@modern-js/app-tools 2.25.0 → 2.25.2

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,76 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 6651684: fix(app-tools): failed to print error stack
8
+
9
+ fix(app-tools): 修复 build 报错时未打印错误堆栈的问题
10
+
11
+ - ae723ab: fix: should not clean dist path if run deploy command but skip build
12
+ fix: 如果运行 deploy 命令,但是跳过构建阶段,不应该清理产物目录
13
+ - 272646c: feat(builder): bump webpack v5.88, support top level await
14
+
15
+ feat(builder): 升级 webpack v5.88, 支持 top level await
16
+
17
+ - Updated dependencies [63d8247]
18
+ - Updated dependencies [f54bb68]
19
+ - Updated dependencies [6651684]
20
+ - Updated dependencies [15a8276]
21
+ - Updated dependencies [272646c]
22
+ - Updated dependencies [358ed24]
23
+ - @modern-js/utils@2.25.2
24
+ - @modern-js/builder-rspack-provider@2.25.2
25
+ - @modern-js/builder-webpack-provider@2.25.2
26
+ - @modern-js/builder-shared@2.25.2
27
+ - @modern-js/plugin-data-loader@2.25.2
28
+ - @modern-js/server@2.25.2
29
+ - @modern-js/builder@2.25.2
30
+ - @modern-js/builder-plugin-esbuild@2.25.2
31
+ - @modern-js/builder-plugin-node-polyfill@2.25.2
32
+ - @modern-js/core@2.25.2
33
+ - @modern-js/plugin-i18n@2.25.2
34
+ - @modern-js/plugin-lint@2.25.2
35
+ - @modern-js/new-action@2.25.2
36
+ - @modern-js/prod-server@2.25.2
37
+ - @modern-js/node-bundle-require@2.25.2
38
+ - @modern-js/plugin@2.25.2
39
+ - @modern-js/upgrade@2.25.2
40
+ - @modern-js/types@2.25.2
41
+
42
+ ## 2.25.1
43
+
44
+ ### Patch Changes
45
+
46
+ - 322ac9e: fix: the router-plugin should update source-map
47
+ fix: router-plugin 应该更新 sourcemap
48
+ - 85366bc: chore(deps): bump esbuild from v15/v16 to v17
49
+
50
+ chore(deps): 将 esbuild 从 v15/v16 升级到 v17
51
+
52
+ - Updated dependencies [b10045f]
53
+ - Updated dependencies [9f78d0c]
54
+ - Updated dependencies [85366bc]
55
+ - @modern-js/builder@2.25.1
56
+ - @modern-js/builder-shared@2.25.1
57
+ - @modern-js/utils@2.25.1
58
+ - @modern-js/node-bundle-require@2.25.1
59
+ - @modern-js/builder-plugin-esbuild@2.25.1
60
+ - @modern-js/builder-plugin-node-polyfill@2.25.1
61
+ - @modern-js/builder-rspack-provider@2.25.1
62
+ - @modern-js/builder-webpack-provider@2.25.1
63
+ - @modern-js/core@2.25.1
64
+ - @modern-js/plugin-data-loader@2.25.1
65
+ - @modern-js/plugin-i18n@2.25.1
66
+ - @modern-js/plugin-lint@2.25.1
67
+ - @modern-js/new-action@2.25.1
68
+ - @modern-js/prod-server@2.25.1
69
+ - @modern-js/server@2.25.1
70
+ - @modern-js/plugin@2.25.1
71
+ - @modern-js/upgrade@2.25.1
72
+ - @modern-js/types@2.25.1
73
+
3
74
  ## 2.25.0
4
75
 
5
76
  ### Patch Changes
@@ -49,14 +49,9 @@ const build = async (api, options) => {
49
49
  distDirectory,
50
50
  configFile: serverConfigFile
51
51
  });
52
- try {
53
- _utils.logger.info("Create a production build...\n");
54
- if (!appContext.builder) {
55
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
56
- }
57
- await appContext.builder.build();
58
- } catch (error) {
59
- (0, _utils.printBuildError)(error);
60
- process.exit(1);
52
+ _utils.logger.info("Create a production build...\n");
53
+ if (!appContext.builder) {
54
+ throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
61
55
  }
56
+ await appContext.builder.build();
62
57
  };
@@ -33,11 +33,7 @@ const dev = async (api, options) => {
33
33
  appDirectory,
34
34
  distDirectory,
35
35
  configFile: serverConfigFile,
36
- options: {
37
- esbuildOptions: {
38
- watch: true
39
- }
40
- }
36
+ watch: true
41
37
  });
42
38
  await hookRunners.beforeDev();
43
39
  if (!appContext.builder && !apiOnly) {
package/dist/cjs/index.js CHANGED
@@ -166,6 +166,17 @@ const appTools = (options = {
166
166
  },
167
167
  async prepare() {
168
168
  const command = (0, _utils.getCommand)();
169
+ if (command === "deploy") {
170
+ const isSkipBuild = [
171
+ "-s",
172
+ "--skip-build"
173
+ ].some((tag) => {
174
+ return (0, _utils.getArgv)().includes(tag);
175
+ });
176
+ if (isSkipBuild) {
177
+ return;
178
+ }
179
+ }
169
180
  if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
170
181
  const resolvedConfig = api.useResolvedConfigContext();
171
182
  if (resolvedConfig.output.cleanDistPath) {
@@ -28,7 +28,7 @@ const _path = /* @__PURE__ */ _interop_require_wildcard._(require("path"));
28
28
  const _nodebundlerequire = require("@modern-js/node-bundle-require");
29
29
  const _utils = require("@modern-js/utils");
30
30
  const defineServerConfig = (config) => config;
31
- const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options }) => {
31
+ const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options, watch }) => {
32
32
  const configFilePath = await (0, _utils.getServerConfig)(appDirectory, configFile);
33
33
  const getOutputFile = async (filepath) => _path.resolve(distDirectory, `${filepath.replace(new RegExp(_utils.CONFIG_FILE_EXTENSIONS.join("|")), "")}.js`);
34
34
  if (configFilePath) {
@@ -40,6 +40,7 @@ const buildServerConfig = async ({ appDirectory, distDirectory, configFile, opti
40
40
  await _utils.fs.writeFile(configHelperFilePath, helperCode);
41
41
  await (0, _nodebundlerequire.bundle)(configFilePath, {
42
42
  ...options,
43
+ watch,
43
44
  getOutputFile,
44
45
  esbuildPlugins: [
45
46
  {
@@ -3,12 +3,12 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import { ResolvedConfigContext } from "@modern-js/core";
6
- import { logger, printBuildError } from "@modern-js/utils";
6
+ import { logger } from "@modern-js/utils";
7
7
  import { generateRoutes } from "../utils/routes";
8
8
  import { buildServerConfig } from "../utils/config";
9
9
  export var build = function() {
10
10
  var _ref = _async_to_generator(function(api, options) {
11
- var resolvedConfig, appContext, hookRunners, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1, error;
11
+ var resolvedConfig, appContext, hookRunners, apiOnly, appDirectory, distDirectory, serverConfigFile, distDirectory1, appDirectory1, serverConfigFile1;
12
12
  return _ts_generator(this, function(_state) {
13
13
  switch (_state.label) {
14
14
  case 0:
@@ -78,14 +78,6 @@ export var build = function() {
78
78
  ];
79
79
  case 6:
80
80
  _state.sent();
81
- _state.label = 7;
82
- case 7:
83
- _state.trys.push([
84
- 7,
85
- 9,
86
- ,
87
- 10
88
- ]);
89
81
  logger.info("Create a production build...\n");
90
82
  if (!appContext.builder) {
91
83
  throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
@@ -94,21 +86,8 @@ export var build = function() {
94
86
  4,
95
87
  appContext.builder.build()
96
88
  ];
97
- case 8:
89
+ case 7:
98
90
  _state.sent();
99
- return [
100
- 3,
101
- 10
102
- ];
103
- case 9:
104
- error = _state.sent();
105
- printBuildError(error);
106
- process.exit(1);
107
- return [
108
- 3,
109
- 10
110
- ];
111
- case 10:
112
91
  return [
113
92
  2
114
93
  ];
@@ -32,11 +32,7 @@ export var dev = function() {
32
32
  appDirectory: appDirectory,
33
33
  distDirectory: distDirectory,
34
34
  configFile: serverConfigFile,
35
- options: {
36
- esbuildOptions: {
37
- watch: true
38
- }
39
- }
35
+ watch: true
40
36
  })
41
37
  ];
42
38
  case 1:
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import path from "path";
6
6
  import { lintPlugin } from "@modern-js/plugin-lint";
7
- import { cleanRequireCache, emptyDir, Import, getCommand } from "@modern-js/utils";
7
+ import { cleanRequireCache, emptyDir, Import, getCommand, getArgv } from "@modern-js/utils";
8
8
  import { castArray } from "@modern-js/utils/lodash";
9
9
  import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
10
10
  import analyzePlugin from "./analyze";
@@ -474,11 +474,24 @@ export var appTools = function() {
474
474
  },
475
475
  prepare: function prepare() {
476
476
  return _async_to_generator(function() {
477
- var command, resolvedConfig, appContext2;
477
+ var command, isSkipBuild, resolvedConfig, appContext2;
478
478
  return _ts_generator(this, function(_state) {
479
479
  switch (_state.label) {
480
480
  case 0:
481
481
  command = getCommand();
482
+ if (command === "deploy") {
483
+ isSkipBuild = [
484
+ "-s",
485
+ "--skip-build"
486
+ ].some(function(tag) {
487
+ return getArgv().includes(tag);
488
+ });
489
+ if (isSkipBuild) {
490
+ return [
491
+ 2
492
+ ];
493
+ }
494
+ }
482
495
  if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
483
496
  return [
484
497
  3,
@@ -10,11 +10,11 @@ export var defineServerConfig = function(config) {
10
10
  };
11
11
  export var buildServerConfig = function() {
12
12
  var _ref = _async_to_generator(function(param) {
13
- var appDirectory, distDirectory, configFile, options, configFilePath, getOutputFile, configHelperFilePath, helperCode;
13
+ var appDirectory, distDirectory, configFile, options, watch, configFilePath, getOutputFile, configHelperFilePath, helperCode;
14
14
  return _ts_generator(this, function(_state) {
15
15
  switch (_state.label) {
16
16
  case 0:
17
- appDirectory = param.appDirectory, distDirectory = param.distDirectory, configFile = param.configFile, options = param.options;
17
+ appDirectory = param.appDirectory, distDirectory = param.distDirectory, configFile = param.configFile, options = param.options, watch = param.watch;
18
18
  return [
19
19
  4,
20
20
  getServerConfig(appDirectory, configFile)
@@ -56,6 +56,7 @@ export var buildServerConfig = function() {
56
56
  return [
57
57
  4,
58
58
  bundle(configFilePath, _object_spread_props(_object_spread({}, options), {
59
+ watch: watch,
59
60
  getOutputFile: getOutputFile,
60
61
  esbuildPlugins: [
61
62
  {
@@ -1,5 +1,5 @@
1
1
  import { ResolvedConfigContext } from "@modern-js/core";
2
- import { logger, printBuildError } from "@modern-js/utils";
2
+ import { logger } from "@modern-js/utils";
3
3
  import { generateRoutes } from "../utils/routes";
4
4
  import { buildServerConfig } from "../utils/config";
5
5
  export const build = async (api, options) => {
@@ -39,14 +39,9 @@ export const build = async (api, options) => {
39
39
  distDirectory,
40
40
  configFile: serverConfigFile
41
41
  });
42
- try {
43
- logger.info("Create a production build...\n");
44
- if (!appContext.builder) {
45
- throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
46
- }
47
- await appContext.builder.build();
48
- } catch (error) {
49
- printBuildError(error);
50
- process.exit(1);
42
+ logger.info("Create a production build...\n");
43
+ if (!appContext.builder) {
44
+ throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
51
45
  }
46
+ await appContext.builder.build();
52
47
  };
@@ -23,11 +23,7 @@ export const dev = async (api, options) => {
23
23
  appDirectory,
24
24
  distDirectory,
25
25
  configFile: serverConfigFile,
26
- options: {
27
- esbuildOptions: {
28
- watch: true
29
- }
30
- }
26
+ watch: true
31
27
  });
32
28
  await hookRunners.beforeDev();
33
29
  if (!appContext.builder && !apiOnly) {
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { lintPlugin } from "@modern-js/plugin-lint";
3
- import { cleanRequireCache, emptyDir, Import, getCommand } from "@modern-js/utils";
3
+ import { cleanRequireCache, emptyDir, Import, getCommand, getArgv } from "@modern-js/utils";
4
4
  import { castArray } from "@modern-js/utils/lodash";
5
5
  import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
6
6
  import analyzePlugin from "./analyze";
@@ -135,6 +135,17 @@ export const appTools = (options = {
135
135
  },
136
136
  async prepare() {
137
137
  const command = getCommand();
138
+ if (command === "deploy") {
139
+ const isSkipBuild = [
140
+ "-s",
141
+ "--skip-build"
142
+ ].some((tag) => {
143
+ return getArgv().includes(tag);
144
+ });
145
+ if (isSkipBuild) {
146
+ return;
147
+ }
148
+ }
138
149
  if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
139
150
  const resolvedConfig = api.useResolvedConfigContext();
140
151
  if (resolvedConfig.output.cleanDistPath) {
@@ -2,7 +2,7 @@ import * as path from "path";
2
2
  import { bundle } from "@modern-js/node-bundle-require";
3
3
  import { CONFIG_FILE_EXTENSIONS, fs, getServerConfig, OUTPUT_CONFIG_FILE } from "@modern-js/utils";
4
4
  export const defineServerConfig = (config) => config;
5
- export const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options }) => {
5
+ export const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options, watch }) => {
6
6
  const configFilePath = await getServerConfig(appDirectory, configFile);
7
7
  const getOutputFile = async (filepath) => path.resolve(distDirectory, `${filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join("|")), "")}.js`);
8
8
  if (configFilePath) {
@@ -14,6 +14,7 @@ export const buildServerConfig = async ({ appDirectory, distDirectory, configFil
14
14
  await fs.writeFile(configHelperFilePath, helperCode);
15
15
  await bundle(configFilePath, {
16
16
  ...options,
17
+ watch,
17
18
  getOutputFile,
18
19
  esbuildPlugins: [
19
20
  {
@@ -6,12 +6,14 @@ export declare const buildServerConfig: ({
6
6
  appDirectory,
7
7
  distDirectory,
8
8
  configFile,
9
- options
9
+ options,
10
+ watch
10
11
  }: {
11
12
  appDirectory: string;
12
13
  distDirectory: string;
13
14
  configFile: string;
14
15
  options?: Parameters<typeof bundle>[1];
16
+ watch?: boolean | undefined;
15
17
  }) => Promise<void>;
16
18
  /**
17
19
  *
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.25.0",
18
+ "version": "2.25.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -70,26 +70,26 @@
70
70
  "@babel/traverse": "^7.21.5",
71
71
  "@babel/types": "^7.21.5",
72
72
  "es-module-lexer": "^1.1.0",
73
- "esbuild": "0.15.7",
73
+ "esbuild": "0.17.19",
74
74
  "rspack-plugin-virtual-module": "0.1.0",
75
75
  "@swc/helpers": "0.5.1",
76
- "@modern-js/builder": "2.25.0",
77
- "@modern-js/builder-plugin-esbuild": "2.25.0",
78
- "@modern-js/builder-plugin-node-polyfill": "2.25.0",
79
- "@modern-js/builder-shared": "2.25.0",
80
- "@modern-js/builder-webpack-provider": "2.25.0",
81
- "@modern-js/core": "2.25.0",
82
- "@modern-js/new-action": "2.25.0",
83
- "@modern-js/node-bundle-require": "2.25.0",
84
- "@modern-js/plugin": "2.25.0",
85
- "@modern-js/plugin-data-loader": "2.25.0",
86
- "@modern-js/plugin-i18n": "2.25.0",
87
- "@modern-js/plugin-lint": "2.25.0",
88
- "@modern-js/prod-server": "2.25.0",
89
- "@modern-js/server": "2.25.0",
90
- "@modern-js/types": "2.25.0",
91
- "@modern-js/upgrade": "2.25.0",
92
- "@modern-js/utils": "2.25.0"
76
+ "@modern-js/builder": "2.25.2",
77
+ "@modern-js/builder-plugin-esbuild": "2.25.2",
78
+ "@modern-js/builder-plugin-node-polyfill": "2.25.2",
79
+ "@modern-js/builder-shared": "2.25.2",
80
+ "@modern-js/builder-webpack-provider": "2.25.2",
81
+ "@modern-js/core": "2.25.2",
82
+ "@modern-js/new-action": "2.25.2",
83
+ "@modern-js/node-bundle-require": "2.25.2",
84
+ "@modern-js/plugin": "2.25.2",
85
+ "@modern-js/plugin-data-loader": "2.25.2",
86
+ "@modern-js/plugin-i18n": "2.25.2",
87
+ "@modern-js/plugin-lint": "2.25.2",
88
+ "@modern-js/prod-server": "2.25.2",
89
+ "@modern-js/server": "2.25.2",
90
+ "@modern-js/types": "2.25.2",
91
+ "@modern-js/upgrade": "2.25.2",
92
+ "@modern-js/utils": "2.25.2"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/babel__traverse": "^7.14.2",
@@ -97,15 +97,15 @@
97
97
  "@types/node": "^14",
98
98
  "jest": "^29",
99
99
  "typescript": "^5",
100
- "webpack": "^5.82.1",
101
- "@modern-js/builder-plugin-swc": "2.25.0",
102
- "@modern-js/builder-rspack-provider": "2.25.0",
103
- "@modern-js/server-core": "2.25.0",
104
- "@scripts/build": "2.25.0",
105
- "@scripts/jest-config": "2.25.0"
100
+ "webpack": "^5.88.1",
101
+ "@modern-js/builder-plugin-swc": "2.25.2",
102
+ "@modern-js/builder-rspack-provider": "2.25.2",
103
+ "@modern-js/server-core": "2.25.2",
104
+ "@scripts/jest-config": "2.25.2",
105
+ "@scripts/build": "2.25.2"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/builder-rspack-provider": "^2.25.0"
108
+ "@modern-js/builder-rspack-provider": "^2.25.2"
109
109
  },
110
110
  "peerDependenciesMeta": {
111
111
  "@modern-js/builder-rspack-provider": {