React-Native Code Splitting
Further split the React Native code based on Metro build to improve performance, providing Dll
and Dynamic Imports
features
Compatibility with Metro versions
-
dependencies react-native -> @react-native-community/cli -> metro
-
metro-code-split -> metro
metro version metro-code-split version 0.64.0 - 0.66.0 0.1.x
How to use it?
- Install the package that matches the Metro version
- Add the scripts in package.json
- More command details
- Modify the metro.config.js
- Execute the command
Custom logic
-
Mcs options provides plugins. You can write plugins in the Mcs as if you were writing Webpack plugins
hooks type parameter beforeInit SyncHook ['bundleOutputInfos'] beforeCheck SyncHook ['freezeFields'] afterCheck SyncHook ['freezeFields'] beforeCustomSerializer SyncBailHook ['entryPoint', 'prepend', 'graph', 'bundleOptions'] beforeOutputChunk SyncHook ['chunkInfo'] afterCustomSerializer SyncHook ['bundle']
Attention to issue
-
This package is only used in
production
environments! (There are currently no plans to be compatible withdevelopment
) -
The add scripts are equivalent to The following (The main purpose is to optimize the
build:dllJson
build:dll
long instructions, if you intend to provide commands using React-Native, be sure to addNODE_ENV=xxx
)