Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Further split the React Native code based on Metro build to improve performance,
- dependencies 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 |
| metro version | metro-code-split version |
|:---------------:|:------------------------:|
| 0.64.0 - 0.66.2 | 0.1.x |
| 0.81.5 | Package not generated yet<br/> (requires manual packaging) |

## How to use it?

Expand Down Expand Up @@ -67,8 +68,24 @@ Further split the React Native code based on Metro build to improve performance,
}),
},
}

module.exports = process.env.NODE_ENV === 'production' ? mcs.mergeTo(busineConfig) : busineConfig

// module.exports = process.env.NODE_ENV === 'production' ? mcs.mergeTo(busineConfig) : busineConfig

async function getMetroConfig() {
let configToMerge;

if (process.env.NODE_ENV === 'production') {
configToMerge = await mcs.mergeTo(busineConfig);
} else {
configToMerge = [busineConfig];
}

const defaultConfig = await getDefaultConfig(__dirname);

return mergeConfig(defaultConfig, ...configToMerge);
}

module.exports = getMetroConfig();
```

- [Mcs DefaultOptions](./src/index.js)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"general-tools": "^0.0.4"
},
"peerDependencies": {
"metro": ">=0.64.0"
"metro": "^0.81.5"
},
"files": [
"src"
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const { mergeConfig } = require('metro-config')
const { fse, ejs, tapable: { SyncHook, SyncBailHook }, log, paths: ps, dataExtend, argv } = require('general-tools')
const baseConfig = require('./config/baseConfig')
const InjectVar = require('./plugins/InjectVar')
Expand Down Expand Up @@ -261,7 +260,7 @@ class MetroCodeSplit {
this.check(busineConfig)
this.hooks.afterCheck.call(this.freezeFields)
const craeteMustConfig = require('./config/craeteMustConfig')
return mergeConfig(baseConfig, busineConfig, craeteMustConfig(this))
return [baseConfig, busineConfig, craeteMustConfig(this)]
}

get baseJSBundle () { return require(this.options.baseJSBundlePath) }
Expand Down