Skip to content

Commit

Permalink
[smart] facebook#2 support filter exclude modules to package business…
Browse files Browse the repository at this point in the history
… bundle
  • Loading branch information
krmao committed May 24, 2018
1 parent bf7050b commit 24ef406
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ npm-debug.log*
packages/*/build/

/packages-release
package-lock.json
package-lock.json

.idea/
13 changes: 12 additions & 1 deletion packages/metro/src/DeltaBundler/Serializers/Serializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,20 @@ async function fullBundle(
options,
);

const code = modules.map(m => m.code);
var finalModules = modules;
if(options.excludedModules) {
console.log("\n\nFilter before modules.length=="+finalModules.length+ "\n")
finalModules = finalModules.filter(module => {
const keep = !options.excludedModules[module.name];
console.log("Filtering "+ (keep? "keep -> ": "remove -> ")+ module.name+ ", "+ module.path)
return keep
})
console.log("\nFilter after modules.length=="+finalModules.length+ "\n")
}

const code = finalModules.map(m => m.code);
return {
modules: finalModules,
bundle: code.join('\n'),
lastModified,
numModifiedFiles,
Expand Down
3 changes: 2 additions & 1 deletion packages/metro/src/Server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class Server {
return this._deltaBundler;
}

async build(options: BundleOptions): Promise<{code: string, map: string}> {
async build(options: BundleOptions): Promise<{code: string, map: string, modules: mixed}> {
options = {
...options,
runBeforeMainModule: this._opts.getModulesRunBeforeMainModule(
Expand All @@ -249,6 +249,7 @@ class Server {
return {
code: fullBundle.bundle,
map: fullMap,
modules: fullBundle.modules,
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/metro/src/shared/output/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {MetroSourceMap} from 'metro-source-map';
function buildBundle(
packagerClient: Server,
requestOptions: RequestOptions,
): Promise<{code: string, map: string}> {
): Promise<{code: string, map: string, modules: mixed}> {
return packagerClient.build({
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOptions,
Expand Down

0 comments on commit 24ef406

Please sign in to comment.