akfun 5.2.10 → 5.2.12

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": "5.2.10",
3
+ "version": "5.2.12",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -13,7 +13,7 @@
13
13
  "author": "wibetter",
14
14
  "license": "MIT",
15
15
  "bin": {
16
- "akfun": "./bin/akfun.js"
16
+ "akfun": "bin/akfun.js"
17
17
  },
18
18
  "main": "module/main.js",
19
19
  "scripts": {
@@ -1,5 +1,4 @@
1
1
  module.exports = {
2
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
3
2
  presets: [
4
3
  [
5
4
  '@babel/preset-env',
@@ -106,7 +106,10 @@ module.exports = function (curConfig, curEnvConfig) {
106
106
  declarationDir: curEnvConfig.declarationDir || './dist/types'
107
107
  })
108
108
  : undefined,
109
- babel(babelConfig), // 备注,需要先babel()再commjs()
109
+ babel({
110
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
111
+ ...babelConfig,
112
+ }), // 备注,需要先babel()再commjs()
110
113
  buildType === 'ts' ? undefined : jsx({ factory: 'React.createElement' }),
111
114
  vue(),
112
115
  commonjs({
@@ -39,16 +39,18 @@ module.exports = (_curEnvConfig, _akfunConfig, buildMode = 'build') => {
39
39
  // 获取当前项目目录
40
40
  const curProjectDir = getProjectDir(curWebpackConfig.projectDir);
41
41
 
42
- // 剔除掉 babel-loader 不需要的配置
43
- delete babelConfig.extensions;
44
-
42
+ // 避免引用 babelConfig 的原始数据,导致数据污染
43
+ const curBabelConfig = {
44
+ ...babelConfig
45
+ };
46
+
45
47
  // 判断是否有自定义 Babel plugins
46
48
  if (isArray(curWebpackConfig.babelPlugins)) {
47
49
  // 添加自定义babel插件
48
- babelConfig.plugins.push(...curWebpackConfig.babelPlugins);
50
+ curBabelConfig.plugins.push(...curWebpackConfig.babelPlugins);
49
51
  } else if (isFunction(curWebpackConfig.babelPlugins)) {
50
52
  // 处理自定义babel插件
51
- curWebpackConfig.babelPlugins(babelConfig.plugins);
53
+ curWebpackConfig.babelPlugins(curBabelConfig.plugins);
52
54
  }
53
55
 
54
56
  // 获取缓存目录路径
@@ -112,7 +114,7 @@ module.exports = (_curEnvConfig, _akfunConfig, buildMode = 'build') => {
112
114
  {
113
115
  loader: 'babel-loader',
114
116
  options: {
115
- ...babelConfig,
117
+ ...curBabelConfig,
116
118
  // Babel 缓存配置
117
119
  cacheDirectory: true, // 启用缓存
118
120
  cacheCompression: false, // 不压缩缓存文件以提升性能
@@ -143,7 +145,7 @@ module.exports = (_curEnvConfig, _akfunConfig, buildMode = 'build') => {
143
145
  {
144
146
  loader: 'babel-loader',
145
147
  options: {
146
- ...babelConfig,
148
+ ...curBabelConfig,
147
149
  // Babel 缓存配置
148
150
  cacheDirectory: true, // 启用缓存
149
151
  cacheCompression: false, // 不压缩缓存文件以提升性能