akfun 3.1.8 → 3.2.1

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.8",
3
+ "version": "3.2.1",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -73,6 +73,7 @@
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",
76
77
  "@typescript-eslint/eslint-plugin": "^5.10.2",
77
78
  "@typescript-eslint/parser": "^5.10.2",
78
79
  "@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,30 +19,37 @@ 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中配置)
48
+ /**
49
+ * external:(在akfun.config.js中配置)
50
+ * 需要一个 id 并返回 true(外部引用)或 false(不是外部的引用), 或者 Array 应该保留在bundle的外部引用的模块ID。
51
+ */
52
+ external: build2esm.external || [],
44
53
  plugins: [
45
54
  alias({
46
55
  resolve: curConfig.webpack.resolve.extensions,
@@ -50,7 +59,9 @@ module.exports = function(fileName, akfunConfig) {
50
59
  nodeResolve({
51
60
  extensions: curConfig.webpack.resolve.extensions
52
61
  }),
62
+ typescript(),
53
63
  babel(babelConfig), // 备注,需要先babel()再commjs()
64
+ // jsx( {factory: 'React.createElement'} ),
54
65
  vue(),
55
66
  commonjs(),
56
67
  postcss({
@@ -101,8 +101,8 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
101
101
  }
102
102
  }
103
103
  ],
104
- include: curProjectDir, // [resolve('src')],
105
- exclude: /node_modules/
104
+ // exclude: /node_modules/,
105
+ include: curProjectDir // [resolve('src')],
106
106
  },
107
107
  {
108
108
  test: /\.(jsx?)$/,
@@ -112,8 +112,8 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
112
112
  options: babelConfig
113
113
  }
114
114
  ],
115
- include: curProjectDir, // [resolve('src')],
116
- exclude: /node_modules/
115
+ // exclude: /node_modules/,
116
+ include: curProjectDir // [resolve('src')],
117
117
  },
118
118
  {
119
119
  // 图片资源
@@ -163,8 +163,8 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
163
163
  {
164
164
  test: /\.(js|ts|tsx|jsx|vue|css|html)$/,
165
165
  loader: 'params-replace-loader',
166
+ // exclude: [/node_modules/, resolve('src/mock/data')], // 排除不需要进行校验的文件夹
166
167
  include: curProjectDir, // [resolve('src')],
167
- exclude: [/node_modules/, resolve('src/mock/data')], // 排除不需要进行校验的文件夹
168
168
  options: config.envParams
169
169
  },
170
170
  {
@@ -243,7 +243,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
243
243
  // context: resolve('src'),
244
244
  extensions: ['ts', 'tsx'],
245
245
  // include: curProjectDir, // [resolve('src')],
246
- exclude: 'node_modules',
246
+ // exclude: 'node_modules',
247
247
  cache: true,
248
248
  fix: config.settings.enableESLintFix || false,
249
249
  formatter: require('eslint-friendly-formatter'),
@@ -255,7 +255,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
255
255
  new ESLintPlugin({
256
256
  extensions: ['js', 'jsx'],
257
257
  // include: curProjectDir, // [resolve('src')],
258
- exclude: 'node_modules',
258
+ // exclude: 'node_modules',
259
259
  cache: true,
260
260
  fix: config.settings.enableESLintFix || false,
261
261
  formatter: require('eslint-friendly-formatter'),
@@ -267,7 +267,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
267
267
  new ESLintPlugin({
268
268
  extensions: ['vue'],
269
269
  // include: curProjectDir, // [resolve('src')],
270
- exclude: 'node_modules',
270
+ // exclude: 'node_modules',
271
271
  cache: true,
272
272
  fix: config.settings.enableESLintFix || false,
273
273
  formatter: require('eslint-friendly-formatter'),