@modern-js/app-tools 2.14.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 +74 -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/lib/types.d.ts +1 -0
- package/package.json +29 -25
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var dev_exports = {};
|
|
19
|
-
__export(dev_exports, {
|
|
20
|
-
dev: () => dev
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "dev", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => dev
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var import_getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
|
9
|
+
const _core = require("@modern-js/core");
|
|
10
|
+
const _utils = require("@modern-js/utils");
|
|
11
|
+
const _printInstructions = require("../utils/printInstructions");
|
|
12
|
+
const _createServer = require("../utils/createServer");
|
|
13
|
+
const _routes = require("../utils/routes");
|
|
14
|
+
const _config = require("../utils/config");
|
|
15
|
+
const _getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
|
30
16
|
const dev = async (api, options) => {
|
|
31
|
-
var
|
|
17
|
+
var _normalizedConfig_tools;
|
|
32
18
|
if (options.analyze) {
|
|
33
19
|
process.env.BUNDLE_ANALYZE = "true";
|
|
34
20
|
}
|
|
35
21
|
let normalizedConfig = api.useResolvedConfigContext();
|
|
36
22
|
const appContext = api.useAppContext();
|
|
37
23
|
const hookRunners = api.useHookRunners();
|
|
38
|
-
normalizedConfig = {
|
|
39
|
-
|
|
24
|
+
normalizedConfig = {
|
|
25
|
+
...normalizedConfig,
|
|
26
|
+
cliOptions: options
|
|
27
|
+
};
|
|
28
|
+
_core.ResolvedConfigContext.set(normalizedConfig);
|
|
40
29
|
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile } = appContext;
|
|
41
|
-
await (0,
|
|
30
|
+
await (0, _config.buildServerConfig)({
|
|
42
31
|
appDirectory,
|
|
43
32
|
distDirectory,
|
|
44
33
|
configFile: serverConfigFile,
|
|
@@ -50,18 +39,16 @@ const dev = async (api, options) => {
|
|
|
50
39
|
});
|
|
51
40
|
await hookRunners.beforeDev();
|
|
52
41
|
if (!appContext.builder && !apiOnly) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
55
|
-
);
|
|
42
|
+
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
|
56
43
|
}
|
|
57
|
-
await (0,
|
|
58
|
-
const serverInternalPlugins = await (0,
|
|
44
|
+
await (0, _routes.generateRoutes)(appContext);
|
|
45
|
+
const serverInternalPlugins = await (0, _getServerInternalPlugins.getServerInternalPlugins)(api);
|
|
59
46
|
const serverOptions = {
|
|
60
47
|
dev: {
|
|
61
48
|
port,
|
|
62
49
|
https: normalizedConfig.dev.https,
|
|
63
50
|
host: normalizedConfig.dev.host,
|
|
64
|
-
...(
|
|
51
|
+
...(_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer
|
|
65
52
|
},
|
|
66
53
|
appContext: {
|
|
67
54
|
appDirectory: appContext.appDirectory,
|
|
@@ -72,35 +59,29 @@ const dev = async (api, options) => {
|
|
|
72
59
|
pwd: appDirectory,
|
|
73
60
|
config: normalizedConfig,
|
|
74
61
|
serverConfigFile,
|
|
75
|
-
internalPlugins: (0,
|
|
62
|
+
internalPlugins: (0, _createServer.injectDataLoaderPlugin)(serverInternalPlugins)
|
|
76
63
|
};
|
|
77
64
|
if (apiOnly) {
|
|
78
|
-
|
|
65
|
+
var _normalizedConfig_dev;
|
|
66
|
+
const app = await (0, _createServer.createServer)({
|
|
79
67
|
...serverOptions,
|
|
80
68
|
compiler: null
|
|
81
69
|
});
|
|
82
|
-
const host = ((
|
|
83
|
-
app.listen(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (err) {
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
(0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
70
|
+
const host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || _utils.DEFAULT_DEV_HOST;
|
|
71
|
+
app.listen({
|
|
72
|
+
port,
|
|
73
|
+
host
|
|
74
|
+
}, async (err) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
throw err;
|
|
93
77
|
}
|
|
94
|
-
|
|
78
|
+
(0, _printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
79
|
+
});
|
|
95
80
|
} else {
|
|
96
81
|
const { server } = await appContext.builder.startDevServer({
|
|
97
82
|
printURLs: false,
|
|
98
83
|
serverOptions
|
|
99
84
|
});
|
|
100
|
-
(0,
|
|
85
|
+
(0, _createServer.setServer)(server);
|
|
101
86
|
}
|
|
102
87
|
};
|
|
103
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
-
0 && (module.exports = {
|
|
105
|
-
dev
|
|
106
|
-
});
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./dev"), exports);
|
|
6
|
+
_export_star(require("./build"), exports);
|
|
7
|
+
_export_star(require("./serve"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var inspect_exports = {};
|
|
19
|
-
__export(inspect_exports, {
|
|
20
|
-
inspect: () => inspect
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
21
4
|
});
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
Object.defineProperty(exports, "inspect", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => inspect
|
|
8
|
+
});
|
|
9
|
+
const _path = require("path");
|
|
24
10
|
const inspect = async (api, options) => {
|
|
25
11
|
const appContext = api.useAppContext();
|
|
26
12
|
if (!appContext.builder) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
29
|
-
);
|
|
13
|
+
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
|
30
14
|
}
|
|
31
15
|
return appContext.builder.inspectConfig({
|
|
32
16
|
env: options.env,
|
|
33
17
|
verbose: options.verbose,
|
|
34
|
-
outputPath: (0,
|
|
18
|
+
outputPath: (0, _path.join)(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
35
19
|
writeToDisk: true
|
|
36
20
|
});
|
|
37
21
|
};
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
inspect
|
|
41
|
-
});
|
|
@@ -1,91 +1,53 @@
|
|
|
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 serve_exports = {};
|
|
29
|
-
__export(serve_exports, {
|
|
30
|
-
start: () => start
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
Object.defineProperty(exports, "start", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => start
|
|
8
|
+
});
|
|
9
|
+
const _utils = require("@modern-js/utils");
|
|
10
|
+
const _prodserver = /* @__PURE__ */ _interop_require_default(require("@modern-js/prod-server"));
|
|
11
|
+
const _printInstructions = require("../utils/printInstructions");
|
|
12
|
+
const _createServer = require("../utils/createServer");
|
|
13
|
+
const _getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
38
19
|
const start = async (api) => {
|
|
39
|
-
var
|
|
20
|
+
var _userConfig_source, _userConfig_output_distPath;
|
|
40
21
|
const appContext = api.useAppContext();
|
|
41
22
|
const userConfig = api.useResolvedConfigContext();
|
|
42
23
|
const hookRunners = api.useHookRunners();
|
|
43
24
|
const { appDirectory, port, serverConfigFile } = appContext;
|
|
44
|
-
|
|
45
|
-
const apiOnly = await (0,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
);
|
|
49
|
-
const serverInternalPlugins = await (0, import_getServerInternalPlugins.getServerInternalPlugins)(api);
|
|
50
|
-
const app = await (0, import_prod_server.default)({
|
|
25
|
+
_utils.logger.log(_utils.chalk.cyan(`Starting the modern server...`));
|
|
26
|
+
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.entriesDir);
|
|
27
|
+
const serverInternalPlugins = await (0, _getServerInternalPlugins.getServerInternalPlugins)(api);
|
|
28
|
+
const app = await (0, _prodserver.default)({
|
|
51
29
|
pwd: appDirectory,
|
|
52
30
|
config: {
|
|
53
31
|
...userConfig,
|
|
54
32
|
dev: userConfig.dev,
|
|
55
33
|
output: {
|
|
56
|
-
path: (
|
|
34
|
+
path: (_userConfig_output_distPath = userConfig.output.distPath) === null || _userConfig_output_distPath === void 0 ? void 0 : _userConfig_output_distPath.root,
|
|
57
35
|
...userConfig.output || {}
|
|
58
36
|
}
|
|
59
37
|
},
|
|
60
38
|
appContext: {
|
|
61
|
-
sharedDirectory: (0,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
appContext.distDirectory
|
|
65
|
-
),
|
|
66
|
-
apiDirectory: (0, import_utils.getTargetDir)(
|
|
67
|
-
appContext.apiDirectory,
|
|
68
|
-
appContext.appDirectory,
|
|
69
|
-
appContext.distDirectory
|
|
70
|
-
),
|
|
71
|
-
lambdaDirectory: (0, import_utils.getTargetDir)(
|
|
72
|
-
appContext.lambdaDirectory,
|
|
73
|
-
appContext.appDirectory,
|
|
74
|
-
appContext.distDirectory
|
|
75
|
-
)
|
|
39
|
+
sharedDirectory: (0, _utils.getTargetDir)(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
|
|
40
|
+
apiDirectory: (0, _utils.getTargetDir)(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
|
|
41
|
+
lambdaDirectory: (0, _utils.getTargetDir)(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
|
|
76
42
|
},
|
|
77
43
|
serverConfigFile,
|
|
78
|
-
internalPlugins: (0,
|
|
44
|
+
internalPlugins: (0, _createServer.injectDataLoaderPlugin)(serverInternalPlugins),
|
|
79
45
|
apiOnly
|
|
80
46
|
});
|
|
81
47
|
app.listen(port, async (err) => {
|
|
82
48
|
if (err) {
|
|
83
49
|
throw err;
|
|
84
50
|
}
|
|
85
|
-
await (0,
|
|
51
|
+
await (0, _printInstructions.printInstructions)(hookRunners, appContext, userConfig);
|
|
86
52
|
});
|
|
87
53
|
};
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
start
|
|
91
|
-
});
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var default_exports = {};
|
|
19
|
-
__export(default_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
20
13
|
createDefaultConfig: () => createDefaultConfig,
|
|
21
14
|
createLegacyDefaultConfig: () => createLegacyDefaultConfig
|
|
22
15
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var import_env = require("../utils/env");
|
|
16
|
+
const _builderwebpackprovider = require("@modern-js/builder-webpack-provider");
|
|
17
|
+
const _env = require("../utils/env");
|
|
26
18
|
function createDefaultConfig(appContext, bundler) {
|
|
27
|
-
const defaultBuilderConfig = (0,
|
|
19
|
+
const defaultBuilderConfig = (0, _builderwebpackprovider.createDefaultConfig)();
|
|
28
20
|
const dev = {
|
|
29
21
|
...defaultBuilderConfig.dev,
|
|
30
22
|
// `dev.port` should not have a default value
|
|
@@ -42,7 +34,7 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
42
34
|
disableDefaultEntries: false,
|
|
43
35
|
entriesDir: "./src",
|
|
44
36
|
configDir: "./config",
|
|
45
|
-
globalVars: (0,
|
|
37
|
+
globalVars: (0, _env.getAutoInjectEnv)(appContext),
|
|
46
38
|
alias: {
|
|
47
39
|
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
48
40
|
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
@@ -54,9 +46,14 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
54
46
|
...defaultBuilderConfig.html,
|
|
55
47
|
title: "",
|
|
56
48
|
meta: {
|
|
57
|
-
charset: {
|
|
49
|
+
charset: {
|
|
50
|
+
charset: "utf-8"
|
|
51
|
+
},
|
|
58
52
|
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
|
59
|
-
"http-equiv": {
|
|
53
|
+
"http-equiv": {
|
|
54
|
+
"http-equiv": "x-ua-compatible",
|
|
55
|
+
content: "ie=edge"
|
|
56
|
+
},
|
|
60
57
|
renderer: "webkit",
|
|
61
58
|
layoutmode: "standard",
|
|
62
59
|
imagemode: "force",
|
|
@@ -103,7 +100,7 @@ function createLegacyDefaultConfig(appContext) {
|
|
|
103
100
|
configDir: "./config",
|
|
104
101
|
apiDir: "./api",
|
|
105
102
|
envVars: [],
|
|
106
|
-
globalVars: (0,
|
|
103
|
+
globalVars: (0, _env.getAutoInjectEnv)(appContext),
|
|
107
104
|
alias: defaultAlias,
|
|
108
105
|
moduleScopes: void 0,
|
|
109
106
|
include: []
|
|
@@ -118,9 +115,14 @@ function createLegacyDefaultConfig(appContext) {
|
|
|
118
115
|
title: "",
|
|
119
116
|
titleByEntries: void 0,
|
|
120
117
|
meta: {
|
|
121
|
-
charset: {
|
|
118
|
+
charset: {
|
|
119
|
+
charset: "utf-8"
|
|
120
|
+
},
|
|
122
121
|
viewport: "width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no",
|
|
123
|
-
"http-equiv": {
|
|
122
|
+
"http-equiv": {
|
|
123
|
+
"http-equiv": "x-ua-compatible",
|
|
124
|
+
content: "ie=edge"
|
|
125
|
+
},
|
|
124
126
|
renderer: "webkit",
|
|
125
127
|
layoutmode: "standard",
|
|
126
128
|
imagemode: "force",
|
|
@@ -161,7 +163,10 @@ function createLegacyDefaultConfig(appContext) {
|
|
|
161
163
|
baseUrl: "/",
|
|
162
164
|
port: 8080
|
|
163
165
|
};
|
|
164
|
-
const devDefaults = {
|
|
166
|
+
const devDefaults = {
|
|
167
|
+
assetPrefix: false,
|
|
168
|
+
https: false
|
|
169
|
+
};
|
|
165
170
|
const toolsDefaults = {
|
|
166
171
|
webpack: void 0,
|
|
167
172
|
babel: void 0,
|
|
@@ -183,8 +188,3 @@ function createLegacyDefaultConfig(appContext) {
|
|
|
183
188
|
runtimeByEntries: {}
|
|
184
189
|
};
|
|
185
190
|
}
|
|
186
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
-
0 && (module.exports = {
|
|
188
|
-
createDefaultConfig,
|
|
189
|
-
createLegacyDefaultConfig
|
|
190
|
-
});
|
package/dist/cjs/config/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./legacy"), exports);
|
|
6
|
+
_export_star(require("./initialize"), exports);
|
|
7
|
+
_export_star(require("./default"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
|
@@ -1,35 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var initialize_exports = {};
|
|
19
|
-
__export(initialize_exports, {
|
|
20
|
-
initialNormalizedConfig: () => initialNormalizedConfig
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "initialNormalizedConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => initialNormalizedConfig
|
|
21
8
|
});
|
|
22
|
-
|
|
23
|
-
var import_inits = require("./inits");
|
|
9
|
+
const _inits = require("./inits");
|
|
24
10
|
function initialNormalizedConfig(config, appContext, bundler) {
|
|
25
|
-
(0,
|
|
26
|
-
(0,
|
|
11
|
+
(0, _inits.initHtmlConfig)(config, appContext);
|
|
12
|
+
(0, _inits.initSourceConfig)(config, appContext, bundler);
|
|
27
13
|
if (bundler === "webpack") {
|
|
28
|
-
(0,
|
|
14
|
+
(0, _inits.initToolsConfig)(config);
|
|
29
15
|
}
|
|
30
16
|
return config;
|
|
31
17
|
}
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
initialNormalizedConfig
|
|
35
|
-
});
|