@modern-js/app-tools 2.43.1-alpha.3 → 2.44.0
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/cjs/analyze/templates.js +6 -5
- package/dist/cjs/plugins/serverBuild.js +8 -0
- package/dist/esm/analyze/templates.js +6 -5
- package/dist/esm/plugins/serverBuild.js +10 -0
- package/dist/esm-node/analyze/templates.js +6 -5
- package/dist/esm-node/plugins/serverBuild.js +8 -0
- package/package.json +25 -25
@@ -275,12 +275,13 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
|
|
275
275
|
lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
276
276
|
component = `lazy(${lazyImport})`;
|
277
277
|
}
|
278
|
-
} else if (ssrMode === "string") {
|
279
|
-
components.push(route._component);
|
280
|
-
component = `component_${components.length - 1}`;
|
281
278
|
} else {
|
282
|
-
|
283
|
-
|
279
|
+
lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
280
|
+
if (ssrMode === "string") {
|
281
|
+
component = `loadable(${lazyImport})`;
|
282
|
+
} else {
|
283
|
+
component = `lazy(${lazyImport})`;
|
284
|
+
}
|
284
285
|
}
|
285
286
|
}
|
286
287
|
} else if (route._component) {
|
@@ -36,12 +36,20 @@ var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utils = require("@modern-js/utils");
|
37
37
|
var import_server_utils = require("@modern-js/server-utils");
|
38
38
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
39
|
+
function checkHasCache(appDir) {
|
40
|
+
const tsFilepath = import_path.default.resolve(appDir, "server", "cache.ts");
|
41
|
+
const jsfilepath = import_path.default.resolve(appDir, "server", "cache.js");
|
42
|
+
return import_fs.default.existsSync(tsFilepath) || import_fs.default.existsSync(jsfilepath);
|
43
|
+
}
|
39
44
|
var serverBuild_default = () => ({
|
40
45
|
name: "@modern-js/server-build",
|
41
46
|
setup(api) {
|
42
47
|
return {
|
43
48
|
async afterBuild() {
|
44
49
|
const { appDirectory, distDirectory } = api.useAppContext();
|
50
|
+
if (!checkHasCache(appDirectory)) {
|
51
|
+
return;
|
52
|
+
}
|
45
53
|
const modernConfig = api.useResolvedConfigContext();
|
46
54
|
const distDir = import_path.default.resolve(distDirectory);
|
47
55
|
const serverDir = import_path.default.resolve(appDirectory, import_utils.SERVER_DIR);
|
@@ -220,12 +220,13 @@ var fileSystemRoutes = function() {
|
|
220
220
|
lazyImport = '() => import(/* webpackChunkName: "'.concat(route2.id, `" */ '`).concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
|
221
221
|
component2 = "lazy(".concat(lazyImport, ")");
|
222
222
|
}
|
223
|
-
} else if (ssrMode === "string") {
|
224
|
-
components.push(route2._component);
|
225
|
-
component2 = "component_".concat(components.length - 1);
|
226
223
|
} else {
|
227
|
-
|
228
|
-
|
224
|
+
lazyImport = `() => import(/* webpackMode: "eager" */ '`.concat(route2._component, `').then(routeModule => handleRouteModule(routeModule, "`).concat(route2.id, '")).catch(handleRouteModuleError) ');
|
225
|
+
if (ssrMode === "string") {
|
226
|
+
component2 = "loadable(".concat(lazyImport, ")");
|
227
|
+
} else {
|
228
|
+
component2 = "lazy(".concat(lazyImport, ")");
|
229
|
+
}
|
229
230
|
}
|
230
231
|
}
|
231
232
|
} else if (route2._component) {
|
@@ -5,6 +5,11 @@ import fs from "fs";
|
|
5
5
|
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
6
6
|
import { compile } from "@modern-js/server-utils";
|
7
7
|
var TS_CONFIG_FILENAME = "tsconfig.json";
|
8
|
+
function checkHasCache(appDir) {
|
9
|
+
var tsFilepath = path.resolve(appDir, "server", "cache.ts");
|
10
|
+
var jsfilepath = path.resolve(appDir, "server", "cache.js");
|
11
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
12
|
+
}
|
8
13
|
function serverBuild_default() {
|
9
14
|
return {
|
10
15
|
name: "@modern-js/server-build",
|
@@ -17,6 +22,11 @@ function serverBuild_default() {
|
|
17
22
|
switch (_state.label) {
|
18
23
|
case 0:
|
19
24
|
_api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, distDirectory = _api_useAppContext.distDirectory;
|
25
|
+
if (!checkHasCache(appDirectory)) {
|
26
|
+
return [
|
27
|
+
2
|
28
|
+
];
|
29
|
+
}
|
20
30
|
modernConfig = api.useResolvedConfigContext();
|
21
31
|
distDir = path.resolve(distDirectory);
|
22
32
|
serverDir = path.resolve(appDirectory, SERVER_DIR);
|
@@ -237,12 +237,13 @@ const fileSystemRoutes = async ({ routes, ssrMode, nestedRoutesEntry, entryName,
|
|
237
237
|
lazyImport = `() => import(/* webpackChunkName: "${route.id}" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
238
238
|
component = `lazy(${lazyImport})`;
|
239
239
|
}
|
240
|
-
} else if (ssrMode === "string") {
|
241
|
-
components.push(route._component);
|
242
|
-
component = `component_${components.length - 1}`;
|
243
240
|
} else {
|
244
|
-
|
245
|
-
|
241
|
+
lazyImport = `() => import(/* webpackMode: "eager" */ '${route._component}').then(routeModule => handleRouteModule(routeModule, "${route.id}")).catch(handleRouteModuleError) `;
|
242
|
+
if (ssrMode === "string") {
|
243
|
+
component = `loadable(${lazyImport})`;
|
244
|
+
} else {
|
245
|
+
component = `lazy(${lazyImport})`;
|
246
|
+
}
|
246
247
|
}
|
247
248
|
}
|
248
249
|
} else if (route._component) {
|
@@ -3,12 +3,20 @@ import fs from "fs";
|
|
3
3
|
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
4
4
|
import { compile } from "@modern-js/server-utils";
|
5
5
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
6
|
+
function checkHasCache(appDir) {
|
7
|
+
const tsFilepath = path.resolve(appDir, "server", "cache.ts");
|
8
|
+
const jsfilepath = path.resolve(appDir, "server", "cache.js");
|
9
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
10
|
+
}
|
6
11
|
var serverBuild_default = () => ({
|
7
12
|
name: "@modern-js/server-build",
|
8
13
|
setup(api) {
|
9
14
|
return {
|
10
15
|
async afterBuild() {
|
11
16
|
const { appDirectory, distDirectory } = api.useAppContext();
|
17
|
+
if (!checkHasCache(appDirectory)) {
|
18
|
+
return;
|
19
|
+
}
|
12
20
|
const modernConfig = api.useResolvedConfigContext();
|
13
21
|
const distDir = path.resolve(distDirectory);
|
14
22
|
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.44.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -72,25 +72,25 @@
|
|
72
72
|
"es-module-lexer": "^1.1.0",
|
73
73
|
"esbuild": "0.17.19",
|
74
74
|
"@swc/helpers": "0.5.3",
|
75
|
-
"@modern-js/builder": "2.
|
76
|
-
"@modern-js/builder-
|
77
|
-
"@modern-js/builder-
|
78
|
-
"@modern-js/
|
79
|
-
"@modern-js/
|
80
|
-
"@modern-js/
|
81
|
-
"@modern-js/builder
|
82
|
-
"@modern-js/
|
83
|
-
"@modern-js/plugin
|
84
|
-
"@modern-js/
|
85
|
-
"@modern-js/
|
86
|
-
"@modern-js/plugin-lint": "2.
|
87
|
-
"@modern-js/server": "2.
|
88
|
-
"@modern-js/
|
89
|
-
"@modern-js/server-utils": "2.
|
90
|
-
"@modern-js/
|
91
|
-
"@modern-js/
|
92
|
-
"@modern-js/server-core": "2.
|
93
|
-
"@modern-js/
|
75
|
+
"@modern-js/builder-plugin-esbuild": "2.44.0",
|
76
|
+
"@modern-js/builder-plugin-node-polyfill": "2.44.0",
|
77
|
+
"@modern-js/builder-shared": "2.44.0",
|
78
|
+
"@modern-js/builder-webpack-provider": "2.44.0",
|
79
|
+
"@modern-js/core": "2.44.0",
|
80
|
+
"@modern-js/node-bundle-require": "2.44.0",
|
81
|
+
"@modern-js/builder": "2.44.0",
|
82
|
+
"@modern-js/new-action": "2.44.0",
|
83
|
+
"@modern-js/plugin": "2.44.0",
|
84
|
+
"@modern-js/plugin-i18n": "2.44.0",
|
85
|
+
"@modern-js/plugin-data-loader": "2.44.0",
|
86
|
+
"@modern-js/plugin-lint": "2.44.0",
|
87
|
+
"@modern-js/prod-server": "2.44.0",
|
88
|
+
"@modern-js/server": "2.44.0",
|
89
|
+
"@modern-js/server-utils": "2.44.0",
|
90
|
+
"@modern-js/types": "2.44.0",
|
91
|
+
"@modern-js/upgrade": "2.44.0",
|
92
|
+
"@modern-js/server-core": "2.44.0",
|
93
|
+
"@modern-js/utils": "2.44.0"
|
94
94
|
},
|
95
95
|
"devDependencies": {
|
96
96
|
"@types/babel__traverse": "7.18.5",
|
@@ -99,13 +99,13 @@
|
|
99
99
|
"jest": "^29",
|
100
100
|
"typescript": "^5",
|
101
101
|
"webpack": "^5.89.0",
|
102
|
-
"@
|
103
|
-
"@
|
104
|
-
"@modern-js/builder-plugin-swc": "2.
|
105
|
-
"@scripts/jest-config": "2.
|
102
|
+
"@modern-js/builder-rspack-provider": "2.44.0",
|
103
|
+
"@scripts/build": "2.44.0",
|
104
|
+
"@modern-js/builder-plugin-swc": "2.44.0",
|
105
|
+
"@scripts/jest-config": "2.44.0"
|
106
106
|
},
|
107
107
|
"peerDependencies": {
|
108
|
-
"@modern-js/builder-rspack-provider": "^2.
|
108
|
+
"@modern-js/builder-rspack-provider": "^2.44.0"
|
109
109
|
},
|
110
110
|
"peerDependenciesMeta": {
|
111
111
|
"@modern-js/builder-rspack-provider": {
|