question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bundle command does not add InitializeCore to runBeforeMainModule

See original GitHub issue

Bug report I was tracking a react native bug, but since my fix is inside metro code, I figured I repost here: https://github.com/facebook/react-native/issues/19827#issuecomment-404156181

What is the current behavior? When using react-native bundle (the command that runs when you build a release), InitializeCore.js is not the first file that get required, but instead it is required later, sometime during the generation of the bridge method, randomly (which is why if you are lucky or not using Promise // setTimeout early you’ll be fine) iOS does not need all those polyfills which is why the issue is only detected on android in release mode.

My insight: Metro does not add InitializeCore.js to the entry point when building the js bundle. I’ve logged here. The issue being that it takes options.runBeforeMainModule that defaults to []. Maybe we could merge it with _this._opts.getModulesRunBeforeMainModule() which defaults to [‘/node_modules/react-native/Libraries/Core/InitializeCore.js’].

I’ve tried to replace it with

runBeforeMainModule: [
            ...options.runBeforeMainModule,
            ..._this._opts.getModulesRunBeforeMainModule(),
          ],
and android was working in release 🎉

I’d like to get more insight from other people and feel free to ask any other question, thanks

To reproduce just create a new app with RN 0.56 and console.log(Promise) at the top of your index.js, you’ll get Promise is undefined when android release.

RN version: 0.56.0 and related metro version.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
rafecacommented, Jul 13, 2018

Hey folks, https://github.com/facebook/metro/commit/64a5b1d9d40397899ca7eab69da62ee504ef4e54 has just landed with a fix for this. I’m going to cherry-pick this change to the 0.38.x branch and publish metro@0.38.3

Sorry for the inconvenience

3reactions
rafecacommented, Jul 12, 2018

Thanks for the report! @Titozzz your suggestion is correct, I’m going to prepare a fix for this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bundler: Command not found - ruby on rails - Stack Overflow
My problem was that I did: sudo gem install bundler. So I had installed as root rather than as myself. So I uninstalled...
Read more >
Bundle Commands - Bundler
When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named...
Read more >
metro-source-map: Versions - Openbase
NOTE: Experimental features are not covered by semver and can change at any ... [Fixed] Bundle command does not add InitializeCore to runBeforeMainModule....
Read more >
rbenv: bundle: command not found - aloucaslabs.com
When you get the rbenv: bundle: command not found error it is most likely the case that you have installed a new Ruby...
Read more >
bundle-exec - Execute a command in the context of the bundle
rb. Note that bundle exec does not require that an executable is available on your shell´s $PATH. BUNDLE INSTALL --BINSTUBS. If you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found