@modern-js/app-tools 2.5.0 → 2.5.1-alpha.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/generateCode.js +13 -19
- package/dist/cjs/analyze/getBundleEntry.js +1 -1
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
- package/dist/cjs/builder/builder-webpack/index.js +5 -11
- package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
- package/dist/cjs/commands/dev.js +14 -6
- package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm/analyze/generateCode.js +26 -37
- package/dist/esm/analyze/getBundleEntry.js +2 -2
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm/builder/builder-webpack/index.js +7 -11
- package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm/commands/dev.js +8 -3
- package/dist/esm/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/analyze/generateCode.js +14 -20
- package/dist/esm-node/analyze/getBundleEntry.js +3 -2
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +2 -2
- package/dist/esm-node/builder/builder-webpack/index.js +6 -12
- package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm-node/commands/dev.js +14 -6
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/js/modern/analyze/constants.js +54 -0
- package/dist/js/modern/analyze/generateCode.js +247 -0
- package/dist/js/modern/analyze/getBundleEntry.js +71 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
- package/dist/js/modern/analyze/getServerRoutes.js +175 -0
- package/dist/js/modern/analyze/index.js +332 -0
- package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
- package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/modern/analyze/nestedRoutes.js +157 -0
- package/dist/js/modern/analyze/templates.js +334 -0
- package/dist/js/modern/analyze/utils.js +141 -0
- package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
- package/dist/js/modern/builder/index.js +159 -0
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +46 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +30 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +113 -0
- package/dist/js/modern/commands/build.js +91 -0
- package/dist/js/modern/commands/deploy.js +28 -0
- package/dist/js/modern/commands/dev.js +109 -0
- package/dist/js/modern/commands/index.js +3 -0
- package/dist/js/modern/commands/inspect.js +38 -0
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +175 -0
- package/dist/js/modern/config/index.js +8 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/initial/createOutputConfig.js +68 -0
- package/dist/js/modern/config/initial/createSourceConfig.js +39 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +42 -0
- package/dist/js/modern/config/initial/index.js +16 -0
- package/dist/js/modern/config/initial/inits.js +152 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +47 -0
- package/dist/js/modern/defineConfig.js +27 -0
- package/dist/js/modern/exports/server.js +4 -0
- package/dist/js/modern/hooks.js +35 -0
- package/dist/js/modern/index.js +211 -0
- package/dist/js/modern/initialize/index.js +124 -0
- package/dist/js/modern/locale/en.js +36 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +36 -0
- package/dist/js/modern/schema/Schema.js +40 -0
- package/dist/js/modern/schema/index.js +88 -0
- package/dist/js/modern/schema/legacy.js +148 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +1 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +3 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +128 -0
- package/dist/js/modern/utils/createServer.js +75 -0
- package/dist/js/modern/utils/env.js +15 -0
- package/dist/js/modern/utils/generateWatchFiles.js +55 -0
- package/dist/js/modern/utils/getSelectedEntries.js +58 -0
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/language.js +8 -0
- package/dist/js/modern/utils/printInstructions.js +31 -0
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +30 -0
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +98 -0
- package/dist/js/node/analyze/generateCode.js +271 -0
- package/dist/js/node/analyze/getBundleEntry.js +95 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
- package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
- package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
- package/dist/js/node/analyze/getServerRoutes.js +194 -0
- package/dist/js/node/analyze/index.js +339 -0
- package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
- package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
- package/dist/js/node/analyze/nestedRoutes.js +184 -0
- package/dist/js/node/analyze/templates.js +365 -0
- package/dist/js/node/analyze/utils.js +172 -0
- package/dist/js/node/builder/builderPlugins/compatModern.js +258 -0
- package/dist/js/node/builder/index.js +177 -0
- package/dist/js/node/builder/loaders/routerLoader.js +38 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/share.js +75 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +53 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +60 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +135 -0
- package/dist/js/node/commands/build.js +112 -0
- package/dist/js/node/commands/deploy.js +51 -0
- package/dist/js/node/commands/dev.js +126 -0
- package/dist/js/node/commands/index.js +19 -0
- package/dist/js/node/commands/inspect.js +61 -0
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +197 -0
- package/dist/js/node/config/index.js +34 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +58 -0
- package/dist/js/node/config/initial/createOutputConfig.js +91 -0
- package/dist/js/node/config/initial/createSourceConfig.js +62 -0
- package/dist/js/node/config/initial/createToolsConfig.js +65 -0
- package/dist/js/node/config/initial/index.js +41 -0
- package/dist/js/node/config/initial/inits.js +175 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +70 -0
- package/dist/js/node/defineConfig.js +49 -0
- package/dist/js/node/exports/server.js +27 -0
- package/dist/js/node/hooks.js +54 -0
- package/dist/js/node/index.js +235 -0
- package/dist/js/node/initialize/index.js +134 -0
- package/dist/js/node/locale/en.js +59 -0
- package/dist/js/node/locale/index.js +33 -0
- package/dist/js/node/locale/zh.js +59 -0
- package/dist/js/node/schema/Schema.js +63 -0
- package/dist/js/node/schema/index.js +118 -0
- package/dist/js/node/schema/legacy.js +169 -0
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +17 -0
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +19 -0
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/utils/config.js +153 -0
- package/dist/js/node/utils/createServer.js +106 -0
- package/dist/js/node/utils/env.js +38 -0
- package/dist/js/node/utils/generateWatchFiles.js +85 -0
- package/dist/js/node/utils/getSelectedEntries.js +81 -0
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/language.js +31 -0
- package/dist/js/node/utils/printInstructions.js +54 -0
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +59 -0
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +40 -0
- package/dist/js/treeshaking/analyze/generateCode.js +485 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +222 -0
- package/dist/js/treeshaking/analyze/index.js +697 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +384 -0
- package/dist/js/treeshaking/analyze/templates.js +468 -0
- package/dist/js/treeshaking/analyze/utils.js +374 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +304 -0
- package/dist/js/treeshaking/builder/index.js +374 -0
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +40 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +72 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +343 -0
- package/dist/js/treeshaking/commands/build.js +291 -0
- package/dist/js/treeshaking/commands/deploy.js +154 -0
- package/dist/js/treeshaking/commands/dev.js +301 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +149 -0
- package/dist/js/treeshaking/commands/serve.js +199 -0
- package/dist/js/treeshaking/config/default.js +210 -0
- package/dist/js/treeshaking/config/index.js +3 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +42 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -0
- package/dist/js/treeshaking/config/initial/index.js +12 -0
- package/dist/js/treeshaking/config/initial/inits.js +209 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +35 -0
- package/dist/js/treeshaking/defineConfig.js +61 -0
- package/dist/js/treeshaking/exports/server.js +2 -0
- package/dist/js/treeshaking/hooks.js +29 -0
- package/dist/js/treeshaking/index.js +706 -0
- package/dist/js/treeshaking/initialize/index.js +276 -0
- package/dist/js/treeshaking/locale/en.js +38 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +38 -0
- package/dist/js/treeshaking/schema/Schema.js +273 -0
- package/dist/js/treeshaking/schema/index.js +181 -0
- package/dist/js/treeshaking/schema/legacy.js +337 -0
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +1 -0
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +3 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/env.js +13 -0
- package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
- package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/language.js +6 -0
- package/dist/js/treeshaking/utils/printInstructions.js +152 -0
- package/dist/js/treeshaking/utils/restart.js +187 -0
- package/dist/js/treeshaking/utils/routes.js +153 -0
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
- package/package.json +11 -11
|
@@ -83,7 +83,6 @@ ${initialize || ""}`
|
|
|
83
83
|
).join("\n");
|
|
84
84
|
};
|
|
85
85
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
86
|
-
var _a, _b, _c;
|
|
87
86
|
const {
|
|
88
87
|
internalDirectory,
|
|
89
88
|
srcDirectory,
|
|
@@ -92,7 +91,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
92
91
|
packageName
|
|
93
92
|
} = appContext;
|
|
94
93
|
const hookRunners = api.useHookRunners();
|
|
95
|
-
const isV5 =
|
|
94
|
+
const isV5 = (0, import_utils.isRouterV5)(config);
|
|
96
95
|
const { mountId } = config.html;
|
|
97
96
|
const getRoutes = isV5 ? import_getClientRoutes.getClientRoutesLegacy : import_getClientRoutes.getClientRoutes;
|
|
98
97
|
await Promise.all(entrypoints.map(generateEntryCode));
|
|
@@ -111,23 +110,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
111
110
|
internalDirAlias
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
|
-
if (entrypoint.nestedRoutesEntry) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
initialRoutes.unshift(nestedRoute);
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
import_utils.logger.error("Nested routes is not supported in legacy mode.");
|
|
130
|
-
process.exit(1);
|
|
113
|
+
if (!isV5 && entrypoint.nestedRoutesEntry) {
|
|
114
|
+
nestedRoute = await (0, import_nestedRoutes.walk)(
|
|
115
|
+
entrypoint.nestedRoutesEntry,
|
|
116
|
+
entrypoint.nestedRoutesEntry,
|
|
117
|
+
{
|
|
118
|
+
name: internalSrcAlias,
|
|
119
|
+
basename: srcDirectory
|
|
120
|
+
},
|
|
121
|
+
entrypoint.entryName
|
|
122
|
+
);
|
|
123
|
+
if (nestedRoute) {
|
|
124
|
+
initialRoutes.unshift(nestedRoute);
|
|
131
125
|
}
|
|
132
126
|
}
|
|
133
127
|
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
@@ -78,7 +78,7 @@ const getBundleEntry = (appContext, config) => {
|
|
|
78
78
|
customBootstrap: value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
|
|
79
79
|
fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
80
80
|
};
|
|
81
|
-
if (entrypoint.fileSystemRoutes) {
|
|
81
|
+
if (entrypoint.fileSystemRoutes && (0, import_utils.isRouterV5)(config)) {
|
|
82
82
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
83
83
|
}
|
|
84
84
|
if (!ifAlreadyExists(defaults, entrypoint)) {
|
|
@@ -17,13 +17,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var compatModern_exports = {};
|
|
19
19
|
__export(compatModern_exports, {
|
|
20
|
-
|
|
20
|
+
builderPluginCompatModern: () => builderPluginCompatModern
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(compatModern_exports);
|
|
23
23
|
var import_path = require("path");
|
|
24
24
|
var import_shared = require("../../shared");
|
|
25
25
|
var import_webpackPlugins = require("../webpackPlugins");
|
|
26
|
-
const
|
|
26
|
+
const builderPluginCompatModern = (options) => ({
|
|
27
27
|
name: "builder-plugin-compat-modern",
|
|
28
28
|
setup(api) {
|
|
29
29
|
const { normalizedConfig: modernConfig, appContext } = options;
|
|
@@ -60,5 +60,5 @@ const PluginCompatModern = (options) => ({
|
|
|
60
60
|
});
|
|
61
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
62
|
0 && (module.exports = {
|
|
63
|
-
|
|
63
|
+
builderPluginCompatModern
|
|
64
64
|
});
|
|
@@ -27,7 +27,6 @@ __export(builder_webpack_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(builder_webpack_exports);
|
|
29
29
|
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
|
30
|
-
var import_utils = require("@modern-js/utils");
|
|
31
30
|
var import_shared = require("../shared");
|
|
32
31
|
var import_generator = require("../generator");
|
|
33
32
|
var import_compatModern = require("./builderPlugins/compatModern");
|
|
@@ -57,20 +56,15 @@ function modifyOutputConfig(config, appContext) {
|
|
|
57
56
|
async function applyBuilderPlugins(builder, options) {
|
|
58
57
|
const { normalizedConfig } = options;
|
|
59
58
|
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
60
|
-
const {
|
|
61
|
-
builder.addPlugins([
|
|
59
|
+
const { builderPluginNodePolyfill } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
|
60
|
+
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
62
61
|
}
|
|
63
62
|
if (normalizedConfig.tools.esbuild) {
|
|
64
63
|
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
65
|
-
const {
|
|
66
|
-
builder.addPlugins([
|
|
67
|
-
PluginEsbuild({
|
|
68
|
-
loader: false,
|
|
69
|
-
minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
|
|
70
|
-
})
|
|
71
|
-
]);
|
|
64
|
+
const { builderPluginEsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
|
|
65
|
+
builder.addPlugins([builderPluginEsbuild(esbuildOptions)]);
|
|
72
66
|
}
|
|
73
|
-
builder.addPlugins([(0, import_compatModern.
|
|
67
|
+
builder.addPlugins([(0, import_compatModern.builderPluginCompatModern)(options)]);
|
|
74
68
|
}
|
|
75
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
70
|
0 && (module.exports = {
|
|
@@ -27,7 +27,7 @@ function getBuilderTargets(normalizedConfig) {
|
|
|
27
27
|
if (useNodeTarget) {
|
|
28
28
|
targets.push("node");
|
|
29
29
|
}
|
|
30
|
-
const useWorkerTarget = (0, import_utils.
|
|
30
|
+
const useWorkerTarget = (0, import_utils.isServiceWorker)(normalizedConfig);
|
|
31
31
|
if (useWorkerTarget) {
|
|
32
32
|
targets.push("service-worker");
|
|
33
33
|
}
|
package/dist/cjs/commands/dev.js
CHANGED
|
@@ -27,7 +27,7 @@ var import_routes = require("../utils/routes");
|
|
|
27
27
|
var import_config = require("../utils/config");
|
|
28
28
|
var import_getServerInternalPlugins = require("../utils/getServerInternalPlugins");
|
|
29
29
|
const dev = async (api, options) => {
|
|
30
|
-
var _a;
|
|
30
|
+
var _a, _b;
|
|
31
31
|
if (options.analyze) {
|
|
32
32
|
process.env.BUNDLE_ANALYZE = "true";
|
|
33
33
|
}
|
|
@@ -59,6 +59,7 @@ const dev = async (api, options) => {
|
|
|
59
59
|
dev: {
|
|
60
60
|
port,
|
|
61
61
|
https: normalizedConfig.dev.https,
|
|
62
|
+
host: normalizedConfig.dev.host,
|
|
62
63
|
...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
|
|
63
64
|
},
|
|
64
65
|
pwd: appDirectory,
|
|
@@ -71,12 +72,19 @@ const dev = async (api, options) => {
|
|
|
71
72
|
...serverOptions,
|
|
72
73
|
compiler: null
|
|
73
74
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const host = ((_b = normalizedConfig.dev) == null ? void 0 : _b.host) || "localhost";
|
|
76
|
+
app.listen(
|
|
77
|
+
{
|
|
78
|
+
port,
|
|
79
|
+
host
|
|
80
|
+
},
|
|
81
|
+
async (err) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
(0, import_printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
77
86
|
}
|
|
78
|
-
|
|
79
|
-
});
|
|
87
|
+
);
|
|
80
88
|
} else {
|
|
81
89
|
const { server } = await appContext.builder.startDevServer({
|
|
82
90
|
printURLs: false,
|
|
@@ -148,7 +148,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
import path from "path";
|
|
151
|
-
import { fs, getEntryOptions, logger } from "@modern-js/utils";
|
|
151
|
+
import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
|
|
152
152
|
import { useResolvedConfigContext } from "@modern-js/core";
|
|
153
153
|
import * as templates from "./templates";
|
|
154
154
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
@@ -240,7 +240,7 @@ var createImportStatements = function(statements) {
|
|
|
240
240
|
};
|
|
241
241
|
var generateCode = function() {
|
|
242
242
|
var _ref = _asyncToGenerator(function(appContext, config, entrypoints, api) {
|
|
243
|
-
var
|
|
243
|
+
var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, mountId, getRoutes;
|
|
244
244
|
function generateEntryCode(entrypoint) {
|
|
245
245
|
return _generateEntryCode.apply(this, arguments);
|
|
246
246
|
}
|
|
@@ -253,11 +253,11 @@ var generateCode = function() {
|
|
|
253
253
|
entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, customBootstrap = entrypoint.customBootstrap, fileSystemRoutes = entrypoint.fileSystemRoutes;
|
|
254
254
|
if (!isAutoMount) return [
|
|
255
255
|
3,
|
|
256
|
-
|
|
256
|
+
16
|
|
257
257
|
];
|
|
258
258
|
if (!fileSystemRoutes) return [
|
|
259
259
|
3,
|
|
260
|
-
|
|
260
|
+
9
|
|
261
261
|
];
|
|
262
262
|
initialRoutes = [];
|
|
263
263
|
nestedRoute = null;
|
|
@@ -270,11 +270,7 @@ var generateCode = function() {
|
|
|
270
270
|
internalDirAlias: internalDirAlias
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
|
-
if (!entrypoint.nestedRoutesEntry) return [
|
|
274
|
-
3,
|
|
275
|
-
3
|
|
276
|
-
];
|
|
277
|
-
if (!!isV5) return [
|
|
273
|
+
if (!(!isV5 && entrypoint.nestedRoutesEntry)) return [
|
|
278
274
|
3,
|
|
279
275
|
2
|
|
280
276
|
];
|
|
@@ -290,15 +286,8 @@ var generateCode = function() {
|
|
|
290
286
|
if (nestedRoute) {
|
|
291
287
|
initialRoutes.unshift(nestedRoute);
|
|
292
288
|
}
|
|
293
|
-
|
|
294
|
-
3,
|
|
295
|
-
3
|
|
296
|
-
];
|
|
289
|
+
_state.label = 2;
|
|
297
290
|
case 2:
|
|
298
|
-
logger.error("Nested routes is not supported in legacy mode.");
|
|
299
|
-
process.exit(1);
|
|
300
|
-
_state.label = 3;
|
|
301
|
-
case 3:
|
|
302
291
|
return [
|
|
303
292
|
4,
|
|
304
293
|
hookRunners.modifyFileSystemRoutes({
|
|
@@ -306,7 +295,7 @@ var generateCode = function() {
|
|
|
306
295
|
routes: initialRoutes
|
|
307
296
|
})
|
|
308
297
|
];
|
|
309
|
-
case
|
|
298
|
+
case 3:
|
|
310
299
|
routes = _state.sent().routes;
|
|
311
300
|
config2 = useResolvedConfigContext();
|
|
312
301
|
ssr = getEntryOptions(entryName, config2.server.ssr, config2.server.ssrByEntries, packageName);
|
|
@@ -338,18 +327,18 @@ var generateCode = function() {
|
|
|
338
327
|
internalDirectory: internalDirectory
|
|
339
328
|
})
|
|
340
329
|
];
|
|
341
|
-
case
|
|
330
|
+
case 4:
|
|
342
331
|
return [
|
|
343
332
|
4,
|
|
344
333
|
_.apply(hookRunners, [
|
|
345
334
|
(_tmp.code = _state.sent(), _tmp)
|
|
346
335
|
])
|
|
347
336
|
];
|
|
348
|
-
case
|
|
337
|
+
case 5:
|
|
349
338
|
_ref = _state.sent(), code2 = _ref.code;
|
|
350
339
|
if (!(entrypoint.nestedRoutesEntry && mode)) return [
|
|
351
340
|
3,
|
|
352
|
-
|
|
341
|
+
8
|
|
353
342
|
];
|
|
354
343
|
routesServerFile = getServerLoadersFile(internalDirectory, entryName);
|
|
355
344
|
code3 = templates.routesForServer({
|
|
@@ -359,19 +348,19 @@ var generateCode = function() {
|
|
|
359
348
|
4,
|
|
360
349
|
fs.ensureFile(routesServerFile)
|
|
361
350
|
];
|
|
362
|
-
case
|
|
351
|
+
case 6:
|
|
363
352
|
_state.sent();
|
|
364
353
|
return [
|
|
365
354
|
4,
|
|
366
355
|
fs.writeFile(routesServerFile, code3)
|
|
367
356
|
];
|
|
368
|
-
case
|
|
357
|
+
case 7:
|
|
369
358
|
_state.sent();
|
|
359
|
+
_state.label = 8;
|
|
360
|
+
case 8:
|
|
361
|
+
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
|
|
370
362
|
_state.label = 9;
|
|
371
363
|
case 9:
|
|
372
|
-
fs.outputFileSync(path.resolve(internalDirectory, "./".concat(entryName, "/").concat(FILE_SYSTEM_ROUTES_FILE_NAME)), code2, "utf8");
|
|
373
|
-
_state.label = 10;
|
|
374
|
-
case 10:
|
|
375
364
|
return [
|
|
376
365
|
4,
|
|
377
366
|
hookRunners.modifyEntryImports({
|
|
@@ -385,7 +374,7 @@ var generateCode = function() {
|
|
|
385
374
|
})
|
|
386
375
|
})
|
|
387
376
|
];
|
|
388
|
-
case
|
|
377
|
+
case 10:
|
|
389
378
|
_ref1 = _state.sent(), importStatements = _ref1.imports;
|
|
390
379
|
return [
|
|
391
380
|
4,
|
|
@@ -394,7 +383,7 @@ var generateCode = function() {
|
|
|
394
383
|
plugins: []
|
|
395
384
|
})
|
|
396
385
|
];
|
|
397
|
-
case
|
|
386
|
+
case 11:
|
|
398
387
|
plugins = _state.sent().plugins;
|
|
399
388
|
return [
|
|
400
389
|
4,
|
|
@@ -407,7 +396,7 @@ var generateCode = function() {
|
|
|
407
396
|
})
|
|
408
397
|
})
|
|
409
398
|
];
|
|
410
|
-
case
|
|
399
|
+
case 12:
|
|
411
400
|
_ref2 = _state.sent(), renderFunction = _ref2.code;
|
|
412
401
|
return [
|
|
413
402
|
4,
|
|
@@ -416,7 +405,7 @@ var generateCode = function() {
|
|
|
416
405
|
exportStatement: "export default AppWrapper;"
|
|
417
406
|
})
|
|
418
407
|
];
|
|
419
|
-
case
|
|
408
|
+
case 13:
|
|
420
409
|
exportStatement = _state.sent().exportStatement;
|
|
421
410
|
code = templates.index({
|
|
422
411
|
mountId: mountId,
|
|
@@ -428,7 +417,7 @@ var generateCode = function() {
|
|
|
428
417
|
entrypoint.entry = entryFile;
|
|
429
418
|
if (!config.source.enableAsyncEntry) return [
|
|
430
419
|
3,
|
|
431
|
-
|
|
420
|
+
15
|
|
432
421
|
];
|
|
433
422
|
return [
|
|
434
423
|
4,
|
|
@@ -437,19 +426,19 @@ var generateCode = function() {
|
|
|
437
426
|
code: "import('./".concat(ENTRY_BOOTSTRAP_FILE_NAME, "');")
|
|
438
427
|
})
|
|
439
428
|
];
|
|
440
|
-
case
|
|
429
|
+
case 14:
|
|
441
430
|
_ref3 = _state.sent(), asyncEntryCode = _ref3.code;
|
|
442
431
|
fs.outputFileSync(entryFile, asyncEntryCode, "utf8");
|
|
443
432
|
bootstrapFile = path.resolve(internalDirectory, "./".concat(entryName, "/").concat(ENTRY_BOOTSTRAP_FILE_NAME));
|
|
444
433
|
fs.outputFileSync(bootstrapFile, code, "utf8");
|
|
445
434
|
return [
|
|
446
435
|
3,
|
|
447
|
-
|
|
436
|
+
16
|
|
448
437
|
];
|
|
449
|
-
case
|
|
438
|
+
case 15:
|
|
450
439
|
fs.outputFileSync(entryFile, code, "utf8");
|
|
451
|
-
_state.label =
|
|
452
|
-
case
|
|
440
|
+
_state.label = 16;
|
|
441
|
+
case 16:
|
|
453
442
|
return [
|
|
454
443
|
2
|
|
455
444
|
];
|
|
@@ -463,7 +452,7 @@ var generateCode = function() {
|
|
|
463
452
|
case 0:
|
|
464
453
|
internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
|
|
465
454
|
hookRunners = api.useHookRunners();
|
|
466
|
-
isV5 =
|
|
455
|
+
isV5 = isRouterV5(config);
|
|
467
456
|
mountId = config.html.mountId;
|
|
468
457
|
getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
|
|
469
458
|
return [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME } from "@modern-js/utils";
|
|
2
|
+
import { ensureAbsolutePath, fs, findExists, MAIN_ENTRY_NAME, isRouterV5 } from "@modern-js/utils";
|
|
3
3
|
import { getFileSystemEntry } from "./getFileSystemEntry";
|
|
4
4
|
import { JS_EXTENSIONS } from "./constants";
|
|
5
5
|
var ensureExtensions = function(file) {
|
|
@@ -43,7 +43,7 @@ var getBundleEntry = function(appContext, config) {
|
|
|
43
43
|
customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
|
|
44
44
|
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
45
45
|
};
|
|
46
|
-
if (entrypoint.fileSystemRoutes) {
|
|
46
|
+
if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
|
|
47
47
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
48
48
|
}
|
|
49
49
|
if (!ifAlreadyExists(defaults, entrypoint)) {
|
|
@@ -26,7 +26,7 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
26
26
|
import { join } from "path";
|
|
27
27
|
import { createCopyPattern } from "../../shared";
|
|
28
28
|
import { RouterPlugin } from "../webpackPlugins";
|
|
29
|
-
var
|
|
29
|
+
var builderPluginCompatModern = function(options) {
|
|
30
30
|
return {
|
|
31
31
|
name: "builder-plugin-compat-modern",
|
|
32
32
|
setup: function setup(api) {
|
|
@@ -61,4 +61,4 @@ var PluginCompatModern = function(options) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
export {
|
|
64
|
+
export { builderPluginCompatModern };
|
|
@@ -200,10 +200,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
import { builderWebpackProvider } from "@modern-js/builder-webpack-provider";
|
|
203
|
-
import { applyOptionsChain } from "@modern-js/utils";
|
|
204
203
|
import { createCopyPattern } from "../shared";
|
|
205
204
|
import { generateBuilder } from "../generator";
|
|
206
|
-
import {
|
|
205
|
+
import { builderPluginCompatModern } from "./builderPlugins/compatModern";
|
|
207
206
|
function createWebpackBuilderForModern(options) {
|
|
208
207
|
return generateBuilder(options, builderWebpackProvider, {
|
|
209
208
|
modifyBuilderConfig: function modifyBuilderConfig(config) {
|
|
@@ -248,7 +247,7 @@ function applyBuilderPlugins(builder, options) {
|
|
|
248
247
|
}
|
|
249
248
|
function _applyBuilderPlugins() {
|
|
250
249
|
_applyBuilderPlugins = _asyncToGenerator(function(builder, options) {
|
|
251
|
-
var normalizedConfig,
|
|
250
|
+
var normalizedConfig, builderPluginNodePolyfill, _normalizedConfig_tools, esbuildOptions, builderPluginEsbuild;
|
|
252
251
|
return __generator(this, function(_state) {
|
|
253
252
|
switch(_state.label){
|
|
254
253
|
case 0:
|
|
@@ -262,9 +261,9 @@ function _applyBuilderPlugins() {
|
|
|
262
261
|
import("@modern-js/builder-plugin-node-polyfill")
|
|
263
262
|
];
|
|
264
263
|
case 1:
|
|
265
|
-
|
|
264
|
+
builderPluginNodePolyfill = _state.sent().builderPluginNodePolyfill;
|
|
266
265
|
builder.addPlugins([
|
|
267
|
-
|
|
266
|
+
builderPluginNodePolyfill()
|
|
268
267
|
]);
|
|
269
268
|
_state.label = 2;
|
|
270
269
|
case 2:
|
|
@@ -278,17 +277,14 @@ function _applyBuilderPlugins() {
|
|
|
278
277
|
import("@modern-js/builder-plugin-esbuild")
|
|
279
278
|
];
|
|
280
279
|
case 3:
|
|
281
|
-
|
|
280
|
+
builderPluginEsbuild = _state.sent().builderPluginEsbuild;
|
|
282
281
|
builder.addPlugins([
|
|
283
|
-
|
|
284
|
-
loader: false,
|
|
285
|
-
minimize: applyOptionsChain({}, esbuildOptions)
|
|
286
|
-
})
|
|
282
|
+
builderPluginEsbuild(esbuildOptions)
|
|
287
283
|
]);
|
|
288
284
|
_state.label = 4;
|
|
289
285
|
case 4:
|
|
290
286
|
builder.addPlugins([
|
|
291
|
-
|
|
287
|
+
builderPluginCompatModern(options)
|
|
292
288
|
]);
|
|
293
289
|
return [
|
|
294
290
|
2
|
|
@@ -7,7 +7,7 @@ function getBuilderTargets(normalizedConfig) {
|
|
|
7
7
|
if (useNodeTarget) {
|
|
8
8
|
targets.push("node");
|
|
9
9
|
}
|
|
10
|
-
var useWorkerTarget =
|
|
10
|
+
var useWorkerTarget = isServiceWorker(normalizedConfig);
|
|
11
11
|
if (useWorkerTarget) {
|
|
12
12
|
targets.push("service-worker");
|
|
13
13
|
}
|
package/dist/esm/commands/dev.js
CHANGED
|
@@ -182,7 +182,7 @@ import { buildServerConfig } from "../utils/config";
|
|
|
182
182
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
183
183
|
var dev = function() {
|
|
184
184
|
var _ref = _asyncToGenerator(function(api, options) {
|
|
185
|
-
var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, app, server;
|
|
185
|
+
var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
|
|
186
186
|
return __generator(this, function(_state) {
|
|
187
187
|
switch(_state.label){
|
|
188
188
|
case 0:
|
|
@@ -236,7 +236,8 @@ var dev = function() {
|
|
|
236
236
|
serverOptions = {
|
|
237
237
|
dev: _objectSpread({
|
|
238
238
|
port: port,
|
|
239
|
-
https: normalizedConfig.dev.https
|
|
239
|
+
https: normalizedConfig.dev.https,
|
|
240
|
+
host: normalizedConfig.dev.host
|
|
240
241
|
}, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
|
|
241
242
|
pwd: appDirectory,
|
|
242
243
|
config: normalizedConfig,
|
|
@@ -255,7 +256,11 @@ var dev = function() {
|
|
|
255
256
|
];
|
|
256
257
|
case 5:
|
|
257
258
|
app = _state.sent();
|
|
258
|
-
|
|
259
|
+
host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || "localhost";
|
|
260
|
+
app.listen({
|
|
261
|
+
port: port,
|
|
262
|
+
host: host
|
|
263
|
+
}, function() {
|
|
259
264
|
var _ref = _asyncToGenerator(function(err) {
|
|
260
265
|
return __generator(this, function(_state) {
|
|
261
266
|
if (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs, getEntryOptions, logger } from "@modern-js/utils";
|
|
2
|
+
import { fs, getEntryOptions, isRouterV5, logger } from "@modern-js/utils";
|
|
3
3
|
import {
|
|
4
4
|
useResolvedConfigContext
|
|
5
5
|
} from "@modern-js/core";
|
|
@@ -60,7 +60,6 @@ ${initialize || ""}`
|
|
|
60
60
|
).join("\n");
|
|
61
61
|
};
|
|
62
62
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
63
|
-
var _a, _b, _c;
|
|
64
63
|
const {
|
|
65
64
|
internalDirectory,
|
|
66
65
|
srcDirectory,
|
|
@@ -69,7 +68,7 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
69
68
|
packageName
|
|
70
69
|
} = appContext;
|
|
71
70
|
const hookRunners = api.useHookRunners();
|
|
72
|
-
const isV5 =
|
|
71
|
+
const isV5 = isRouterV5(config);
|
|
73
72
|
const { mountId } = config.html;
|
|
74
73
|
const getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
|
|
75
74
|
await Promise.all(entrypoints.map(generateEntryCode));
|
|
@@ -88,23 +87,18 @@ const generateCode = async (appContext, config, entrypoints, api) => {
|
|
|
88
87
|
internalDirAlias
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
|
-
if (entrypoint.nestedRoutesEntry) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
initialRoutes.unshift(nestedRoute);
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
logger.error("Nested routes is not supported in legacy mode.");
|
|
107
|
-
process.exit(1);
|
|
90
|
+
if (!isV5 && entrypoint.nestedRoutesEntry) {
|
|
91
|
+
nestedRoute = await walk(
|
|
92
|
+
entrypoint.nestedRoutesEntry,
|
|
93
|
+
entrypoint.nestedRoutesEntry,
|
|
94
|
+
{
|
|
95
|
+
name: internalSrcAlias,
|
|
96
|
+
basename: srcDirectory
|
|
97
|
+
},
|
|
98
|
+
entrypoint.entryName
|
|
99
|
+
);
|
|
100
|
+
if (nestedRoute) {
|
|
101
|
+
initialRoutes.unshift(nestedRoute);
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
104
|
const { routes } = await hookRunners.modifyFileSystemRoutes({
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
ensureAbsolutePath,
|
|
4
4
|
fs,
|
|
5
5
|
findExists,
|
|
6
|
-
MAIN_ENTRY_NAME
|
|
6
|
+
MAIN_ENTRY_NAME,
|
|
7
|
+
isRouterV5
|
|
7
8
|
} from "@modern-js/utils";
|
|
8
9
|
import { getFileSystemEntry } from "./getFileSystemEntry";
|
|
9
10
|
import { JS_EXTENSIONS } from "./constants";
|
|
@@ -55,7 +56,7 @@ const getBundleEntry = (appContext, config) => {
|
|
|
55
56
|
customBootstrap: value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
|
|
56
57
|
fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, value.entry)).isDirectory() ? {} : void 0
|
|
57
58
|
};
|
|
58
|
-
if (entrypoint.fileSystemRoutes) {
|
|
59
|
+
if (entrypoint.fileSystemRoutes && isRouterV5(config)) {
|
|
59
60
|
entrypoint.nestedRoutesEntry = entrypoint.entry;
|
|
60
61
|
}
|
|
61
62
|
if (!ifAlreadyExists(defaults, entrypoint)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
2
|
import { createCopyPattern } from "../../shared";
|
|
3
3
|
import { RouterPlugin } from "../webpackPlugins";
|
|
4
|
-
const
|
|
4
|
+
const builderPluginCompatModern = (options) => ({
|
|
5
5
|
name: "builder-plugin-compat-modern",
|
|
6
6
|
setup(api) {
|
|
7
7
|
const { normalizedConfig: modernConfig, appContext } = options;
|
|
@@ -37,5 +37,5 @@ const PluginCompatModern = (options) => ({
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
builderPluginCompatModern
|
|
41
41
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
builderWebpackProvider
|
|
3
3
|
} from "@modern-js/builder-webpack-provider";
|
|
4
|
-
import { applyOptionsChain } from "@modern-js/utils";
|
|
5
4
|
import { createCopyPattern } from "../shared";
|
|
6
5
|
import { generateBuilder } from "../generator";
|
|
7
|
-
import {
|
|
6
|
+
import { builderPluginCompatModern } from "./builderPlugins/compatModern";
|
|
8
7
|
function createWebpackBuilderForModern(options) {
|
|
9
8
|
return generateBuilder(options, builderWebpackProvider, {
|
|
10
9
|
modifyBuilderConfig(config) {
|
|
@@ -31,20 +30,15 @@ function modifyOutputConfig(config, appContext) {
|
|
|
31
30
|
async function applyBuilderPlugins(builder, options) {
|
|
32
31
|
const { normalizedConfig } = options;
|
|
33
32
|
if (!normalizedConfig.output.disableNodePolyfill) {
|
|
34
|
-
const {
|
|
35
|
-
builder.addPlugins([
|
|
33
|
+
const { builderPluginNodePolyfill } = await import("@modern-js/builder-plugin-node-polyfill");
|
|
34
|
+
builder.addPlugins([builderPluginNodePolyfill()]);
|
|
36
35
|
}
|
|
37
36
|
if (normalizedConfig.tools.esbuild) {
|
|
38
37
|
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
|
39
|
-
const {
|
|
40
|
-
builder.addPlugins([
|
|
41
|
-
PluginEsbuild({
|
|
42
|
-
loader: false,
|
|
43
|
-
minimize: applyOptionsChain({}, esbuildOptions)
|
|
44
|
-
})
|
|
45
|
-
]);
|
|
38
|
+
const { builderPluginEsbuild } = await import("@modern-js/builder-plugin-esbuild");
|
|
39
|
+
builder.addPlugins([builderPluginEsbuild(esbuildOptions)]);
|
|
46
40
|
}
|
|
47
|
-
builder.addPlugins([
|
|
41
|
+
builder.addPlugins([builderPluginCompatModern(options)]);
|
|
48
42
|
}
|
|
49
43
|
export {
|
|
50
44
|
createWebpackBuilderForModern
|