runBeforeMainModule is an empty array
See original GitHub issueDo you want to request a feature or report a bug? report a bug
What is the current behavior?
runBeforeMainModule
is an empty array. I noticed that runBeforeMainModule
config was removed from metro-bundler
in this commit Make the runBeforeMainModule config param to RN repo and make it absolute. runBeforeMainModule
is passed into Server
instance in react-native local-cli.
const options = {
assetExts: defaultAssetExts.concat(assetExts),
assetRegistryPath: ASSET_REGISTRY_PATH,
blacklistRE: config.getBlacklistRE(),
extraNodeModules: config.extraNodeModules,
getPolyfills: config.getPolyfills,
getTransformOptions: config.getTransformOptions,
globalTransformCache: null,
hasteImpl: config.hasteImpl,
maxWorkers: args.maxWorkers,
platforms: defaultPlatforms.concat(platforms),
postMinifyProcess: config.postMinifyProcess,
postProcessModules: config.postProcessModules,
postProcessBundleSourcemap: config.postProcessBundleSourcemap,
projectRoots: config.getProjectRoots(),
providesModuleNodeModules: providesModuleNodeModules,
resetCache: args.resetCache,
reporter: new TerminalReporter(terminal),
runBeforeMainModule: config.runBeforeMainModule,
sourceExts: defaultSourceExts.concat(sourceExts),
transformCache: TransformCaching.useTempDir(),
transformModulePath: transformModulePath,
useDeltaBundler: false,
watch: false,
workerPath: config.getWorkerPath && config.getWorkerPath(),
};
packagerInstance = new Server(options);
However, runBeforeMainModule
is not passed into bundle options.
In shared/output/bundle.js
module, runBeforeMainModule
is not included when packagerClient.buildBundle
is called.
// shared/output/bundle.js
function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
return packagerClient.buildBundle({
...Server.DEFAULT_BUNDLE_OPTIONS,
...requestOptions,
isolateModuleIDs: true,
});
}
In Server/index
module, runBeforeMainModule
is also not included when this._bundler.bundle(options)
is called.
async buildBundle(options: BundleOptions): Promise<Bundle> {
const bundle = await this._bundler.bundle(options);
const modules = bundle.getModules();
const nonVirtual = modules.filter(m => !m.virtual);
bundleDeps.set(bundle, {
files: new Map(
nonVirtual.map(({sourcePath, meta}) => [
sourcePath,
meta != null ? meta.dependencies : [],
]),
),
idToIndex: new Map(modules.map(({id}, i) => [id, i])),
dependencyPairs: new Map(
nonVirtual
.filter(({meta}) => meta && meta.dependencyPairs)
.map(m => [m.sourcePath, m.meta.dependencyPairs]),
),
outdated: new Set(),
});
return bundle;
}
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install
and yarn test
.
What is the expected behavior?
Shouldn’t this._opts.runBeforeMainModule
merged into options
when this._bundler.bundle(options)
is called in buildBundle
function of Server
module?
Please provide your exact metro-bundler configuration and mention your metro-bundler, node, yarn/npm version and operating system.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
That was the case. That resolved it! Thanks so much!
oh, just realized that if you’re using import syntax, you’ll need to also import InitializeCore (
import Foo from 'InitializeCore';
), since imports are hoisted before the require statements. Is this the case?