@qse/edu-scripts 2.1.0 → 2.1.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/dist/cli.mjs CHANGED
@@ -564,10 +564,10 @@ function getWebpackConfig(args, override) {
564
564
  ".json",
565
565
  ".wasm"
566
566
  ],
567
- tsConfig: {
567
+ tsConfig: fs.existsSync(paths.tsconfig) ? {
568
568
  configFile: paths.tsconfig,
569
569
  references: "auto"
570
- }
570
+ } : void 0
571
571
  },
572
572
  stats: false,
573
573
  devtool: isDev ? "cheap-module-source-map" : false,
@@ -1014,8 +1014,6 @@ function getConfig(args) {
1014
1014
 
1015
1015
  //#endregion
1016
1016
  //#region src/build.ts
1017
- const WARN_AFTER_BUNDLE_GZIP_SIZE = appConfig.single ? 1024 * 1024 : 30 * 1024;
1018
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
1019
1017
  async function build(args) {
1020
1018
  process.env.NODE_ENV = "production";
1021
1019
  process.env.BABEL_ENV = "production";
@@ -1027,7 +1025,8 @@ async function build(args) {
1027
1025
  fs.emptyDirSync(paths.dist);
1028
1026
  if (appConfig.single) fs.copySync(paths.public, paths.resolveApp("dist"));
1029
1027
  if (appConfig.mainProject && fs.existsSync(paths.static)) fs.copySync(paths.static, paths.resolveApp("dist", "static"));
1030
- rspack(getConfig(args), (error, stats) => {
1028
+ const config = getConfig(args);
1029
+ rspack(config, (error, stats) => {
1031
1030
  if (error) {
1032
1031
  console.log(chalk.red("编译失败"));
1033
1032
  console.log(chalk.red(error.message || error));
@@ -1043,7 +1042,15 @@ async function build(args) {
1043
1042
  }));
1044
1043
  process.exit(1);
1045
1044
  }
1046
- printFileSizesAfterBuild(stats, previousSizeMap, paths.dist, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
1045
+ const size = {
1046
+ maxEntrypointSize: 25e4,
1047
+ maxAssetSize: 25e4
1048
+ };
1049
+ if (typeof config.performance === "object") {
1050
+ config.performance.maxEntrypointSize = size.maxEntrypointSize;
1051
+ config.performance.maxAssetSize = size.maxAssetSize;
1052
+ }
1053
+ printFileSizesAfterBuild(stats, previousSizeMap, paths.dist, size.maxEntrypointSize, size.maxAssetSize);
1047
1054
  if (appConfig.single) console.log(`打包完成,可以使用 ${chalk.green("@qse/ssh-sftp")} 自动部署代码到 v1`);
1048
1055
  else console.log(`打包完成,可以运行 ${chalk.green("npx edu-scripts deploy")} 部署代码到 v1`);
1049
1056
  console.log();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qse/edu-scripts",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "教育工程化基础框架",
6
6
  "author": "Kinoko",
7
7
  "license": "MIT",
package/src/build.ts CHANGED
@@ -9,9 +9,6 @@ import appConfig from './utils/appConfig'
9
9
  import { measureFileSizesBeforeBuild, printFileSizesAfterBuild } from './utils/FileSizeReporter'
10
10
  import getConfig from './utils/getConfig'
11
11
 
12
- const WARN_AFTER_BUNDLE_GZIP_SIZE = appConfig.single ? 1024 * 1024 : 30 * 1024
13
- const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024
14
-
15
12
  interface BuildArgs {
16
13
  analyze?: boolean
17
14
  outputHtml?: boolean
@@ -55,12 +52,18 @@ export default async function build(args: BuildArgs) {
55
52
  process.exit(1)
56
53
  }
57
54
 
55
+ const size = { maxEntrypointSize: 250000, maxAssetSize: 250000 }
56
+ if (typeof config.performance === 'object') {
57
+ config.performance.maxEntrypointSize = size.maxEntrypointSize
58
+ config.performance.maxAssetSize = size.maxAssetSize
59
+ }
60
+
58
61
  printFileSizesAfterBuild(
59
62
  stats,
60
63
  previousSizeMap,
61
64
  paths.dist,
62
- WARN_AFTER_BUNDLE_GZIP_SIZE,
63
- WARN_AFTER_CHUNK_GZIP_SIZE
65
+ size.maxEntrypointSize,
66
+ size.maxAssetSize
64
67
  )
65
68
 
66
69
  if (appConfig.single) {
@@ -246,10 +246,9 @@ export default function getWebpackConfig(args: any, override: CustomConfiguratio
246
246
  ...override.alias,
247
247
  },
248
248
  extensions: ['.web.js', '.web.mjs', '.js', '.mjs', '.jsx', '.ts', '.tsx', '.json', '.wasm'],
249
- tsConfig: {
250
- configFile: paths.tsconfig,
251
- references: 'auto',
252
- },
249
+ tsConfig: fs.existsSync(paths.tsconfig)
250
+ ? { configFile: paths.tsconfig, references: 'auto' }
251
+ : undefined,
253
252
  },
254
253
  stats: false,
255
254
  devtool: isDev ? 'cheap-module-source-map' : false,