mirror of https://github.com/status-im/metro.git
Only write assets referenced in a bundle
Summary: Adds filtering to the assets written from a Buck build, so that we don’t write all assets present in libs, but rather only the ones included in the bundle. Reviewed By: cpojer Differential Revision: D5522844 fbshipit-source-id: fcca3567b726dfab1ecf9560932fd6e1a174b31f
This commit is contained in:
parent
e032e6621f
commit
0272069002
|
@ -92,7 +92,7 @@ exports.createBuildSetup = (
|
||||||
const prependedScripts = [preludeScript, ...moduleSystem, ...polyfills];
|
const prependedScripts = [preludeScript, ...moduleSystem, ...polyfills];
|
||||||
callback(null, {
|
callback(null, {
|
||||||
entryModules,
|
entryModules,
|
||||||
modules: concat(prependedScripts, modules),
|
modules: prependedScripts.concat(modules),
|
||||||
prependedScripts,
|
prependedScripts,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -68,7 +68,7 @@ describe('build setup', () => {
|
||||||
it('places polyfills after the module system', done => {
|
it('places polyfills after the module system', done => {
|
||||||
buildSetup(noEntryPoints, polyfillOptions, (error, result) => {
|
buildSetup(noEntryPoints, polyfillOptions, (error, result) => {
|
||||||
const list = polyfillOptions.getPolyfills();
|
const list = polyfillOptions.getPolyfills();
|
||||||
const polyfills = Array.from(result.modules).slice(2, list.length + 2);
|
const polyfills = result.modules.slice(2, list.length + 2);
|
||||||
expect(polyfills).toEqual(list.map(moduleFromPath));
|
expect(polyfills).toEqual(list.map(moduleFromPath));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -77,7 +77,7 @@ describe('build setup', () => {
|
||||||
it('places all entry points and dependencies at the end, post-processed', done => {
|
it('places all entry points and dependencies at the end, post-processed', done => {
|
||||||
const entryPoints = ['b', 'c', 'd'];
|
const entryPoints = ['b', 'c', 'd'];
|
||||||
buildSetup(entryPoints, noOptions, (error, result) => {
|
buildSetup(entryPoints, noOptions, (error, result) => {
|
||||||
expect(Array.from(result.modules).slice(-4))
|
expect(result.modules.slice(-4))
|
||||||
.toEqual(['a', 'b', 'c', 'd'].map(moduleFromPath));
|
.toEqual(['a', 'b', 'c', 'd'].map(moduleFromPath));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -52,8 +52,8 @@ type GraphOptions = {|
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export type GraphResult = {|
|
export type GraphResult = {|
|
||||||
entryModules: Iterable<Module>,
|
entryModules: $ReadOnlyArray<Module>,
|
||||||
modules: Iterable<Module>,
|
modules: $ReadOnlyArray<Module>,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export type IdForPathFn = {path: string} => number;
|
export type IdForPathFn = {path: string} => number;
|
||||||
|
@ -163,7 +163,11 @@ export type LibraryOptions = {|
|
||||||
|};
|
|};
|
||||||
|
|
||||||
export type Base64Content = string;
|
export type Base64Content = string;
|
||||||
export type AssetContentsByPath = {[destFilePath: string]: Base64Content};
|
export type AssetContents = {
|
||||||
|
+data: Base64Content,
|
||||||
|
+outputPath: string,
|
||||||
|
};
|
||||||
|
export type AssetContentsByPath = {+[moduleFilePath: string]: $ReadOnlyArray<AssetContents>};
|
||||||
|
|
||||||
export type Library = {|
|
export type Library = {|
|
||||||
+files: Array<TransformedCodeFile>,
|
+files: Array<TransformedCodeFile>,
|
||||||
|
|
Loading…
Reference in New Issue