akfun 5.2.8 → 5.2.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "5.2.8",
3
+ "version": "5.2.10",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -5,7 +5,7 @@ module.exports = {
5
5
  '@babel/preset-env',
6
6
  {
7
7
  loose: true,
8
- modules: false, // 是否启用将ES6模块语法转换为其他模块类型的功能,当前设置为false,以便webpack进行tree shaking。
8
+ modules: false // 是否启用将ES6模块语法转换为其他模块类型的功能,当前设置为false,以便webpack进行tree shaking。
9
9
  /*
10
10
  备注:后续升级babel版本时,再启用此配置
11
11
  useBuiltIns: 'usage', // 按需引入 polyfill,替代 @babel/polyfill
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Babel 插件:自动在 React 组件的最外层元素添加 data-scope 属性
3
- *
3
+ *
4
4
  * 使用场景:
5
5
  * - 在构建 React 组件时,自动为组件的根元素添加 data-scope 属性
6
6
  * - 支持函数组件和类组件
@@ -12,18 +12,17 @@ module.exports = function ({ types: t }) {
12
12
  */
13
13
  function returnsJSX(path) {
14
14
  const body = path.get('body');
15
-
15
+
16
16
  if (body.isBlockStatement()) {
17
17
  // 检查函数体中是否有返回 JSX 的语句
18
18
  let hasJSXReturn = false;
19
19
  body.traverse({
20
20
  ReturnStatement(returnPath) {
21
21
  const argument = returnPath.get('argument');
22
- if (argument.node && (
23
- argument.isJSXElement() ||
24
- argument.isJSXFragment() ||
25
- argument.isArrayExpression()
26
- )) {
22
+ if (
23
+ argument.node &&
24
+ (argument.isJSXElement() || argument.isJSXFragment() || argument.isArrayExpression())
25
+ ) {
27
26
  hasJSXReturn = true;
28
27
  returnPath.stop();
29
28
  }
@@ -34,7 +33,7 @@ module.exports = function ({ types: t }) {
34
33
  // 箭头函数直接返回 JSX
35
34
  return true;
36
35
  }
37
-
36
+
38
37
  return false;
39
38
  }
40
39
 
@@ -47,15 +46,12 @@ module.exports = function ({ types: t }) {
47
46
 
48
47
  // 检查是否已经存在 data-scope 属性
49
48
  const hasDataScope = attributes.some(
50
- attr => t.isJSXAttribute(attr) && attr.name.name === 'data-scope'
49
+ (attr) => t.isJSXAttribute(attr) && attr.name.name === 'data-scope'
51
50
  );
52
51
 
53
52
  if (!hasDataScope) {
54
53
  // 创建 data-scope 属性
55
- const dataScopeAttr = t.jsxAttribute(
56
- t.jsxIdentifier('data-scope'),
57
- t.stringLiteral('')
58
- );
54
+ const dataScopeAttr = t.jsxAttribute(t.jsxIdentifier('data-scope'), t.stringLiteral(''));
59
55
  // 添加到属性列表的开头
60
56
  attributes.unshift(dataScopeAttr);
61
57
  }
@@ -66,7 +62,7 @@ module.exports = function ({ types: t }) {
66
62
  */
67
63
  function processReturnStatement(path) {
68
64
  const argument = path.get('argument');
69
-
65
+
70
66
  if (!argument.node) {
71
67
  return;
72
68
  }
@@ -146,7 +142,7 @@ module.exports = function ({ types: t }) {
146
142
  }
147
143
 
148
144
  const body = path.get('body');
149
-
145
+
150
146
  // 处理函数体中的返回语句
151
147
  if (body.isBlockStatement()) {
152
148
  body.traverse({
@@ -185,4 +181,3 @@ module.exports = function ({ types: t }) {
185
181
  }
186
182
  };
187
183
  };
188
-
@@ -66,6 +66,11 @@ module.exports = function (config, envConfig, _rollupConfig, _consoleTag) {
66
66
  }
67
67
  if (compress && isArray(curRollupConfig.output)) {
68
68
  curRollupConfig.output.map((outputItem) => {
69
+ if (outputItem.notCompressed) {
70
+ // 不压缩代码
71
+ delete outputItem.notCompressed; // 剔除掉 rollup 不能识别的配置
72
+ return;
73
+ }
69
74
  if (!outputItem.plugins) {
70
75
  outputItem.plugins = [terser()];
71
76
  } else {
@@ -74,7 +79,7 @@ module.exports = function (config, envConfig, _rollupConfig, _consoleTag) {
74
79
  });
75
80
  } else if (compress && isObject(curRollupConfig.output)) {
76
81
  if (!curRollupConfig.plugins) {
77
- curRollupConfig.output.plugins = [terser()];
82
+ curRollupConfig.plugins = [terser()];
78
83
  } else {
79
84
  curRollupConfig.plugins.push(terser());
80
85
  }
@@ -142,7 +142,8 @@ module.exports = function (curConfig, curEnvConfig) {
142
142
  output: [
143
143
  {
144
144
  file: resolveToCurrentDist(`${curFileName}.${buildFormat}.js`, curEnvConfig.outDir),
145
- format: buildFormat
145
+ format: buildFormat,
146
+ notCompressed: true // 不压缩代码
146
147
  },
147
148
  {
148
149
  file: resolveToCurrentDist(`${curFileName}.${buildFormat}.min.js`, curEnvConfig.outDir),
@@ -39,6 +39,9 @@ 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
45
  // 判断是否有自定义 Babel plugins
43
46
  if (isArray(curWebpackConfig.babelPlugins)) {
44
47
  // 添加自定义babel插件