@qse/edu-scripts 1.14.13 → 1.14.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.14.15 (2025-08-15)
4
+
5
+ - feat: 增加 load chunk retry 功能
6
+
7
+ ## 1.14.14 (2025-07-17)
8
+
9
+ - fix: 将装饰器功能改成可配置项
10
+
3
11
  ## 1.14.13 (2025-07-11)
4
12
 
5
13
  - fix: 修复 pnpm build 时 @babel/runtime 解析不了
@@ -83,7 +83,6 @@ module.exports = function getBabelConfig(opts = {}) {
83
83
  // useESModules: true,
84
84
  }
85
85
  ],
86
- [require.resolve("@babel/plugin-proposal-decorators"), { version: "2023-11" }],
87
86
  [
88
87
  require.resolve("babel-plugin-import"),
89
88
  { libraryName: "lodash", libraryDirectory: "", camel2DashComponentName: false },
@@ -94,6 +93,13 @@ module.exports = function getBabelConfig(opts = {}) {
94
93
  ].filter(Boolean)
95
94
  };
96
95
  const override = getOverride();
96
+ if (override.decorators) {
97
+ config.presets[0][1].include = ["@babel/plugin-transform-class-properties"];
98
+ config.plugins.push([
99
+ require.resolve("@babel/plugin-proposal-decorators"),
100
+ { version: "legacy" }
101
+ ]);
102
+ }
97
103
  if (override.babel) {
98
104
  config = override.babel(config, "src") || config;
99
105
  }
@@ -33,6 +33,7 @@ var CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
33
33
  var appPkg = require(paths.package);
34
34
  var appConfig = require("../utils/appConfig");
35
35
  var { ESBuildMinifyPlugin } = require("esbuild-loader");
36
+ var { RetryChunkLoadPlugin } = require("webpack-retry-chunk-load-plugin");
36
37
  var once = require("lodash/once");
37
38
  var jsMainPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.name}` : `${appPkg.name}/${appPkg.name}`;
38
39
  var assetPath = appConfig.grayscale ? `${appPkg.name}/beta/${appPkg.version}` : `${appPkg.name}/${appPkg.version}`;
@@ -349,6 +350,11 @@ module.exports = function getWebpackConfig(args, override) {
349
350
  resourceRegExp: /^\.\/locale$/,
350
351
  contextRegExp: /moment$/
351
352
  }),
353
+ new RetryChunkLoadPlugin({
354
+ maxRetries: 3,
355
+ retryDelay: 300,
356
+ lastResortScript: `setTimeout(function() { window.location.reload(); }, 2000)`
357
+ }),
352
358
  new webpack.DefinePlugin({
353
359
  "process.env.APP_NAME": JSON.stringify(appPkg.name),
354
360
  "process.env.APP_VERSION": JSON.stringify(appPkg.version),
@@ -83,5 +83,11 @@ export type Config = {
83
83
  /** webpack compiler 自定义的时候会用到 */
84
84
  compiler: Compiler;
85
85
  }) => void;
86
+ /**
87
+ * 是否开启装饰器语法支持 只支持 legacy 版本
88
+ * @see https://babeljs.io/docs/en/babel-plugin-proposal-decorators
89
+ * @default false
90
+ */
91
+ decorators?: boolean;
86
92
  };
87
93
  export declare function defineConfig(config: Config): Config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qse/edu-scripts",
3
- "version": "1.14.13",
3
+ "version": "1.14.15",
4
4
  "author": "Kinoko",
5
5
  "license": "MIT",
6
6
  "description": "教育工程化基础框架",
@@ -43,7 +43,7 @@
43
43
  "@babel/register": "~7.25.9",
44
44
  "@babel/runtime": "~7.27.0",
45
45
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.16",
46
- "@qse/ssh-sftp": "^1.0.1",
46
+ "@qse/ssh-sftp": "^1.1.0",
47
47
  "@svgr/webpack": "^8.1.0",
48
48
  "@types/express": "^4.17.21",
49
49
  "babel-loader": "^9.2.1",
@@ -92,6 +92,7 @@
92
92
  "webpack": "^5.99.6",
93
93
  "webpack-bundle-analyzer": "^4.10.2",
94
94
  "webpack-dev-server": "^4.15.2",
95
+ "webpack-retry-chunk-load-plugin": "^3.1.1",
95
96
  "yargs": "^17.7.2"
96
97
  },
97
98
  "devDependencies": {
@@ -68,7 +68,6 @@ module.exports = function getBabelConfig(opts = {}) {
68
68
  // useESModules: true,
69
69
  },
70
70
  ],
71
- [require.resolve('@babel/plugin-proposal-decorators'), { version: '2023-11' }],
72
71
  [
73
72
  require.resolve('babel-plugin-import'),
74
73
  { libraryName: 'lodash', libraryDirectory: '', camel2DashComponentName: false },
@@ -80,6 +79,13 @@ module.exports = function getBabelConfig(opts = {}) {
80
79
  }
81
80
 
82
81
  const override = getOverride()
82
+ if (override.decorators) {
83
+ config.presets[0][1].include = ['@babel/plugin-transform-class-properties'] // Force include: always transform
84
+ config.plugins.push([
85
+ require.resolve('@babel/plugin-proposal-decorators'),
86
+ { version: 'legacy' },
87
+ ])
88
+ }
83
89
  if (override.babel) {
84
90
  config = override.babel(config, 'src') || config
85
91
  }
@@ -9,6 +9,7 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
9
9
  const appPkg = require(paths.package)
10
10
  const appConfig = require('../utils/appConfig')
11
11
  const { ESBuildMinifyPlugin } = require('esbuild-loader')
12
+ const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin')
12
13
  const once = require('lodash/once')
13
14
 
14
15
  const jsMainPath = appConfig.grayscale
@@ -348,6 +349,11 @@ module.exports = function getWebpackConfig(args, override) {
348
349
  resourceRegExp: /^\.\/locale$/,
349
350
  contextRegExp: /moment$/,
350
351
  }),
352
+ new RetryChunkLoadPlugin({
353
+ maxRetries: 3,
354
+ retryDelay: 300,
355
+ lastResortScript: `setTimeout(function() { window.location.reload(); }, 2000)`,
356
+ }),
351
357
  new webpack.DefinePlugin({
352
358
  'process.env.APP_NAME': JSON.stringify(appPkg.name),
353
359
  'process.env.APP_VERSION': JSON.stringify(appPkg.version),
@@ -85,6 +85,13 @@ export type Config = {
85
85
  /** webpack compiler 自定义的时候会用到 */
86
86
  compiler: Compiler
87
87
  }) => void
88
+
89
+ /**
90
+ * 是否开启装饰器语法支持 只支持 legacy 版本
91
+ * @see https://babeljs.io/docs/en/babel-plugin-proposal-decorators
92
+ * @default false
93
+ */
94
+ decorators?: boolean
88
95
  }
89
96
  export function defineConfig(config: Config) {
90
97
  return config