-
Notifications
You must be signed in to change notification settings - Fork 1
/
metro.common.config.js
49 lines (39 loc) · 1.24 KB
/
metro.common.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { hasBuildInfo, writeBuildInfo, clean } = require("./build");
function createModuleIdFactory() {
const fileToIdMap = new Map();
let nextId = 0;
clean("./config/bundleCommonInfo.json");
// 如果是业务 模块请以 10000000 来自增命名
return (path) => {
let id = fileToIdMap.get(path);
if (typeof id !== "number") {
id = nextId++;
fileToIdMap.set(path, id);
!hasBuildInfo("./config/bundleCommonInfo.json", path) &&
writeBuildInfo(
"./config/bundleCommonInfo.json",
path,
fileToIdMap.get(path)
);
}
return id;
};
}
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
serializer: {
createModuleIdFactory: createModuleIdFactory, // 给 bundle 一个id 避免冲突 cli 源码中这个id 是从1 开始 自增的
},
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
// module.exports = {
// serializer: {
// createModuleIdFactory: createModuleIdFactory, // 给 bundle 一个id 避免冲突 cli 源码中这个id 是从1 开始 自增的
// },
// };