-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuz.config.js
executable file
·58 lines (52 loc) · 1.78 KB
/
buz.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
50
51
52
53
54
55
56
57
58
const pathSep = require('path').sep;
const plaformModules = require('./multi_bundle_map/platformNameMap.json');
const getModuleId = require('./multi_bundle_config/getModulelId').getModuleId;
const useIndex = require('./multi_bundle_config/getModulelId').useIndex;
let entry;
function postProcessModulesFilter(module) {
const projectRootPath = __dirname;
if (plaformModules == null || plaformModules.length == 0) {
console.log('请先打基础包');
process.exit(1);
return false;
}
const path = module['path']
if (path.indexOf("__prelude__") >= 0 ||
path.indexOf("/node_modules/react-native/Libraries/polyfills") >= 0 ||
path.indexOf("source-map") >= 0 ||
path.indexOf("/node_modules/metro/src/lib/polyfills/") >= 0) {
return false;
}
if (module['path'].indexOf(pathSep + 'node_modules' + pathSep) > 0) {
if ('js' + pathSep + 'script' + pathSep + 'virtual' == module['output'][0]['type']) {
return true;
}
const name = getModuleId(projectRootPath,path);
if (useIndex && name < 100000) {//这个模块在基础包已打好,过滤
return false;
}else if(useIndex!==true && plaformModules.includes(name)){//使用模块名作为模块id的逻辑
return false;
}
}
return true;
}
function createModuleIdFactory() {
const projectRootPath = __dirname;
return path => {
let name = getModuleId(projectRootPath,path,entry,true);
return name;
};
}
function getModulesRunBeforeMainModule(entryFilePath) {
console.log('entryFilePath',entryFilePath);
entry = entryFilePath;
return [];
}
module.exports = {
serializer: {
createModuleIdFactory: createModuleIdFactory,
processModuleFilter: postProcessModulesFilter,
getModulesRunBeforeMainModule:getModulesRunBeforeMainModule
/* serializer options */
}
};