Skip to content
Permalink
Browse files

make module IDs deterministic when bundling

Summary:
This makes sure that `getModuleId` is called on modules in the order returned by `node-haste`, rather than waiting for a couple of promises to resolve before calling the function.

Related: #7758

Reviewed By: frantic

Differential Revision: D3450853

fbshipit-source-id: 7f26590b39b94ade32c73a8db9fd31d283d57549
  • Loading branch information
davidaurelio authored and Facebook Github Bot 6 committed Jun 17, 2016
1 parent 99e2a67 commit 62bb09d1f64c6669d08b885f8952e92cc6f07438
Showing with 13 additions and 8 deletions.
  1. +4 −1 local-cli/bundle/output/bundle.js
  2. +9 −7 packager/react-packager/src/Bundler/index.js
@@ -13,7 +13,10 @@ const meta = require('./meta');
const writeFile = require('./writeFile');

function buildBundle(packagerClient, requestOptions) {
return packagerClient.buildBundle(requestOptions);
return packagerClient.buildBundle({
...requestOptions,
isolateModuleIDs: true,
});
}

function createCodeWithMap(bundle, dev) {
@@ -530,12 +530,14 @@ class Bundler {

_toModuleTransport({module, bundle, entryFilePath, transformOptions, getModuleId}) {
let moduleTransport;
const moduleId = getModuleId(module);

if (module.isAsset_DEPRECATED()) {
moduleTransport =
this._generateAssetModule_DEPRECATED(bundle, module, getModuleId);
this._generateAssetModule_DEPRECATED(bundle, module, moduleId);
} else if (module.isAsset()) {
moduleTransport = this._generateAssetModule(
bundle, module, getModuleId, transformOptions.platform);
bundle, module, moduleId, transformOptions.platform);
}

if (moduleTransport) {
@@ -556,7 +558,7 @@ class Bundler {

return new ModuleTransport({
name,
id: getModuleId(module),
id: moduleId,
code,
map,
meta: {dependencies, dependencyOffsets, preloaded},
@@ -566,7 +568,7 @@ class Bundler {
});
}

_generateAssetModule_DEPRECATED(bundle, module, getModuleId) {
_generateAssetModule_DEPRECATED(bundle, module, moduleId) {
return Promise.all([
sizeOf(module.path),
module.getName(),
@@ -586,7 +588,7 @@ class Bundler {

return new ModuleTransport({
name: id,
id: getModuleId(module),
id: moduleId,
code: code,
sourceCode: code,
sourcePath: module.path,
@@ -645,15 +647,15 @@ class Bundler {
}


_generateAssetModule(bundle, module, getModuleId, platform = null) {
_generateAssetModule(bundle, module, moduleId, platform = null) {
return Promise.all([
module.getName(),
this._generateAssetObjAndCode(module, platform),
]).then(([name, {asset, code, meta}]) => {
bundle.addAsset(asset);
return new ModuleTransport({
name,
id: getModuleId(module),
id: moduleId,
code,
meta: meta,
sourceCode: code,

0 comments on commit 62bb09d

Please sign in to comment.
You can’t perform that action at this time.