akfun 3.1.9 → 3.2.2

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": "akfun",
3
- "version": "3.1.9",
3
+ "version": "3.2.2",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -73,6 +73,8 @@
73
73
  "@rollup/plugin-image": "^2.1.1",
74
74
  "@rollup/plugin-json": "^4.1.0",
75
75
  "@rollup/plugin-node-resolve": "^13.1.3",
76
+ "@rollup/plugin-typescript": "^8.3.1",
77
+ "rollup-plugin-node-externals": "^4.0.0",
76
78
  "@typescript-eslint/eslint-plugin": "^5.10.2",
77
79
  "@typescript-eslint/parser": "^5.10.2",
78
80
  "@vue/compiler-sfc": "^3.2.29",
@@ -1,6 +1,8 @@
1
1
  // rollup.config.js
2
2
  const { babel } = require('@rollup/plugin-babel');
3
3
  const { nodeResolve } = require('@rollup/plugin-node-resolve'); // 支持node中的文件导入
4
+ // const jsx = require('rollup-plugin-jsx'); // 用于处理jsx
5
+ const typescript = require('@rollup/plugin-typescript'); // 支持ts
4
6
  const commonjs = require('@rollup/plugin-commonjs'); // 识别cmd模块
5
7
  const vue = require('rollup-plugin-vue');
6
8
  const json = require('@rollup/plugin-json'); // 识别json类型文件
@@ -17,40 +19,51 @@ const nested = require('postcss-nested');
17
19
  const postcssPresetEnv = require('postcss-preset-env');
18
20
  // css代码压缩
19
21
  const cssnano = require('cssnano');
22
+ const { externals } = require('rollup-plugin-node-externals');
20
23
  const { resolveToCurrentRoot, resolveToCurrentDist } = require('../utils/pathUtils'); // 统一路径解析
21
24
  const babelConfig = require('./babel.config'); // Babel的配置文件
22
- const curProjectConfig = require('./index'); // 引入当前项目配置文件
23
- const {buildBanner} = require("../utils/akfunParams");
25
+ const projectConfig = require('./index'); // 引入当前项目配置文件
26
+ const { buildBanner } = require('../utils/akfunParams');
24
27
 
25
- module.exports = function(fileName, akfunConfig) {
28
+ module.exports = function (fileName, akfunConfig) {
26
29
  const curConfig = akfunConfig || curProjectConfig;
30
+ const build2esm = curConfig.build2esm || {};
27
31
  // 获取用户配置的构建入口文件
28
32
  let rollupInput = resolveToCurrentRoot('src/main.js');
29
- if (curConfig.build2esm && curConfig.build2esm.input) {
30
- rollupInput = curConfig.build2esm.input;
33
+ if (build2esm.input) {
34
+ rollupInput = build2esm.input;
31
35
  }
32
36
  let curFileName = fileName || 'index'; // 默认以"index.esm.js"输出
33
37
  // 获取用户配置的构建输出文件名
34
- if (curConfig.build2esm && curConfig.build2esm.fileName) {
35
- curFileName = curConfig.build2esm.fileName;
38
+ if (build2esm.fileName) {
39
+ curFileName = build2esm.fileName;
36
40
  }
37
41
  // 增加babel配置
38
42
  babelConfig.babelHelpers = 'runtime';
39
43
 
40
44
  return {
41
45
  banner: buildBanner,
46
+ // format: build2esm.format || 'esm', // 生成包的格式
42
47
  input: rollupInput,
43
- // external:将模块视为外部模块,不会打包在库中(在akfun.config.js中配置)
44
48
  plugins: [
45
49
  alias({
46
50
  resolve: curConfig.webpack.resolve.extensions,
47
51
  extensions: curConfig.webpack.resolve.extensions,
48
52
  entries: curConfig.webpack.resolve.alias
49
53
  }),
54
+ /**
55
+ * excludeList(在akfun.config.js中配置)
56
+ * 设置打包中应该排除的依赖
57
+ */
58
+ externals({
59
+ include: build2esm.excludeList || []
60
+ }),
50
61
  nodeResolve({
51
62
  extensions: curConfig.webpack.resolve.extensions
52
63
  }),
64
+ typescript(),
53
65
  babel(babelConfig), // 备注,需要先babel()再commjs()
66
+ // jsx( {factory: 'React.createElement'} ),
54
67
  vue(),
55
68
  commonjs(),
56
69
  postcss({
@@ -102,7 +102,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
102
102
  }
103
103
  ],
104
104
  // exclude: /node_modules/,
105
- include: curProjectDir, // [resolve('src')],
105
+ include: curProjectDir // [resolve('src')],
106
106
  },
107
107
  {
108
108
  test: /\.(jsx?)$/,
@@ -113,7 +113,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
113
113
  }
114
114
  ],
115
115
  // exclude: /node_modules/,
116
- include: curProjectDir, // [resolve('src')],
116
+ include: curProjectDir // [resolve('src')],
117
117
  },
118
118
  {
119
119
  // 图片资源