neo-cmp-cli 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -16,23 +16,35 @@ const createCommonModulesCode = (neoExports) => {
|
|
|
16
16
|
|
|
17
17
|
// 根据 neoExports 获取共享的依赖模块
|
|
18
18
|
if (Array.isArray(neoExports) && neoExports.length > 0) {
|
|
19
|
-
neoExports.forEach(module => {
|
|
19
|
+
neoExports.forEach((module) => {
|
|
20
20
|
CustomCmpCommonModules[module] = require(module);
|
|
21
21
|
});
|
|
22
|
-
} else if (isPlainObject(neoExports)) {
|
|
23
|
-
|
|
22
|
+
} else if (isPlainObject(neoExports) && Object.keys(neoExports).length > 0) {
|
|
23
|
+
Object.keys(neoExports).forEach((moduleId) => {
|
|
24
|
+
CustomCmpCommonModules[moduleId] = `require('${neoExports[moduleId]}')`;
|
|
25
|
+
});
|
|
24
26
|
} else {
|
|
25
|
-
console.error(
|
|
27
|
+
console.error(
|
|
28
|
+
'neoExports 格式不正确,请检查 neo.config.js 文件中的 neoCommonModule / neoExports 配置'
|
|
29
|
+
);
|
|
26
30
|
process.exit(1);
|
|
27
|
-
return '';
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
// 构建 CustomCmpCommonModules 对象的代码字符串
|
|
34
|
+
let customCmpCommonModulesCode = '{\n';
|
|
35
|
+
const moduleEntries = Object.entries(CustomCmpCommonModules);
|
|
36
|
+
moduleEntries.forEach(([moduleId, moduleValue], index) => {
|
|
37
|
+
const isLast = index === moduleEntries.length - 1;
|
|
38
|
+
customCmpCommonModulesCode += ` "${moduleId}": ${moduleValue}${isLast ? '' : ','}\n`;
|
|
39
|
+
});
|
|
40
|
+
customCmpCommonModulesCode += '}';
|
|
41
|
+
|
|
30
42
|
const commonModulesCode = `
|
|
31
43
|
/**
|
|
32
44
|
* 自定义组件 共享出来的依赖模块
|
|
33
45
|
* 备注:可在其他模块中通过 neoRequire 中使用
|
|
34
46
|
*/
|
|
35
|
-
const CustomCmpCommonModules = ${
|
|
47
|
+
const CustomCmpCommonModules = ${customCmpCommonModulesCode};
|
|
36
48
|
|
|
37
49
|
// 用于添加共享的依赖模块
|
|
38
50
|
const addNeoCommonModules = (modules) => {
|
package/src/module/main.js
CHANGED
|
@@ -125,13 +125,19 @@ module.exports = {
|
|
|
125
125
|
curConfig.dev.externals = neoExternals;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
if (
|
|
128
|
+
if (
|
|
129
|
+
cmpNeoExports &&
|
|
130
|
+
((Array.isArray(cmpNeoExports) && cmpNeoExports.length > 0) ||
|
|
131
|
+
(_.isPlainObject(cmpNeoExports) && Object.keys(cmpNeoExports).length > 0))
|
|
132
|
+
) {
|
|
129
133
|
const commonModulesFilePath = createCommonModulesCode(cmpNeoExports);
|
|
130
134
|
|
|
131
135
|
// 所有入口文件添加 commonModulesFile
|
|
132
136
|
if (curConfig.dev.entry) {
|
|
133
137
|
Object.keys(curConfig.dev.entry).forEach((name) => {
|
|
134
|
-
|
|
138
|
+
curConfig.dev.entry[name] = [commonModulesFilePath].concat(
|
|
139
|
+
curConfig.dev.entry[name]
|
|
140
|
+
);
|
|
135
141
|
});
|
|
136
142
|
}
|
|
137
143
|
}
|
|
@@ -230,19 +236,25 @@ module.exports = {
|
|
|
230
236
|
|
|
231
237
|
// 添加 内置 Neo 的 externals 配置
|
|
232
238
|
const neoExternals = getExternalsByNeoCommonModules(cmpNeoExternals);
|
|
233
|
-
if (curConfig.build2lib.externals && _.isPlainObject(curConfig.
|
|
239
|
+
if (curConfig.build2lib.externals && _.isPlainObject(curConfig.build2lib.externals)) {
|
|
234
240
|
curConfig.build2lib.externals = Object.assign(curConfig.build2lib.externals, neoExternals);
|
|
235
241
|
} else {
|
|
236
242
|
curConfig.build2lib.externals = neoExternals;
|
|
237
243
|
}
|
|
238
244
|
|
|
239
|
-
if (
|
|
245
|
+
if (
|
|
246
|
+
cmpNeoExports &&
|
|
247
|
+
((Array.isArray(cmpNeoExports) && cmpNeoExports.length > 0) ||
|
|
248
|
+
(_.isPlainObject(cmpNeoExports) && Object.keys(cmpNeoExports).length > 0))
|
|
249
|
+
) {
|
|
240
250
|
const commonModulesFilePath = createCommonModulesCode(cmpNeoExports);
|
|
241
251
|
|
|
242
252
|
// 所有入口文件添加 commonModulesFile
|
|
243
|
-
if (curConfig.
|
|
244
|
-
Object.keys(curConfig.
|
|
245
|
-
|
|
253
|
+
if (curConfig.build2lib.entry) {
|
|
254
|
+
Object.keys(curConfig.build2lib.entry).forEach((name) => {
|
|
255
|
+
curConfig.build2lib.entry[name] = [commonModulesFilePath].concat(
|
|
256
|
+
curConfig.build2lib.entry[name]
|
|
257
|
+
);
|
|
246
258
|
});
|
|
247
259
|
}
|
|
248
260
|
}
|
|
@@ -41,8 +41,8 @@ module.exports = {
|
|
|
41
41
|
neoCommonModule: {
|
|
42
42
|
// neoExports: ['echarts'], // 自定义组件 共享出来的模块,支持数组和对象
|
|
43
43
|
neoExports: {
|
|
44
|
-
'neo/chart-widget':
|
|
45
|
-
'neo-register':
|
|
44
|
+
// 'neo/chart-widget': './src/components/chart-widget',
|
|
45
|
+
'neo-register': 'neo-register',
|
|
46
46
|
},
|
|
47
47
|
neoExternals: ['echarts'], // 自定义组件 需要剔除的模块,仅支持数组写法
|
|
48
48
|
},
|