neo-cmp-cli 1.1.3 → 1.1.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -11,6 +11,7 @@ const getEntries = require('../cmpUtils/getEntries');
11
11
  const getEntriesWithAutoRegister = require('../cmpUtils/getEntriesWithAutoRegister');
12
12
  const previewCmp = require('./previewCmp');
13
13
  const AddNeoRequirePlugin = require('../plugins/AddNeoRequirePlugin');
14
+ const { getExternalsByNeoCommonModules } = require('../neo/neoRequire');
14
15
  // const { MFPlugins } = require('../utils/webpack.mf');
15
16
 
16
17
  const getValue = (originValue, defaultValue) => {
@@ -108,6 +109,17 @@ module.exports = {
108
109
  curConfig.webpack.plugins = [new AddNeoRequirePlugin()];
109
110
  }
110
111
 
112
+ // 添加 externals 配置
113
+ const neoExternals = getExternalsByNeoCommonModules();
114
+ if (
115
+ curConfig.dev.externals &&
116
+ Array.isArray(curConfig.dev.externals)
117
+ ) {
118
+ curConfig.dev.externals.push(...neoExternals);
119
+ } else {
120
+ curConfig.dev.externals = neoExternals;
121
+ }
122
+
111
123
  akfun.dev(curConfig, consoleTag);
112
124
  },
113
125
  build: () => akfun.build('build', curConfig, consoleTag), // 构建脚本:生产环境
@@ -200,6 +212,17 @@ module.exports = {
200
212
  curConfig.webpack.plugins = [new AddNeoRequirePlugin()];
201
213
  }
202
214
 
215
+ // 添加 externals 配置
216
+ const neoExternals = getExternalsByNeoCommonModules();
217
+ if (
218
+ curConfig.build2lib.externals &&
219
+ Array.isArray(curConfig.build2lib.externals)
220
+ ) {
221
+ curConfig.build2lib.externals.push(...neoExternals);
222
+ } else {
223
+ curConfig.build2lib.externals = neoExternals;
224
+ }
225
+
203
226
  akfun.build('lib', curConfig, consoleTag, () => {
204
227
  // 构建完成后,执行 publish2oss
205
228
  publish2oss(
@@ -17,6 +17,14 @@ const NeoCommonModules = {
17
17
  };
18
18
 
19
19
  // 根据 Neo 共享出来的依赖模块,获取 externals 配置
20
+ const getExternalsByNeoCommonModulesV1 = () => {
21
+ const neoExternals = {};
22
+ Object.keys(NeoCommonModules).forEach(moduleName => {
23
+ neoExternals[moduleName] = `commonjs ${moduleName}`;
24
+ });
25
+ return neoExternals;
26
+ };
27
+
20
28
  const getExternalsByNeoCommonModules = () => {
21
29
  return Object.keys(NeoCommonModules).map(moduleName => `commonjs ${moduleName}`);
22
30
  };
@@ -33,7 +33,7 @@ class AddNeoRequirePlugin {
33
33
  })(function(require) {
34
34
  `;
35
35
 
36
- const Footer = `}))`;
36
+ const Footer = `})`;
37
37
 
38
38
  compilation.updateAsset(file, (oldFileContent) => new ConcatSource(Header, oldFileContent, Footer));
39
39
  }
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.1.2",
50
+ "neo-cmp-cli": "^1.1.3",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"