@modern-js/app-tools 2.15.0 → 2.16.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/CHANGELOG.md +45 -0
- package/dist/cjs/analyze/constants.js +37 -61
- package/dist/cjs/analyze/generateCode.js +102 -127
- package/dist/cjs/analyze/getBundleEntry.js +33 -66
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
- package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
- package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
- package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
- package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
- package/dist/cjs/analyze/getServerRoutes.js +67 -110
- package/dist/cjs/analyze/index.js +265 -257
- package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
- package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
- package/dist/cjs/analyze/nestedRoutes.js +99 -104
- package/dist/cjs/analyze/templates.js +49 -110
- package/dist/cjs/analyze/utils.js +98 -102
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
- package/dist/cjs/builder/builder-rspack/index.js +14 -30
- package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
- package/dist/cjs/builder/builder-webpack/index.js +65 -46
- package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
- package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
- package/dist/cjs/builder/generator/index.js +61 -55
- package/dist/cjs/builder/index.js +53 -43
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
- package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
- package/dist/cjs/builder/shared/index.js +20 -19
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
- package/dist/cjs/builder/shared/types.js +4 -15
- package/dist/cjs/commands/build.js +23 -40
- package/dist/cjs/commands/deploy.js +7 -25
- package/dist/cjs/commands/dev.js +38 -57
- package/dist/cjs/commands/index.js +20 -19
- package/dist/cjs/commands/inspect.js +10 -30
- package/dist/cjs/commands/serve.js +28 -66
- package/dist/cjs/config/default.js +34 -34
- package/dist/cjs/config/index.js +20 -19
- package/dist/cjs/config/initialize/index.js +11 -29
- package/dist/cjs/config/initialize/inits.js +103 -82
- package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
- package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
- package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
- package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
- package/dist/cjs/config/legacy/index.js +22 -46
- package/dist/cjs/defineConfig.js +16 -31
- package/dist/cjs/exports/server.js +7 -25
- package/dist/cjs/hooks.js +33 -51
- package/dist/cjs/index.js +185 -166
- package/dist/cjs/initialize/index.js +84 -100
- package/dist/cjs/locale/en.js +13 -27
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +13 -27
- package/dist/cjs/schema/Schema.js +27 -31
- package/dist/cjs/schema/index.js +141 -71
- package/dist/cjs/schema/legacy.js +273 -96
- package/dist/cjs/types/config/deploy.js +4 -15
- package/dist/cjs/types/config/dev.js +4 -15
- package/dist/cjs/types/config/experiments.js +4 -15
- package/dist/cjs/types/config/html.js +4 -15
- package/dist/cjs/types/config/index.js +18 -17
- package/dist/cjs/types/config/output.js +4 -15
- package/dist/cjs/types/config/performance.js +4 -15
- package/dist/cjs/types/config/security.js +4 -15
- package/dist/cjs/types/config/source.js +4 -15
- package/dist/cjs/types/config/tools.js +4 -15
- package/dist/cjs/types/hooks.js +4 -15
- package/dist/cjs/types/index.js +20 -19
- package/dist/cjs/types/legacyConfig/deploy.js +4 -15
- package/dist/cjs/types/legacyConfig/dev.js +4 -15
- package/dist/cjs/types/legacyConfig/index.js +4 -15
- package/dist/cjs/types/legacyConfig/output.js +4 -15
- package/dist/cjs/types/legacyConfig/source.js +4 -15
- package/dist/cjs/types/legacyConfig/tools.js +4 -15
- package/dist/cjs/types/utils.js +4 -15
- package/dist/cjs/utils/config.js +74 -79
- package/dist/cjs/utils/createServer.js +16 -42
- package/dist/cjs/utils/env.js +7 -25
- package/dist/cjs/utils/generateWatchFiles.js +31 -52
- package/dist/cjs/utils/getSelectedEntries.js +13 -35
- package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
- package/dist/cjs/utils/printInstructions.js +10 -28
- package/dist/cjs/utils/restart.js +13 -31
- package/dist/cjs/utils/routes.js +18 -39
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/analyze/constants.js +40 -41
- package/dist/esm/analyze/generateCode.js +477 -455
- package/dist/esm/analyze/getBundleEntry.js +53 -54
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
- package/dist/esm/analyze/getClientRoutes/index.js +2 -3
- package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
- package/dist/esm/analyze/getFileSystemEntry.js +86 -87
- package/dist/esm/analyze/getHtmlTemplate.js +289 -278
- package/dist/esm/analyze/getServerRoutes.js +203 -190
- package/dist/esm/analyze/index.js +679 -651
- package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
- package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
- package/dist/esm/analyze/nestedRoutes.js +400 -392
- package/dist/esm/analyze/templates.js +536 -509
- package/dist/esm/analyze/utils.js +357 -336
- package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
- package/dist/esm/builder/builder-rspack/index.js +8 -9
- package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
- package/dist/esm/builder/builder-webpack/index.js +266 -249
- package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
- package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
- package/dist/esm/builder/generator/index.js +203 -196
- package/dist/esm/builder/index.js +183 -176
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
- package/dist/esm/builder/shared/createCopyInfo.js +9 -10
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
- package/dist/esm/builder/shared/types.js +1 -1
- package/dist/esm/commands/build.js +279 -272
- package/dist/esm/commands/deploy.js +150 -144
- package/dist/esm/commands/dev.js +296 -289
- package/dist/esm/commands/inspect.js +144 -138
- package/dist/esm/commands/serve.js +241 -235
- package/dist/esm/config/default.js +202 -203
- package/dist/esm/config/initialize/index.js +7 -8
- package/dist/esm/config/initialize/inits.js +189 -181
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
- package/dist/esm/config/legacy/createOutputConfig.js +41 -42
- package/dist/esm/config/legacy/createSourceConfig.js +38 -39
- package/dist/esm/config/legacy/createToolsConfig.js +24 -25
- package/dist/esm/config/legacy/index.js +31 -32
- package/dist/esm/defineConfig.js +52 -53
- package/dist/esm/exports/server.js +1 -2
- package/dist/esm/hooks.js +26 -27
- package/dist/esm/index.js +685 -671
- package/dist/esm/initialize/index.js +276 -269
- package/dist/esm/locale/en.js +36 -37
- package/dist/esm/locale/index.js +2 -2
- package/dist/esm/locale/zh.js +36 -37
- package/dist/esm/schema/Schema.js +255 -244
- package/dist/esm/schema/index.js +165 -165
- package/dist/esm/schema/legacy.js +316 -317
- package/dist/esm/types/config/deploy.js +1 -1
- package/dist/esm/types/config/dev.js +1 -1
- package/dist/esm/types/config/experiments.js +1 -1
- package/dist/esm/types/config/html.js +1 -1
- package/dist/esm/types/config/output.js +1 -1
- package/dist/esm/types/config/performance.js +1 -1
- package/dist/esm/types/config/security.js +1 -1
- package/dist/esm/types/config/source.js +1 -1
- package/dist/esm/types/config/tools.js +1 -1
- package/dist/esm/types/hooks.js +1 -1
- package/dist/esm/types/legacyConfig/deploy.js +1 -1
- package/dist/esm/types/legacyConfig/dev.js +1 -1
- package/dist/esm/types/legacyConfig/index.js +1 -1
- package/dist/esm/types/legacyConfig/output.js +1 -1
- package/dist/esm/types/legacyConfig/source.js +1 -1
- package/dist/esm/types/legacyConfig/tools.js +1 -1
- package/dist/esm/types/utils.js +1 -1
- package/dist/esm/utils/config.js +285 -278
- package/dist/esm/utils/createServer.js +242 -234
- package/dist/esm/utils/env.js +11 -12
- package/dist/esm/utils/generateWatchFiles.js +205 -190
- package/dist/esm/utils/getSelectedEntries.js +180 -173
- package/dist/esm/utils/getServerInternalPlugins.js +197 -191
- package/dist/esm/utils/printInstructions.js +147 -141
- package/dist/esm/utils/restart.js +179 -173
- package/dist/esm/utils/routes.js +146 -139
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm-node/analyze/constants.js +31 -46
- package/dist/esm-node/analyze/generateCode.js +28 -94
- package/dist/esm-node/analyze/getBundleEntry.js +8 -27
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
- package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
- package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
- package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
- package/dist/esm-node/analyze/getServerRoutes.js +43 -75
- package/dist/esm-node/analyze/index.js +208 -230
- package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
- package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
- package/dist/esm-node/analyze/nestedRoutes.js +23 -43
- package/dist/esm-node/analyze/templates.js +22 -69
- package/dist/esm-node/analyze/utils.js +66 -60
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
- package/dist/esm-node/builder/builder-rspack/index.js +4 -5
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
- package/dist/esm-node/builder/builder-webpack/index.js +13 -11
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
- package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
- package/dist/esm-node/builder/generator/index.js +7 -16
- package/dist/esm-node/builder/index.js +2 -7
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
- package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
- package/dist/esm-node/builder/shared/types.js +1 -0
- package/dist/esm-node/commands/build.js +7 -9
- package/dist/esm-node/commands/deploy.js +1 -4
- package/dist/esm-node/commands/dev.js +19 -27
- package/dist/esm-node/commands/inspect.js +3 -8
- package/dist/esm-node/commands/serve.js +7 -25
- package/dist/esm-node/config/default.js +20 -11
- package/dist/esm-node/config/initialize/index.js +1 -4
- package/dist/esm-node/config/initialize/inits.js +48 -54
- package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
- package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
- package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
- package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
- package/dist/esm-node/config/legacy/index.js +3 -18
- package/dist/esm-node/defineConfig.js +7 -13
- package/dist/esm-node/exports/server.js +1 -4
- package/dist/esm-node/hooks.js +2 -9
- package/dist/esm-node/index.js +95 -120
- package/dist/esm-node/initialize/index.js +74 -87
- package/dist/esm-node/locale/en.js +7 -6
- package/dist/esm-node/locale/index.js +5 -5
- package/dist/esm-node/locale/zh.js +7 -6
- package/dist/esm-node/schema/Schema.js +19 -8
- package/dist/esm-node/schema/index.js +121 -36
- package/dist/esm-node/schema/legacy.js +262 -72
- package/dist/esm-node/types/config/deploy.js +1 -0
- package/dist/esm-node/types/config/dev.js +1 -0
- package/dist/esm-node/types/config/experiments.js +1 -0
- package/dist/esm-node/types/config/html.js +1 -0
- package/dist/esm-node/types/config/output.js +1 -0
- package/dist/esm-node/types/config/performance.js +1 -0
- package/dist/esm-node/types/config/security.js +1 -0
- package/dist/esm-node/types/config/source.js +1 -0
- package/dist/esm-node/types/config/tools.js +1 -0
- package/dist/esm-node/types/hooks.js +1 -0
- package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
- package/dist/esm-node/types/legacyConfig/dev.js +1 -0
- package/dist/esm-node/types/legacyConfig/index.js +1 -0
- package/dist/esm-node/types/legacyConfig/output.js +1 -0
- package/dist/esm-node/types/legacyConfig/source.js +1 -0
- package/dist/esm-node/types/legacyConfig/tools.js +1 -0
- package/dist/esm-node/types/utils.js +1 -0
- package/dist/esm-node/utils/config.js +16 -47
- package/dist/esm-node/utils/createServer.js +5 -12
- package/dist/esm-node/utils/env.js +1 -4
- package/dist/esm-node/utils/generateWatchFiles.js +13 -20
- package/dist/esm-node/utils/getSelectedEntries.js +2 -9
- package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
- package/dist/esm-node/utils/printInstructions.js +1 -4
- package/dist/esm-node/utils/restart.js +2 -11
- package/dist/esm-node/utils/routes.js +4 -4
- package/dist/esm-node/utils/types.js +1 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +29 -25
|
@@ -1,276 +1,284 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var analyze_exports = {};
|
|
29
|
-
__export(analyze_exports, {
|
|
30
|
-
default: () => analyze_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _default
|
|
8
|
+
});
|
|
9
|
+
const _path = /* @__PURE__ */ _interop_require_wildcard(require("path"));
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _lodash = require("@modern-js/utils/lodash");
|
|
12
|
+
const _printInstructions = require("../utils/printInstructions");
|
|
13
|
+
const _routes = require("../utils/routes");
|
|
14
|
+
const _config = require("../utils/config");
|
|
15
|
+
const _getSelectedEntries = require("../utils/getSelectedEntries");
|
|
16
|
+
const _config1 = require("../config");
|
|
17
|
+
const _builder = require("../builder");
|
|
18
|
+
const _utils1 = require("./utils");
|
|
19
|
+
const _constants = require("./constants");
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function")
|
|
22
|
+
return null;
|
|
23
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
26
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
27
|
+
})(nodeInterop);
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
30
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
53
34
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
35
|
+
default: obj
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
39
|
+
if (cache && cache.has(obj)) {
|
|
40
|
+
return cache.get(obj);
|
|
41
|
+
}
|
|
42
|
+
var newObj = {};
|
|
43
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for (var key in obj) {
|
|
45
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
46
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
47
|
+
if (desc && (desc.get || desc.set)) {
|
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
|
49
|
+
} else {
|
|
50
|
+
newObj[key] = obj[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
newObj.default = obj;
|
|
55
|
+
if (cache) {
|
|
56
|
+
cache.set(obj, newObj);
|
|
57
|
+
}
|
|
58
|
+
return newObj;
|
|
59
|
+
}
|
|
60
|
+
const debug = (0, _utils.createDebugger)("plugin-analyze");
|
|
61
|
+
const _default = ({ bundler }) => {
|
|
62
|
+
return {
|
|
63
|
+
name: "@modern-js/plugin-analyze",
|
|
64
|
+
setup: (api) => {
|
|
65
|
+
let pagesDir = [];
|
|
66
|
+
let nestedRouteEntries = [];
|
|
67
|
+
let originEntrypoints = [];
|
|
68
|
+
return {
|
|
69
|
+
async prepare() {
|
|
70
|
+
var _resolvedConfig_source;
|
|
71
|
+
let appContext = api.useAppContext();
|
|
72
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
73
|
+
const hookRunners = api.useHookRunners();
|
|
74
|
+
try {
|
|
75
|
+
_utils.fs.emptydirSync(appContext.internalDirectory);
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir);
|
|
79
|
+
await hookRunners.addRuntimeExports();
|
|
80
|
+
if (apiOnly) {
|
|
81
|
+
const { routes: routes2 } = await hookRunners.modifyServerRoutes({
|
|
82
|
+
routes: []
|
|
83
|
+
});
|
|
84
|
+
debug(`server routes: %o`, routes2);
|
|
85
|
+
appContext = {
|
|
86
|
+
...appContext,
|
|
87
|
+
apiOnly,
|
|
88
|
+
serverRoutes: routes2
|
|
89
|
+
};
|
|
90
|
+
api.setAppContext(appContext);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const [{ getBundleEntry }, { getServerRoutes }, { generateCode }, { getHtmlTemplate }] = await Promise.all([
|
|
94
|
+
Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("./getBundleEntry"))),
|
|
95
|
+
Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("./getServerRoutes"))),
|
|
96
|
+
Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("./generateCode"))),
|
|
97
|
+
Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("./getHtmlTemplate")))
|
|
98
|
+
]);
|
|
99
|
+
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
100
|
+
debug(`entrypoints: %o`, entrypoints);
|
|
101
|
+
const initialRoutes = getServerRoutes(entrypoints, {
|
|
102
|
+
appContext,
|
|
103
|
+
config: resolvedConfig
|
|
104
|
+
});
|
|
105
|
+
const { routes } = await hookRunners.modifyServerRoutes({
|
|
106
|
+
routes: initialRoutes
|
|
71
107
|
});
|
|
72
|
-
debug(`server routes: %o`,
|
|
108
|
+
debug(`server routes: %o`, routes);
|
|
73
109
|
appContext = {
|
|
74
110
|
...appContext,
|
|
75
|
-
|
|
76
|
-
serverRoutes:
|
|
111
|
+
entrypoints,
|
|
112
|
+
serverRoutes: routes
|
|
77
113
|
};
|
|
78
114
|
api.setAppContext(appContext);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{ generateCode },
|
|
85
|
-
{ getHtmlTemplate }
|
|
86
|
-
] = await Promise.all([
|
|
87
|
-
Promise.resolve().then(() => __toESM(require("./getBundleEntry"))),
|
|
88
|
-
Promise.resolve().then(() => __toESM(require("./getServerRoutes"))),
|
|
89
|
-
Promise.resolve().then(() => __toESM(require("./generateCode"))),
|
|
90
|
-
Promise.resolve().then(() => __toESM(require("./getHtmlTemplate")))
|
|
91
|
-
]);
|
|
92
|
-
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
93
|
-
debug(`entrypoints: %o`, entrypoints);
|
|
94
|
-
const initialRoutes = getServerRoutes(entrypoints, {
|
|
95
|
-
appContext,
|
|
96
|
-
config: resolvedConfig
|
|
97
|
-
});
|
|
98
|
-
const { routes } = await hookRunners.modifyServerRoutes({
|
|
99
|
-
routes: initialRoutes
|
|
100
|
-
});
|
|
101
|
-
debug(`server routes: %o`, routes);
|
|
102
|
-
appContext = {
|
|
103
|
-
...appContext,
|
|
104
|
-
entrypoints,
|
|
105
|
-
serverRoutes: routes
|
|
106
|
-
};
|
|
107
|
-
api.setAppContext(appContext);
|
|
108
|
-
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
109
|
-
pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
110
|
-
originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
|
|
111
|
-
await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
112
|
-
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
113
|
-
appContext,
|
|
114
|
-
config: resolvedConfig
|
|
115
|
-
});
|
|
116
|
-
debug(`html templates: %o`, htmlTemplates);
|
|
117
|
-
await hookRunners.addDefineTypes();
|
|
118
|
-
debug(`add Define Types`);
|
|
119
|
-
let checkedEntries = entrypoints.map((point) => point.entryName);
|
|
120
|
-
if ((0, import_utils.isDevCommand)()) {
|
|
121
|
-
const { entry } = (0, import_utils.minimist)((0, import_utils.getArgv)());
|
|
122
|
-
checkedEntries = await (0, import_getSelectedEntries.getSelectedEntries)(
|
|
123
|
-
typeof entry === "string" ? entry.split(",") : entry,
|
|
124
|
-
entrypoints
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
appContext = {
|
|
128
|
-
...appContext,
|
|
129
|
-
entrypoints,
|
|
130
|
-
checkedEntries,
|
|
131
|
-
apiOnly,
|
|
132
|
-
serverRoutes: routes,
|
|
133
|
-
htmlTemplates
|
|
134
|
-
};
|
|
135
|
-
api.setAppContext(appContext);
|
|
136
|
-
const command = (0, import_utils.getCommand)();
|
|
137
|
-
const buildCommands = ["dev", "start", "build", "inspect", "deploy"];
|
|
138
|
-
if (buildCommands.includes(command)) {
|
|
139
|
-
const normalizedConfig = api.useResolvedConfigContext();
|
|
140
|
-
const createBuilderForModern = await (0, import_builder.createBuilderGenerator)(bundler);
|
|
141
|
-
const builder = await createBuilderForModern({
|
|
142
|
-
normalizedConfig,
|
|
115
|
+
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
116
|
+
pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
117
|
+
originEntrypoints = (0, _lodash.cloneDeep)(entrypoints);
|
|
118
|
+
await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
119
|
+
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
143
120
|
appContext,
|
|
144
|
-
|
|
145
|
-
const hookRunners2 = api.useHookRunners();
|
|
146
|
-
await (0, import_routes.generateRoutes)(appContext);
|
|
147
|
-
await hookRunners2.beforeBuild({
|
|
148
|
-
bundlerConfigs
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
async onAfterBuild({ stats }) {
|
|
152
|
-
const hookRunners2 = api.useHookRunners();
|
|
153
|
-
await hookRunners2.afterBuild({ stats });
|
|
154
|
-
await (0, import_config.emitResolvedConfig)(
|
|
155
|
-
appContext.appDirectory,
|
|
156
|
-
normalizedConfig
|
|
157
|
-
);
|
|
158
|
-
},
|
|
159
|
-
async onDevCompileDone({ isFirstCompile }) {
|
|
160
|
-
const hookRunners2 = api.useHookRunners();
|
|
161
|
-
if (process.stdout.isTTY || isFirstCompile) {
|
|
162
|
-
hookRunners2.afterDev();
|
|
163
|
-
if (isFirstCompile) {
|
|
164
|
-
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
async onBeforeCreateCompiler({ bundlerConfigs }) {
|
|
169
|
-
const hookRunners2 = api.useHookRunners();
|
|
170
|
-
await hookRunners2.beforeCreateCompiler({
|
|
171
|
-
bundlerConfigs
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
async onAfterCreateCompiler({ compiler }) {
|
|
175
|
-
const hookRunners2 = api.useHookRunners();
|
|
176
|
-
await hookRunners2.afterCreateCompiler({
|
|
177
|
-
compiler
|
|
178
|
-
});
|
|
179
|
-
}
|
|
121
|
+
config: resolvedConfig
|
|
180
122
|
});
|
|
181
|
-
|
|
123
|
+
debug(`html templates: %o`, htmlTemplates);
|
|
124
|
+
await hookRunners.addDefineTypes();
|
|
125
|
+
debug(`add Define Types`);
|
|
126
|
+
let checkedEntries = entrypoints.map((point) => point.entryName);
|
|
127
|
+
if ((0, _utils.isDevCommand)()) {
|
|
128
|
+
const { entry } = (0, _utils.minimist)((0, _utils.getArgv)());
|
|
129
|
+
checkedEntries = await (0, _getSelectedEntries.getSelectedEntries)(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
|
|
130
|
+
}
|
|
182
131
|
appContext = {
|
|
183
132
|
...appContext,
|
|
184
|
-
|
|
133
|
+
entrypoints,
|
|
134
|
+
checkedEntries,
|
|
135
|
+
apiOnly,
|
|
136
|
+
serverRoutes: routes,
|
|
137
|
+
htmlTemplates
|
|
185
138
|
};
|
|
186
139
|
api.setAppContext(appContext);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
140
|
+
const command = (0, _utils.getCommand)();
|
|
141
|
+
const buildCommands = [
|
|
142
|
+
"dev",
|
|
143
|
+
"start",
|
|
144
|
+
"build",
|
|
145
|
+
"inspect",
|
|
146
|
+
"deploy"
|
|
147
|
+
];
|
|
148
|
+
if (buildCommands.includes(command)) {
|
|
149
|
+
const normalizedConfig = api.useResolvedConfigContext();
|
|
150
|
+
const createBuilderForModern = await (0, _builder.createBuilderGenerator)(bundler);
|
|
151
|
+
const builder = await createBuilderForModern({
|
|
152
|
+
normalizedConfig,
|
|
153
|
+
appContext,
|
|
154
|
+
async onBeforeBuild({ bundlerConfigs }) {
|
|
155
|
+
const hookRunners2 = api.useHookRunners();
|
|
156
|
+
await (0, _routes.generateRoutes)(appContext);
|
|
157
|
+
await hookRunners2.beforeBuild({
|
|
158
|
+
bundlerConfigs
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
async onAfterBuild({ stats }) {
|
|
162
|
+
const hookRunners2 = api.useHookRunners();
|
|
163
|
+
await hookRunners2.afterBuild({
|
|
164
|
+
stats
|
|
165
|
+
});
|
|
166
|
+
await (0, _config.emitResolvedConfig)(appContext.appDirectory, normalizedConfig);
|
|
167
|
+
},
|
|
168
|
+
async onDevCompileDone({ isFirstCompile }) {
|
|
169
|
+
const hookRunners2 = api.useHookRunners();
|
|
170
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
171
|
+
hookRunners2.afterDev();
|
|
172
|
+
if (isFirstCompile) {
|
|
173
|
+
(0, _printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
async onBeforeCreateCompiler({ bundlerConfigs }) {
|
|
178
|
+
const hookRunners2 = api.useHookRunners();
|
|
179
|
+
await hookRunners2.beforeCreateCompiler({
|
|
180
|
+
bundlerConfigs
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
async onAfterCreateCompiler({ compiler }) {
|
|
184
|
+
const hookRunners2 = api.useHookRunners();
|
|
185
|
+
await hookRunners2.afterCreateCompiler({
|
|
186
|
+
compiler
|
|
187
|
+
});
|
|
188
|
+
}
|
|
217
189
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
190
|
+
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
191
|
+
appContext = {
|
|
192
|
+
...appContext,
|
|
193
|
+
builder
|
|
194
|
+
};
|
|
195
|
+
api.setAppContext(appContext);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
watchFiles() {
|
|
199
|
+
return pagesDir;
|
|
200
|
+
},
|
|
201
|
+
resolvedConfig({ resolved }) {
|
|
202
|
+
const appContext = api.useAppContext();
|
|
203
|
+
const config = (0, _config1.initialNormalizedConfig)(resolved, appContext, bundler);
|
|
204
|
+
return {
|
|
205
|
+
resolved: config
|
|
206
|
+
};
|
|
207
|
+
},
|
|
208
|
+
// This logic is not in the router plugin to avoid having to include some dependencies in the utils package
|
|
209
|
+
async modifyEntryImports({ entrypoint, imports }) {
|
|
210
|
+
const appContext = api.useAppContext();
|
|
211
|
+
const { srcDirectory, internalSrcAlias } = appContext;
|
|
212
|
+
const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
|
|
213
|
+
if (fileSystemRoutes && nestedRoutesEntry) {
|
|
214
|
+
const rootLayoutPath = _path.join(nestedRoutesEntry, "layout");
|
|
215
|
+
const rootLayoutFile = (0, _utils.findExists)([
|
|
216
|
+
".js",
|
|
217
|
+
".ts",
|
|
218
|
+
".jsx",
|
|
219
|
+
".tsx"
|
|
220
|
+
].map((ext) => `${rootLayoutPath}${ext}`));
|
|
221
|
+
if (rootLayoutFile) {
|
|
222
|
+
const rootLayoutBuffer = await _utils.fs.readFile(rootLayoutFile);
|
|
223
|
+
const rootLayout = rootLayoutBuffer.toString();
|
|
224
|
+
const [, moduleExports] = await (0, _utils1.parseModule)({
|
|
225
|
+
source: rootLayout.toString(),
|
|
226
|
+
filename: rootLayoutFile
|
|
241
227
|
});
|
|
228
|
+
const hasAppConfig = moduleExports.some((e) => e.n === _constants.APP_CONFIG_NAME);
|
|
229
|
+
const generateLayoutPath = (0, _utils1.replaceWithAlias)(srcDirectory, rootLayoutFile, internalSrcAlias);
|
|
230
|
+
if (hasAppConfig) {
|
|
231
|
+
imports.push({
|
|
232
|
+
value: generateLayoutPath,
|
|
233
|
+
specifiers: [
|
|
234
|
+
{
|
|
235
|
+
imported: _constants.APP_CONFIG_NAME
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
const hasAppInit = moduleExports.some((e) => e.n === _constants.APP_INIT_EXPORTED);
|
|
241
|
+
if (hasAppInit) {
|
|
242
|
+
imports.push({
|
|
243
|
+
value: generateLayoutPath,
|
|
244
|
+
specifiers: [
|
|
245
|
+
{
|
|
246
|
+
imported: _constants.APP_INIT_EXPORTED,
|
|
247
|
+
local: _constants.APP_INIT_IMPORTED
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
});
|
|
251
|
+
}
|
|
242
252
|
}
|
|
243
253
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
return {
|
|
255
|
+
entrypoint,
|
|
256
|
+
imports
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
validateSchema() {
|
|
260
|
+
return {
|
|
261
|
+
target: "output.splitRouteChunks",
|
|
262
|
+
schema: {
|
|
263
|
+
type: "boolean"
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
async fileChange(e) {
|
|
268
|
+
const appContext = api.useAppContext();
|
|
269
|
+
const { appDirectory } = appContext;
|
|
270
|
+
const { filename, eventType } = e;
|
|
271
|
+
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
272
|
+
const absoluteFilePath = _path.resolve(appDirectory, filename);
|
|
273
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && (0, _utils1.isPageComponentFile)(absoluteFilePath);
|
|
274
|
+
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
275
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
276
|
+
const { generateCode } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard(require("./generateCode")));
|
|
277
|
+
const entrypoints = (0, _lodash.cloneDeep)(originEntrypoints);
|
|
278
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
255
279
|
}
|
|
256
|
-
};
|
|
257
|
-
},
|
|
258
|
-
async fileChange(e) {
|
|
259
|
-
const appContext = api.useAppContext();
|
|
260
|
-
const { appDirectory } = appContext;
|
|
261
|
-
const { filename, eventType } = e;
|
|
262
|
-
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
263
|
-
const absoluteFilePath = path.resolve(appDirectory, filename);
|
|
264
|
-
const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isPageComponentFile)(absoluteFilePath);
|
|
265
|
-
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
266
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
|
267
|
-
const { generateCode } = await Promise.resolve().then(() => __toESM(require("./generateCode")));
|
|
268
|
-
const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
|
|
269
|
-
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
270
280
|
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
276
|
-
0 && (module.exports = {});
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
};
|