mirror of https://github.com/status-im/metro.git
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
This commit is contained in:
parent
50d5275fc0
commit
930ef51646
|
@ -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,7 +647,7 @@ class Bundler {
|
|||
}
|
||||
|
||||
|
||||
_generateAssetModule(bundle, module, getModuleId, platform = null) {
|
||||
_generateAssetModule(bundle, module, moduleId, platform = null) {
|
||||
return Promise.all([
|
||||
module.getName(),
|
||||
this._generateAssetObjAndCode(module, platform),
|
||||
|
@ -653,7 +655,7 @@ class Bundler {
|
|||
bundle.addAsset(asset);
|
||||
return new ModuleTransport({
|
||||
name,
|
||||
id: getModuleId(module),
|
||||
id: moduleId,
|
||||
code,
|
||||
meta: meta,
|
||||
sourceCode: code,
|
||||
|
|
Loading…
Reference in New Issue