-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Add support code for experimental dev-mode bundle splitting #32098
Conversation
Differential Revision: D30577963 fbshipit-source-id: bd408ccbb727018a17564ef0a102df90b84b35ce
Summary: Changelog: [Internal] Moves `asyncRequireForMetro.js` into React Native. This code can be used together with `experimentalImportBundleSupport: true` in Metro to load split bundles in development from a Metro server. This is still an experimental, undocumented workflow - proper documentation will follow when it's stable. The minimal Metro config required for this to work is: ``` // metro.config.js module.exports = { transformer: { asyncRequireModulePath: 'react-native/Libraries/DevBundleLoading/asyncRequireForMetro.js', experimentalImportBundleSupport: true, }, }; ``` Differential Revision: D30580274 fbshipit-source-id: 740af4947f753c8bed36fab67accd638ac0c3904
This pull request was exported from Phabricator. Differential Revision: D30580274 |
|
cc @cpojer, @EvanBacon |
Base commit: 362511d |
Base commit: 362511d |
} | ||
}) | ||
.finally(() => { | ||
if (!--pendingRequests) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this pendingRequests++
?
return importBundlePromises[stringModuleID]; | ||
} | ||
|
||
return dynamicRequire.importAll(moduleID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would this be used?
|
||
const requestUrl = buildUrlForBundle(bundlePath, { | ||
modulesOnly: 'true', | ||
runModule: 'false', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing shallow: true
?
Edit: This actually doesn't work with shallow true if you have an async module inside another async module, but the bundles appear to be larger.
); | ||
} | ||
|
||
HMRClient.registerBundle(requestUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi I found a bug with this code that you also have at Facebook. When Metro's websocket disconnects and reconnects, it will not replay the registerBundle
calls and Metro won't update the right files any longer. Most likely it will manifest in Fast Refresh breaking until you reload. The fix is to append registerBundle
calls to a Set
and replay them when reconnecting.
Any idea of when / if this will be merged? |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Lazy bundling shipped in React Native 0.73. |
Summary:
Changelog: [Internal]
Moves
asyncRequireForMetro.js
into React Native. This code can be used together withexperimentalImportBundleSupport: true
in Metro to load split bundles in development from a Metro server. This is still an experimental, undocumented workflow - proper documentation will follow when it's stable.The minimal Metro config required for this to work is:
Differential Revision: D30580274