
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
metro-code-split
Advanced tools
Further split the React Native code based on Metro build to improve performance, providing `Dll` and `Dynamic Imports` features
Further split the React Native code based on Metro build to improve performance, providing Dll and Dynamic Imports features
Dll The split 820KB + common code (react、react-native) can be built into the App, similar to the Webpack DLLPluginDynamic Imports issuedependencies react-native -> @react-native-community/cli -> metro
metro-code-split -> metro
| metro version | metro-code-split version |
|---|---|
| 0.64.0 - 0.66.2 | 0.1.x |
npm i metro-code-split -D | yarn add metro-code-split -D
"scripts": {
"start": "mcs-scripts start -p 8081",
"build:dllJson": "mcs-scripts build -t dllJson -od public/dll",
"build:dll": "mcs-scripts build -t dll -od public/dll",
"build": "mcs-scripts build -t busine -e index.js"
}
npx mcs-scripts --help
const Mcs = require('metro-code-split')
const mcs = new Mcs({
output: {
publicPath: 'https://a.cdn.com/a-rn-project',
},
dll: {
entry: ['react-native', 'react'], // which three - party library into dll
referenceDir: './public/dll', // the JSON address to reference for the build DLL file, also the npm run build:dllJson output directory
},
dynamicImports: {}, // DynamicImports can also be set to false to disable this feature if it is not required
})
const busineConfig = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
}
module.exports = process.env.NODE_ENV === 'production' ? mcs.mergeTo(busineConfig) : busineConfig
npm run build:dllJson // build the reference json file for the Dll
npm run build:dll // build the Dll file (the generated Dll file is usually built into the APP)
npm run build // build busine code
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'] |
This package is only used in production environments! (There are currently no plans to be compatible with development)
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 add NODE_ENV=xxx)
"scripts": {
"start": "NODE_ENV=production react-native start --port 8081",
"build:dllJson": "NODE_ENV=production react-native bundle --platform ios --entry-file node_modules/.cache/metro-code-split/dll-entry.js --bundle-output public/dll/_dll.ios.json --dev false & NODE_ENV=production react-native bundle --platform android --entry-file node_modules/.cache/metro-code-split/dll-entry.js --bundle-output public/dll/_dll.android.json --dev false",
"build:dll": "NODE_ENV=production react-native bundle --platform ios --entry-file node_modules/.cache/metro-code-split/dll-entry.js --bundle-output public/dll/_dll.ios.bundle --dev false & NODE_ENV=production react-native bundle --platform android --entry-file node_modules/.cache/metro-code-split/dll-entry.js --bundle-output public/dll/_dll.android.bundle --dev false",
"build": "NODE_ENV=production react-native bundle --platform ios --entry-file index.js --bundle-output dist/buz.ios.bundle --dev false & NODE_ENV=production react-native bundle --platform android --entry-file index.js --bundle-output dist/buz.android.bundle --dev false"
}
FAQs
Further split the React Native code based on Metro build to improve performance, providing `Dll` and `Dynamic Imports` features
The npm package metro-code-split receives a total of 7 weekly downloads. As such, metro-code-split popularity was classified as not popular.
We found that metro-code-split demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.