@modern-js/app-tools 2.22.0 → 2.22.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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 2.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 664f414: fix(app-tools): should not delete internalDir because we need guarantee the dev, build command correct.
8
+ fix(app-tools): 不应该在非构建模式下删除 internalDir,因为我们需要保证这些构建模式的入口是正确的
9
+ - Updated dependencies [25b490a]
10
+ - Updated dependencies [e2848a2]
11
+ - Updated dependencies [a470c04]
12
+ - Updated dependencies [95ffa6b]
13
+ - Updated dependencies [12d54ae]
14
+ - Updated dependencies [bd4b150]
15
+ - Updated dependencies [c739207]
16
+ - Updated dependencies [c465db6]
17
+ - Updated dependencies [dd36311]
18
+ - Updated dependencies [d4045ed]
19
+ - Updated dependencies [8bd9981]
20
+ - Updated dependencies [1f02cd2]
21
+ - Updated dependencies [cfcf003]
22
+ - Updated dependencies [15181be]
23
+ - @modern-js/types@2.22.1
24
+ - @modern-js/utils@2.22.1
25
+ - @modern-js/builder-webpack-provider@2.22.1
26
+ - @modern-js/builder-rspack-provider@2.22.1
27
+ - @modern-js/builder-shared@2.22.1
28
+ - @modern-js/builder@2.22.1
29
+ - @modern-js/server@2.22.1
30
+ - @modern-js/prod-server@2.22.1
31
+ - @modern-js/core@2.22.1
32
+ - @modern-js/plugin-data-loader@2.22.1
33
+ - @modern-js/builder-plugin-esbuild@2.22.1
34
+ - @modern-js/builder-plugin-node-polyfill@2.22.1
35
+ - @modern-js/plugin-i18n@2.22.1
36
+ - @modern-js/plugin-lint@2.22.1
37
+ - @modern-js/new-action@2.22.1
38
+ - @modern-js/node-bundle-require@2.22.1
39
+ - @modern-js/plugin@2.22.1
40
+ - @modern-js/upgrade@2.22.1
41
+
3
42
  ## 2.22.0
4
43
 
5
44
  ### Minor Changes
@@ -36,7 +36,9 @@ const _default = ({ bundler }) => {
36
36
  const resolvedConfig = api.useResolvedConfigContext();
37
37
  const hookRunners = api.useHookRunners();
38
38
  try {
39
- _utils.fs.emptydirSync(appContext.internalDirectory);
39
+ if ((0, _utils1.checkIsBuildCommands)()) {
40
+ _utils.fs.emptydirSync(appContext.internalDirectory);
41
+ }
40
42
  } catch {
41
43
  }
42
44
  const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir);
@@ -101,15 +103,7 @@ const _default = ({ bundler }) => {
101
103
  htmlTemplates
102
104
  };
103
105
  api.setAppContext(appContext);
104
- const command = (0, _utils.getCommand)();
105
- const buildCommands = [
106
- "dev",
107
- "start",
108
- "build",
109
- "inspect",
110
- "deploy"
111
- ];
112
- if (buildCommands.includes(command)) {
106
+ if ((0, _utils1.checkIsBuildCommands)()) {
113
107
  const normalizedConfig = api.useResolvedConfigContext();
114
108
  const createBuilderForModern = await (0, _builder.createBuilderGenerator)(bundler);
115
109
  const builder = await createBuilderForModern({
@@ -33,6 +33,9 @@ _export(exports, {
33
33
  },
34
34
  getServerCombinedModueFile: function() {
35
35
  return getServerCombinedModueFile;
36
+ },
37
+ checkIsBuildCommands: function() {
38
+ return checkIsBuildCommands;
36
39
  }
37
40
  });
38
41
  const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
@@ -175,3 +178,14 @@ const getServerLoadersFile = (internalDirectory, entryName) => {
175
178
  const getServerCombinedModueFile = (internalDirectory, entryName) => {
176
179
  return _path.default.join(internalDirectory, entryName, "server-loader-combined.js");
177
180
  };
181
+ const checkIsBuildCommands = () => {
182
+ const buildCommands = [
183
+ "dev",
184
+ "start",
185
+ "build",
186
+ "inspect",
187
+ "deploy"
188
+ ];
189
+ const command = (0, _utils.getCommand)();
190
+ return buildCommands.includes(command);
191
+ };
@@ -4,7 +4,7 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
4
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
5
5
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
6
  import * as path from "path";
7
- import { createDebugger, findExists, fs, isApiOnly, minimist, getCommand, isDevCommand, getArgv } from "@modern-js/utils";
7
+ import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
8
8
  import { cloneDeep } from "@modern-js/utils/lodash";
9
9
  import { printInstructions } from "../utils/printInstructions";
10
10
  import { generateRoutes } from "../utils/routes";
@@ -12,7 +12,7 @@ import { emitResolvedConfig } from "../utils/config";
12
12
  import { getSelectedEntries } from "../utils/getSelectedEntries";
13
13
  import { initialNormalizedConfig } from "../config";
14
14
  import { createBuilderGenerator } from "../builder";
15
- import { isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
15
+ import { checkIsBuildCommands, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
16
16
  import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
17
17
  import { generateIndexCode } from "./generateCode";
18
18
  var debug = createDebugger("plugin-analyze");
@@ -27,7 +27,7 @@ export default function(param) {
27
27
  return {
28
28
  prepare: function prepare() {
29
29
  return _async_to_generator(function() {
30
- var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes1, importsStatemets, htmlTemplates, checkedEntries, entry, command, buildCommands, normalizedConfig, createBuilderForModern, builder;
30
+ var _resolvedConfig_source, appContext, resolvedConfig, hookRunners, apiOnly, routes, _ref, getBundleEntry, getServerRoutes, generateCode, getHtmlTemplate, entrypoints, initialRoutes, routes1, importsStatemets, htmlTemplates, checkedEntries, entry, normalizedConfig, createBuilderForModern, builder;
31
31
  return _ts_generator(this, function(_state) {
32
32
  switch (_state.label) {
33
33
  case 0:
@@ -35,7 +35,9 @@ export default function(param) {
35
35
  resolvedConfig = api.useResolvedConfigContext();
36
36
  hookRunners = api.useHookRunners();
37
37
  try {
38
- fs.emptydirSync(appContext.internalDirectory);
38
+ if (checkIsBuildCommands()) {
39
+ fs.emptydirSync(appContext.internalDirectory);
40
+ }
39
41
  } catch (e) {
40
42
  }
41
43
  return [
@@ -164,15 +166,7 @@ export default function(param) {
164
166
  htmlTemplates: htmlTemplates
165
167
  });
166
168
  api.setAppContext(appContext);
167
- command = getCommand();
168
- buildCommands = [
169
- "dev",
170
- "start",
171
- "build",
172
- "inspect",
173
- "deploy"
174
- ];
175
- if (!buildCommands.includes(command))
169
+ if (!checkIsBuildCommands())
176
170
  return [
177
171
  3,
178
172
  14
@@ -4,7 +4,7 @@ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
5
  import fs from "fs";
6
6
  import path from "path";
7
- import { isReact18, normalizeToPosixPath, fs as fse } from "@modern-js/utils";
7
+ import { isReact18, normalizeToPosixPath, fs as fse, getCommand } from "@modern-js/utils";
8
8
  import { transform } from "esbuild";
9
9
  import { parse } from "es-module-lexer";
10
10
  import { FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME } from "./constants";
@@ -201,3 +201,14 @@ export var getServerLoadersFile = function(internalDirectory, entryName) {
201
201
  export var getServerCombinedModueFile = function(internalDirectory, entryName) {
202
202
  return path.join(internalDirectory, entryName, "server-loader-combined.js");
203
203
  };
204
+ export var checkIsBuildCommands = function() {
205
+ var buildCommands = [
206
+ "dev",
207
+ "start",
208
+ "build",
209
+ "inspect",
210
+ "deploy"
211
+ ];
212
+ var command = getCommand();
213
+ return buildCommands.includes(command);
214
+ };
@@ -1,5 +1,5 @@
1
1
  import * as path from "path";
2
- import { createDebugger, findExists, fs, isApiOnly, minimist, getCommand, isDevCommand, getArgv } from "@modern-js/utils";
2
+ import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
3
3
  import { cloneDeep } from "@modern-js/utils/lodash";
4
4
  import { printInstructions } from "../utils/printInstructions";
5
5
  import { generateRoutes } from "../utils/routes";
@@ -7,7 +7,7 @@ import { emitResolvedConfig } from "../utils/config";
7
7
  import { getSelectedEntries } from "../utils/getSelectedEntries";
8
8
  import { initialNormalizedConfig } from "../config";
9
9
  import { createBuilderGenerator } from "../builder";
10
- import { isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
10
+ import { checkIsBuildCommands, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
11
11
  import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
12
12
  import { generateIndexCode } from "./generateCode";
13
13
  const debug = createDebugger("plugin-analyze");
@@ -25,7 +25,9 @@ export default ({ bundler }) => {
25
25
  const resolvedConfig = api.useResolvedConfigContext();
26
26
  const hookRunners = api.useHookRunners();
27
27
  try {
28
- fs.emptydirSync(appContext.internalDirectory);
28
+ if (checkIsBuildCommands()) {
29
+ fs.emptydirSync(appContext.internalDirectory);
30
+ }
29
31
  } catch {
30
32
  }
31
33
  const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir);
@@ -90,15 +92,7 @@ export default ({ bundler }) => {
90
92
  htmlTemplates
91
93
  };
92
94
  api.setAppContext(appContext);
93
- const command = getCommand();
94
- const buildCommands = [
95
- "dev",
96
- "start",
97
- "build",
98
- "inspect",
99
- "deploy"
100
- ];
101
- if (buildCommands.includes(command)) {
95
+ if (checkIsBuildCommands()) {
102
96
  const normalizedConfig = api.useResolvedConfigContext();
103
97
  const createBuilderForModern = await createBuilderGenerator(bundler);
104
98
  const builder = await createBuilderForModern({
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { isReact18, normalizeToPosixPath, fs as fse } from "@modern-js/utils";
3
+ import { isReact18, normalizeToPosixPath, fs as fse, getCommand } from "@modern-js/utils";
4
4
  import { transform } from "esbuild";
5
5
  import { parse } from "es-module-lexer";
6
6
  import { FILE_SYSTEM_ROUTES_FILE_NAME, JS_EXTENSIONS, LOADER_EXPORT_NAME } from "./constants";
@@ -137,3 +137,14 @@ export const getServerLoadersFile = (internalDirectory, entryName) => {
137
137
  export const getServerCombinedModueFile = (internalDirectory, entryName) => {
138
138
  return path.join(internalDirectory, entryName, "server-loader-combined.js");
139
139
  };
140
+ export const checkIsBuildCommands = () => {
141
+ const buildCommands = [
142
+ "dev",
143
+ "start",
144
+ "build",
145
+ "inspect",
146
+ "deploy"
147
+ ];
148
+ const command = getCommand();
149
+ return buildCommands.includes(command);
150
+ };
@@ -25,4 +25,5 @@ export declare const parseModule: ({
25
25
  }) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
26
26
  export declare const hasLoader: (filename: string) => Promise<boolean>;
27
27
  export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
28
- export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
28
+ export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
29
+ export declare const checkIsBuildCommands: () => boolean;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.22.0",
18
+ "version": "2.22.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -73,23 +73,23 @@
73
73
  "esbuild": "0.15.7",
74
74
  "rspack-plugin-virtual-module": "0.1.0",
75
75
  "@swc/helpers": "0.5.1",
76
- "@modern-js/builder": "2.22.0",
77
- "@modern-js/builder-plugin-esbuild": "2.22.0",
78
- "@modern-js/builder-plugin-node-polyfill": "2.22.0",
79
- "@modern-js/builder-shared": "2.22.0",
80
- "@modern-js/builder-webpack-provider": "2.22.0",
81
- "@modern-js/core": "2.22.0",
82
- "@modern-js/new-action": "2.22.0",
83
- "@modern-js/node-bundle-require": "2.22.0",
84
- "@modern-js/plugin": "2.22.0",
85
- "@modern-js/plugin-data-loader": "2.22.0",
86
- "@modern-js/plugin-i18n": "2.22.0",
87
- "@modern-js/plugin-lint": "2.22.0",
88
- "@modern-js/prod-server": "2.22.0",
89
- "@modern-js/server": "2.22.0",
90
- "@modern-js/types": "2.22.0",
91
- "@modern-js/upgrade": "2.22.0",
92
- "@modern-js/utils": "2.22.0"
76
+ "@modern-js/builder": "2.22.1",
77
+ "@modern-js/builder-plugin-esbuild": "2.22.1",
78
+ "@modern-js/builder-plugin-node-polyfill": "2.22.1",
79
+ "@modern-js/builder-shared": "2.22.1",
80
+ "@modern-js/builder-webpack-provider": "2.22.1",
81
+ "@modern-js/core": "2.22.1",
82
+ "@modern-js/new-action": "2.22.1",
83
+ "@modern-js/node-bundle-require": "2.22.1",
84
+ "@modern-js/plugin": "2.22.1",
85
+ "@modern-js/plugin-data-loader": "2.22.1",
86
+ "@modern-js/plugin-i18n": "2.22.1",
87
+ "@modern-js/plugin-lint": "2.22.1",
88
+ "@modern-js/prod-server": "2.22.1",
89
+ "@modern-js/server": "2.22.1",
90
+ "@modern-js/types": "2.22.1",
91
+ "@modern-js/upgrade": "2.22.1",
92
+ "@modern-js/utils": "2.22.1"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/babel__traverse": "^7.14.2",
@@ -98,14 +98,14 @@
98
98
  "jest": "^29",
99
99
  "typescript": "^5",
100
100
  "webpack": "^5.82.1",
101
- "@modern-js/builder-rspack-provider": "2.22.0",
102
- "@scripts/jest-config": "2.22.0",
103
- "@modern-js/server-core": "2.22.0",
104
- "@scripts/build": "2.22.0",
105
- "@modern-js/builder-plugin-swc": "2.22.0"
101
+ "@modern-js/builder-plugin-swc": "2.22.1",
102
+ "@modern-js/builder-rspack-provider": "2.22.1",
103
+ "@modern-js/server-core": "2.22.1",
104
+ "@scripts/build": "2.22.1",
105
+ "@scripts/jest-config": "2.22.1"
106
106
  },
107
107
  "peerDependencies": {
108
- "@modern-js/builder-rspack-provider": "^2.22.0"
108
+ "@modern-js/builder-rspack-provider": "^2.22.1"
109
109
  },
110
110
  "peerDependenciesMeta": {
111
111
  "@modern-js/builder-rspack-provider": {