Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG when metro.confg.js file is used #27518

Closed
mahi8813 opened this issue Dec 15, 2019 · 4 comments
Closed

BUG when metro.confg.js file is used #27518

mahi8813 opened this issue Dec 15, 2019 · 4 comments
Labels
Bug Needs: Author Feedback Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@mahi8813
Copy link

I am trying to enable RAM bundles for a ios react-native project to improve startup performance. I have bundled using ram-bundle option of react-native cli which worked fine. But after this, i tried to use preloadedModules feature to further improve startup time as described in https://facebook.github.io/react-native/docs/performance#updating-the-metroconfigjs

added both metro.config.js & packager/modulePaths.js in my project.
Bundled my code using ram-bundle.
However, the resultant bundle is not working properly, the home never loads and stucks at the loading screen. Upon further debugging, the issue seems to be that none of the callbacks from native to js are being invoked. As a result, my home screen response nevers comes to JS side and stuck at loading screen.

This only happens when i add metro.config.js file to my project. Suspecting the entries in preloadedModules, i have remved add entries in packager/modulePaths.js and return empty config in metro.config.js. Even then resultant bundle is not working. It works only if remove metro.config.js from my project.

I wanted to use preloadedModules feature to further improve startup time but facing this issue. Any help to solve this would be highly appreciated?

To Reproduce:

  1. Add the attached metro.config.js file to project root folder.
  2. Bundle the code (plain or ram bundle) using the following command
    node_modules/.bin/react-native bundle --reset-cache --entry-file index.ios.js --platform ios --dev false --bundle-output main.jsbundle --sourcemap-output main.jsbundle.map
  3. Run in debug mode, you ll see the application behaviour is undefined.

Env:

React Native - 0.61.4
metro - 0.56.0

metro.config.js

`const modulePaths = require('./packager/modulePaths');
const resolve = require('path').resolve;
const fs = require('fs');

// Update the following line if the root folder of your app is somewhere else.
const ROOT_FOLDER = resolve(__dirname);

const config = {
serializer: {
getModulesRunBeforeMainModule: () => [
resolve('node_modules/react-native/Libraries/Core/InitializeCore.js')
]
},
transformer: {
getTransformOptions: () => {
const moduleMap = {};
modulePaths.forEach(path => {
if (fs.existsSync(path)) {
moduleMap[resolve(path)] = true;
}
});
return {
preloadedModules: moduleMap,
transform: { inlineRequires: { blacklist: moduleMap } },
};
},
},
projectRoot:ROOT_FOLDER,
};

module.exports = config;`

NOTE: Plain bundle with metro.config.js added also has the same [issue.](url)

@mahi8813 mahi8813 added the Bug label Dec 15, 2019
@react-native-bot
Copy link
Collaborator

Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?

👉 Click here if you want to take another look at the Bug Report issue template.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Resolution: Needs More Information labels Dec 15, 2019
@mahi8813 mahi8813 reopened this Dec 15, 2019
@mahi8813
Copy link
Author

Screenshot 2019-12-15 at 7 30 50 PM

emoryt config in metro.config.js

@mahi8813
Copy link
Author

if the file is removed and bundled, then it works fine. So i feel its definitely a bug. Just by adding empty metro.config.js, the issue is reproducible

@no-response
Copy link

no-response bot commented Mar 5, 2020

It's been three weeks since we asked for additional information from the author of this issue. As it happens, we don't have enough information to take action. We are going to close this issue, but please do not hesitate to open a new issue if you are still encountering this problem.

@no-response no-response bot closed this as completed Mar 5, 2020
@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Needs: Author Feedback Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants