-
Notifications
You must be signed in to change notification settings - Fork 186
/
buz-ui.config.js
executable file
·72 lines (66 loc) · 2.11 KB
/
buz-ui.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const pathSep = require('path').sep;
const buzDeps = require('./buzDep');
const noFilterModules = buzDeps;
const plaformModules = require('./multibundler/platformNameMap.json');
const getModuleId = require('./multibundler/getModulelId').getModuleId;
const useIndex = require('./multibundler/getModulelId').useIndex;
let entry;
function packageToBundle(path){
for(let i=0;i<noFilterModules.length;i++) {
let moduleName = noFilterModules[i];
if (path.indexOf(pathSep + 'node_modules' + pathSep + moduleName) > 0) {
return true;
}
}
return false;
}
function postProcessModulesFilter(module) {//返回false则过滤不编译
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(path.indexOf(pathSep+'node_modules'+pathSep)>0){
if(packageToBundle(module['path'])){
return true;
}
if('js'+pathSep+'script'+pathSep+'virtual'==module['output'][0]['type']){
return false;
}
let 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 */
}
};