mirror of https://github.com/status-im/metro.git
409a2ae809
Summary: This diff enables the HMR transforms for any bundle requested through the metro-bundler HTTP server, so it ignores the `hot` parameter passed in the URL. This allows much faster switches when enabling/disabling HMR, since metro-bundler does not need to re-compile each single file again, while not impacting substantially build times when HMR is off. I've done some lightweight benchmarks on my machine and these are the results (all the tests have been done after running metro-bundler with a clean cache and restarting the app). **Before** Time to build (HMR off): 1x (baseline) Time to build (HMR on): 1.90x **This diff** Time to build (HMR off): 1.009x Time to build (HMR on): 1.036x (The reason why now it takes double the time to load the HMR bundle than the non-HMR bundle after launching the app is because the device after a restart always asks for the non-HMR bundle and afterwards the HMR bundle, causing the server to have to build both bundles). **Bundle size** In terms of bundle size, adding the HMR transforms increases the size by around 3-4% (this regression is due to the wrappers added around React components, and will depend on the app). **Next steps** There are two improvements to do after this diff: 1. Remove the `hot=true` parameter from the clients when they request the bundle. This will reduce by half the memory used by metro-bundler when switching from non-HMR to HMR (or when opening the app with HMR enabled), since metro-bundler caches the bundles based on url. 2. After this diff, the `hot` parameter in the various options objects will not make much sense, so my suggestion is to just remove it from everywhere and instead of checking for that parameter in the transformer, check for `dev=true` there. Reviewed By: davidaurelio Differential Revision: D5623623 fbshipit-source-id: cb76b9182e55f442e2987fcf59eee2ba2571578e |
||
---|---|---|
.. | ||
src | ||
.eslintrc | ||
.npmignore | ||
Glossary.md | ||
README.md | ||
package.json | ||
rn-babelrc.json | ||
yarn.lock |
README.md
metro-bundler
🚇 The JavaScript bundler for React Native.
- 🚅 Fast: We aim for sub-second reload cycles, fast startup and quick bundling speeds.
- ⚖️ Scalable: Works with thousands of modules in a single application.
- ⚛️ Integrated: Supports every React Native project out of the box.
This project was previously part of the react-native repository. In this smaller repository it is easier for the team working on Metro Bundler to respond to both issues and pull requests. See react-native#13976 for the initial announcement.