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:
David Aurelio 2017-07-31 09:52:17 -07:00 committed by Facebook Github Bot
parent e032e6621f
commit 0272069002
3 changed files with 10 additions and 6 deletions

View File

@ -92,7 +92,7 @@ exports.createBuildSetup = (
const prependedScripts = [preludeScript, ...moduleSystem, ...polyfills];
callback(null, {
entryModules,
modules: concat(prependedScripts, modules),
modules: prependedScripts.concat(modules),
prependedScripts,
});
});

View File

@ -68,7 +68,7 @@ describe('build setup', () => {
it('places polyfills after the module system', done => {
buildSetup(noEntryPoints, polyfillOptions, (error, result) => {
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));
done();
});
@ -77,7 +77,7 @@ describe('build setup', () => {
it('places all entry points and dependencies at the end, post-processed', done => {
const entryPoints = ['b', 'c', 'd'];
buildSetup(entryPoints, noOptions, (error, result) => {
expect(Array.from(result.modules).slice(-4))
expect(result.modules.slice(-4))
.toEqual(['a', 'b', 'c', 'd'].map(moduleFromPath));
done();
});

View File

@ -52,8 +52,8 @@ type GraphOptions = {|
|};
export type GraphResult = {|
entryModules: Iterable<Module>,
modules: Iterable<Module>,
entryModules: $ReadOnlyArray<Module>,
modules: $ReadOnlyArray<Module>,
|};
export type IdForPathFn = {path: string} => number;
@ -163,7 +163,11 @@ export type LibraryOptions = {|
|};
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 = {|
+files: Array<TransformedCodeFile>,