@modern-js/app-tools 1.22.1 → 2.0.0-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/CHANGELOG.md +1383 -87
- package/bin/modern.js +13 -1
- package/dist/js/modern/analyze/Builder.js +39 -0
- package/dist/js/modern/analyze/constants.js +48 -15
- package/dist/js/modern/analyze/generateCode.js +286 -133
- package/dist/js/modern/analyze/getBundleEntry.js +39 -41
- 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 +74 -39
- package/dist/js/modern/analyze/getHtmlTemplate.js +90 -57
- package/dist/js/modern/analyze/getServerRoutes.js +123 -140
- package/dist/js/modern/analyze/index.js +220 -133
- package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -20
- package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -13
- package/dist/js/modern/analyze/nestedRoutes.js +166 -0
- package/dist/js/modern/analyze/templates.js +289 -29
- package/dist/js/modern/analyze/utils.js +128 -58
- package/dist/js/modern/builder/builderPlugins/compatModern.js +233 -0
- package/dist/js/modern/builder/index.js +154 -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 +75 -138
- package/dist/js/modern/commands/deploy.js +27 -4
- package/dist/js/modern/commands/dev.js +102 -66
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/inspect.js +33 -64
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +173 -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 +153 -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 -1
- package/dist/js/modern/hooks.js +37 -21
- package/dist/js/modern/index.js +185 -94
- package/dist/js/modern/initialize/index.js +120 -0
- package/dist/js/modern/locale/en.js +20 -22
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +21 -23
- 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/commands.js +13 -0
- package/dist/js/modern/utils/config.js +102 -52
- package/dist/js/modern/utils/createFileWatcher.js +115 -0
- package/dist/js/modern/utils/createServer.js +67 -10
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/getSpecifiedEntries.js +46 -25
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/modern/utils/printInstructions.js +29 -9
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +29 -14
- package/dist/js/node/analyze/Builder.js +64 -0
- package/dist/js/node/analyze/constants.js +86 -33
- package/dist/js/node/analyze/generateCode.js +305 -163
- package/dist/js/node/analyze/getBundleEntry.js +66 -58
- 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 +99 -58
- package/dist/js/node/analyze/getHtmlTemplate.js +121 -83
- package/dist/js/node/analyze/getServerRoutes.js +146 -160
- package/dist/js/node/analyze/index.js +243 -161
- package/dist/js/node/analyze/isDefaultExportFunction.js +59 -38
- package/dist/js/node/analyze/makeLegalIdentifier.js +31 -19
- package/dist/js/node/analyze/nestedRoutes.js +193 -0
- package/dist/js/node/analyze/templates.js +316 -43
- package/dist/js/node/analyze/utils.js +158 -78
- 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 +97 -159
- package/dist/js/node/commands/deploy.js +49 -12
- package/dist/js/node/commands/dev.js +121 -93
- package/dist/js/node/commands/index.js +19 -44
- package/dist/js/node/commands/inspect.js +56 -93
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +195 -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 +176 -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 +25 -11
- package/dist/js/node/hooks.js +53 -36
- package/dist/js/node/index.js +216 -128
- package/dist/js/node/initialize/index.js +135 -0
- package/dist/js/node/locale/en.js +40 -26
- package/dist/js/node/locale/index.js +31 -18
- package/dist/js/node/locale/zh.js +41 -27
- 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/commands.js +37 -0
- package/dist/js/node/utils/config.js +125 -75
- package/dist/js/node/utils/createFileWatcher.js +139 -0
- package/dist/js/node/utils/createServer.js +96 -25
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/getSpecifiedEntries.js +68 -34
- package/dist/js/node/utils/language.js +28 -10
- package/dist/js/node/utils/printInstructions.js +51 -19
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +58 -24
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/Builder.js +199 -0
- package/dist/js/treeshaking/analyze/constants.js +37 -0
- package/dist/js/treeshaking/analyze/generateCode.js +615 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +64 -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 +589 -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 +426 -0
- package/dist/js/treeshaking/analyze/templates.js +446 -0
- package/dist/js/treeshaking/analyze/utils.js +390 -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 +319 -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 +208 -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 +213 -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 +31 -0
- package/dist/js/treeshaking/index.js +694 -0
- package/dist/js/treeshaking/initialize/index.js +300 -0
- package/dist/js/treeshaking/locale/en.js +35 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +35 -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/commands.js +10 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createFileWatcher.js +283 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +185 -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/analyze/Builder.d.ts +8 -0
- package/dist/types/analyze/constants.d.ts +13 -1
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
- package/dist/types/analyze/getServerRoutes.d.ts +3 -2
- package/dist/types/analyze/index.d.ts +3 -40
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +24 -5
- package/dist/types/analyze/utils.d.ts +12 -2
- package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
- package/dist/types/builder/index.d.ts +18 -0
- package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +4 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +10 -6
- package/dist/types/commands/serve.d.ts +3 -0
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
- package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
- package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
- package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
- package/dist/types/config/initial/index.d.ts +4 -0
- package/dist/types/config/initial/inits.d.ts +4 -0
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +8 -0
- package/dist/types/hooks.d.ts +2 -37
- package/dist/types/index.d.ts +9 -3
- package/dist/types/initialize/index.d.ts +5 -0
- package/dist/types/locale/en.d.ts +1 -2
- package/dist/types/locale/index.d.ts +2 -4
- package/dist/types/locale/zh.d.ts +1 -2
- package/dist/types/schema/Schema.d.ts +14 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/dist/types/schema/legacy.d.ts +3 -0
- package/dist/types/types/config/deploy.d.ts +9 -0
- package/dist/types/types/config/dev.d.ts +13 -0
- package/dist/types/types/config/experiments.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +4 -0
- package/dist/types/types/config/index.d.ts +66 -0
- package/dist/types/types/config/output.d.ts +22 -0
- package/dist/types/types/config/performance.d.ts +4 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/source.d.ts +24 -0
- package/dist/types/types/config/tools.d.ts +24 -0
- package/dist/types/types/hooks.d.ts +89 -0
- package/dist/types/types/index.d.ts +23 -0
- package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
- package/dist/types/types/legacyConfig/dev.d.ts +13 -0
- package/dist/types/types/legacyConfig/index.d.ts +33 -0
- package/dist/types/types/legacyConfig/output.d.ts +51 -0
- package/dist/types/types/legacyConfig/source.d.ts +25 -0
- package/dist/types/types/legacyConfig/tools.d.ts +17 -0
- package/dist/types/utils/commands.d.ts +2 -0
- package/dist/types/utils/config.d.ts +2 -2
- package/dist/types/utils/createFileWatcher.d.ts +4 -0
- package/dist/types/utils/createServer.d.ts +9 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +2 -0
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/restart.d.ts +3 -0
- package/dist/types/utils/types.d.ts +2 -3
- package/lib/types.d.ts +1 -1
- package/package.json +37 -46
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/types/commands/start.d.ts +0 -2
- package/dist/types/utils/createCompiler.d.ts +0 -13
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
+
var __async = (__this, __arguments, generator) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
var fulfilled = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.next(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var rejected = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.throw(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var nestedRoutes_exports = {};
|
|
62
|
+
__export(nestedRoutes_exports, {
|
|
63
|
+
walk: () => walk
|
|
64
|
+
});
|
|
65
|
+
module.exports = __toCommonJS(nestedRoutes_exports);
|
|
66
|
+
var path = __toESM(require("path"));
|
|
67
|
+
var import_utils = require("@modern-js/utils");
|
|
68
|
+
var import_constants = require("./constants");
|
|
69
|
+
var import_utils2 = require("./utils");
|
|
70
|
+
const conventionNames = Object.values(import_constants.NESTED_ROUTE);
|
|
71
|
+
const getLoaderPath = (filename) => __async(void 0, null, function* () {
|
|
72
|
+
if (yield (0, import_utils2.hasLoader)(filename)) {
|
|
73
|
+
return filename;
|
|
74
|
+
}
|
|
75
|
+
return void 0;
|
|
76
|
+
});
|
|
77
|
+
const replaceDynamicPath = (routePath) => {
|
|
78
|
+
return routePath.replace(/\[(.*?)\]/g, ":$1");
|
|
79
|
+
};
|
|
80
|
+
const createIndexRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
81
|
+
return createRoute(
|
|
82
|
+
__spreadProps(__spreadValues({}, routeInfo), {
|
|
83
|
+
index: true,
|
|
84
|
+
children: void 0
|
|
85
|
+
}),
|
|
86
|
+
rootDir,
|
|
87
|
+
filename,
|
|
88
|
+
entryName
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
const createRoute = (routeInfo, rootDir, filename, entryName) => {
|
|
92
|
+
const id = (0, import_utils.getRouteId)(filename, rootDir, entryName);
|
|
93
|
+
return __spreadProps(__spreadValues({}, routeInfo), {
|
|
94
|
+
id,
|
|
95
|
+
type: "nested"
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const walk = (dirname, rootDir, alias, entryName) => __async(void 0, null, function* () {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
if (!(yield import_utils.fs.pathExists(dirname))) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const isDirectory = (yield import_utils.fs.stat(dirname)).isDirectory();
|
|
104
|
+
if (!isDirectory) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const relativeDir = path.relative(rootDir, dirname);
|
|
108
|
+
const pathSegments = relativeDir.split(path.sep);
|
|
109
|
+
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
110
|
+
const isRoot = lastSegment === "";
|
|
111
|
+
const isPathlessLayout = lastSegment.startsWith("__");
|
|
112
|
+
const isWithoutLayoutPath = lastSegment.includes(".");
|
|
113
|
+
let routePath = isRoot || isPathlessLayout ? "/" : `${lastSegment}`;
|
|
114
|
+
if (isWithoutLayoutPath) {
|
|
115
|
+
routePath = lastSegment.split(".").join("/");
|
|
116
|
+
}
|
|
117
|
+
routePath = replaceDynamicPath(routePath);
|
|
118
|
+
const route = {
|
|
119
|
+
path: routePath,
|
|
120
|
+
children: [],
|
|
121
|
+
isRoot
|
|
122
|
+
};
|
|
123
|
+
let pageLoaderFile = "";
|
|
124
|
+
let pageRoute = null;
|
|
125
|
+
const items = yield import_utils.fs.readdir(dirname);
|
|
126
|
+
for (const item of items) {
|
|
127
|
+
const itemPath = path.join(dirname, item);
|
|
128
|
+
const extname = path.extname(item);
|
|
129
|
+
const itemWithoutExt = item.slice(0, -extname.length);
|
|
130
|
+
const isDirectory2 = (yield import_utils.fs.stat(itemPath)).isDirectory();
|
|
131
|
+
if (isDirectory2) {
|
|
132
|
+
const childRoute = yield walk(itemPath, rootDir, alias, entryName);
|
|
133
|
+
if (childRoute) {
|
|
134
|
+
(_a = route.children) == null ? void 0 : _a.push(childRoute);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (extname && (!import_constants.JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LAYOUT_LOADER_FILE) {
|
|
141
|
+
if (!route.loader) {
|
|
142
|
+
route.loader = itemPath;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LAYOUT_FILE) {
|
|
146
|
+
route._component = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
147
|
+
const loaderPath = yield getLoaderPath(itemPath);
|
|
148
|
+
if (loaderPath) {
|
|
149
|
+
route.loader = loaderPath;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.PAGE_LOADER_FILE) {
|
|
153
|
+
pageLoaderFile = itemPath;
|
|
154
|
+
}
|
|
155
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.PAGE_FILE) {
|
|
156
|
+
pageRoute = createIndexRoute(
|
|
157
|
+
{
|
|
158
|
+
_component: (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name)
|
|
159
|
+
},
|
|
160
|
+
rootDir,
|
|
161
|
+
itemPath,
|
|
162
|
+
entryName
|
|
163
|
+
);
|
|
164
|
+
const loaderPath = yield getLoaderPath(itemPath);
|
|
165
|
+
if (loaderPath) {
|
|
166
|
+
pageRoute.loader = loaderPath;
|
|
167
|
+
} else if (pageLoaderFile) {
|
|
168
|
+
pageRoute.loader = pageLoaderFile;
|
|
169
|
+
}
|
|
170
|
+
(_b = route.children) == null ? void 0 : _b.push(pageRoute);
|
|
171
|
+
}
|
|
172
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.LOADING_FILE) {
|
|
173
|
+
route.loading = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
174
|
+
}
|
|
175
|
+
if (itemWithoutExt === import_constants.NESTED_ROUTE.ERROR_FILE) {
|
|
176
|
+
route.error = (0, import_utils2.replaceWithAlias)(alias.basename, itemPath, alias.name);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const finalRoute = createRoute(
|
|
180
|
+
route,
|
|
181
|
+
rootDir,
|
|
182
|
+
path.join(dirname, `${import_constants.NESTED_ROUTE.LAYOUT_FILE}.ts`),
|
|
183
|
+
entryName
|
|
184
|
+
);
|
|
185
|
+
if (isPathlessLayout) {
|
|
186
|
+
delete finalRoute.path;
|
|
187
|
+
}
|
|
188
|
+
return finalRoute;
|
|
189
|
+
});
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
walk
|
|
193
|
+
});
|
|
@@ -1,14 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
+
var __async = (__this, __arguments, generator) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
var fulfilled = (value) => {
|
|
44
|
+
try {
|
|
45
|
+
step(generator.next(value));
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(e);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var rejected = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.throw(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
58
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var templates_exports = {};
|
|
62
|
+
__export(templates_exports, {
|
|
63
|
+
fileSystemRoutes: () => fileSystemRoutes,
|
|
64
|
+
html: () => html,
|
|
65
|
+
index: () => index,
|
|
66
|
+
renderFunction: () => renderFunction,
|
|
67
|
+
routesForServer: () => routesForServer
|
|
5
68
|
});
|
|
6
|
-
|
|
7
|
-
|
|
69
|
+
module.exports = __toCommonJS(templates_exports);
|
|
70
|
+
var import_path = __toESM(require("path"));
|
|
71
|
+
var import_utils = require("@modern-js/utils");
|
|
72
|
+
var import_constants = require("./constants");
|
|
8
73
|
const index = ({
|
|
9
74
|
mountId,
|
|
10
75
|
imports,
|
|
11
|
-
renderFunction,
|
|
76
|
+
renderFunction: renderFunction2,
|
|
12
77
|
exportStatement
|
|
13
78
|
}) => `
|
|
14
79
|
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
|
@@ -22,30 +87,25 @@ let AppWrapper = null;
|
|
|
22
87
|
let root = null;
|
|
23
88
|
|
|
24
89
|
function render() {
|
|
25
|
-
${
|
|
90
|
+
${renderFunction2}
|
|
26
91
|
}
|
|
27
92
|
|
|
28
93
|
AppWrapper = render();
|
|
29
94
|
|
|
30
95
|
${exportStatement};
|
|
31
96
|
`;
|
|
32
|
-
|
|
33
|
-
exports.index = index;
|
|
34
|
-
|
|
35
97
|
const renderFunction = ({
|
|
36
98
|
plugins,
|
|
37
99
|
customBootstrap,
|
|
38
|
-
fileSystemRoutes
|
|
100
|
+
fileSystemRoutes: fileSystemRoutes2
|
|
39
101
|
}) => `
|
|
40
102
|
AppWrapper = createApp({
|
|
41
103
|
plugins: [
|
|
42
|
-
${plugins.map(
|
|
43
|
-
name,
|
|
44
|
-
|
|
45
|
-
args
|
|
46
|
-
}) => `${name}({...${options}, ...App?.config?.${args || name}}),`).join('\n')}
|
|
104
|
+
${plugins.map(
|
|
105
|
+
({ name, options, args }) => `${name}({...${options}, ...App?.config?.${args || name}}),`
|
|
106
|
+
).join("\n")}
|
|
47
107
|
]
|
|
48
|
-
})(${
|
|
108
|
+
})(${fileSystemRoutes2 ? "" : `App`})
|
|
49
109
|
|
|
50
110
|
if (IS_BROWSER) {
|
|
51
111
|
${customBootstrap ? `customBootstrap(AppWrapper);` : `bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);`}
|
|
@@ -53,22 +113,19 @@ const renderFunction = ({
|
|
|
53
113
|
|
|
54
114
|
return AppWrapper
|
|
55
115
|
`;
|
|
56
|
-
|
|
57
|
-
exports.renderFunction = renderFunction;
|
|
58
|
-
|
|
59
|
-
const html = partials => `
|
|
116
|
+
const html = (partials) => `
|
|
60
117
|
<!DOCTYPE html>
|
|
61
118
|
<html>
|
|
62
119
|
<head>
|
|
63
120
|
<%= meta %>
|
|
64
121
|
<title><%= title %></title>
|
|
65
122
|
|
|
66
|
-
${partials.top.join(
|
|
123
|
+
${partials.top.join("\n")}
|
|
67
124
|
|
|
68
125
|
<script>
|
|
69
126
|
window.__assetPrefix__ = '<%= assetPrefix %>';
|
|
70
|
-
|
|
71
|
-
${partials.head.join(
|
|
127
|
+
<\/script>
|
|
128
|
+
${partials.head.join("\n")}
|
|
72
129
|
|
|
73
130
|
<!--<?- chunksMap.css ?>-->
|
|
74
131
|
</head>
|
|
@@ -78,7 +135,7 @@ const html = partials => `
|
|
|
78
135
|
We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.
|
|
79
136
|
</noscript>
|
|
80
137
|
<div id="<%= mountId %>"><!--<?- html ?>--></div>
|
|
81
|
-
${partials.body.join(
|
|
138
|
+
${partials.body.join("\n")}
|
|
82
139
|
<!--<?- chunksMap.js ?>-->
|
|
83
140
|
<!--<?- SSRDataScript ?>-->
|
|
84
141
|
<!--<?- bottomTemplate ?>-->
|
|
@@ -86,21 +143,237 @@ const html = partials => `
|
|
|
86
143
|
|
|
87
144
|
</html>
|
|
88
145
|
`;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
146
|
+
const routesForServer = ({
|
|
147
|
+
routes,
|
|
148
|
+
internalDirectory,
|
|
149
|
+
entryName
|
|
150
|
+
}) => {
|
|
151
|
+
const loaders = [];
|
|
152
|
+
const loaderIndexFile = import_path.default.join(
|
|
153
|
+
internalDirectory,
|
|
154
|
+
entryName,
|
|
155
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
156
|
+
"index.js"
|
|
157
|
+
);
|
|
158
|
+
const traverseRouteTree = (route) => {
|
|
159
|
+
var _a;
|
|
160
|
+
let children;
|
|
161
|
+
if ("children" in route && route.children) {
|
|
162
|
+
children = (_a = route == null ? void 0 : route.children) == null ? void 0 : _a.map(traverseRouteTree);
|
|
163
|
+
}
|
|
164
|
+
let loader;
|
|
165
|
+
if (route.type === "nested") {
|
|
166
|
+
if (route.loader) {
|
|
167
|
+
loaders.push(route.loader);
|
|
168
|
+
loader = `loader_${loaders.length - 1}`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
172
|
+
loader,
|
|
173
|
+
children
|
|
174
|
+
});
|
|
175
|
+
return finalRoute;
|
|
176
|
+
};
|
|
177
|
+
let routesCode = `
|
|
178
|
+
export const routes = [
|
|
179
|
+
`;
|
|
180
|
+
for (const route of routes) {
|
|
181
|
+
if ("type" in route) {
|
|
182
|
+
const newRoute = traverseRouteTree(route);
|
|
183
|
+
routesCode += `${JSON.stringify(newRoute, null, 2).replace(
|
|
184
|
+
/"(loader_[^"])"/g,
|
|
185
|
+
"$1"
|
|
186
|
+
)},`;
|
|
187
|
+
} else {
|
|
188
|
+
routesCode += `${JSON.stringify(route, null, 2)}`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
routesCode += `
|
|
192
|
+
];`;
|
|
193
|
+
let importLoadersCode = "";
|
|
194
|
+
if (loaders.length > 0) {
|
|
195
|
+
importLoadersCode = `
|
|
196
|
+
import { ${loaders.map(
|
|
197
|
+
(loader, index2) => `loader_${index2}`
|
|
198
|
+
)} } from "${(0, import_utils.slash)(loaderIndexFile)}"`;
|
|
199
|
+
}
|
|
200
|
+
return `
|
|
201
|
+
${importLoadersCode}
|
|
202
|
+
${routesCode}
|
|
203
|
+
`;
|
|
204
|
+
};
|
|
205
|
+
const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
206
|
+
routes,
|
|
207
|
+
ssrMode,
|
|
208
|
+
nestedRoutesEntry,
|
|
209
|
+
entryName,
|
|
210
|
+
internalDirectory,
|
|
211
|
+
internalDirAlias
|
|
212
|
+
}) {
|
|
213
|
+
const loadings = [];
|
|
214
|
+
const errors = [];
|
|
215
|
+
const loaders = [];
|
|
216
|
+
const loadersMap = {};
|
|
217
|
+
const loadersIndexFile = import_path.default.join(
|
|
218
|
+
internalDirAlias,
|
|
219
|
+
entryName,
|
|
220
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
221
|
+
"index.js"
|
|
222
|
+
);
|
|
223
|
+
const loadersMapFile = import_path.default.join(
|
|
224
|
+
internalDirectory,
|
|
225
|
+
entryName,
|
|
226
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
227
|
+
"map.json"
|
|
228
|
+
);
|
|
229
|
+
const importLazyCode = `
|
|
230
|
+
import { lazy } from "react";
|
|
231
|
+
import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
|
|
232
|
+
`;
|
|
233
|
+
let rootLayoutCode = ``;
|
|
234
|
+
let dataLoaderPath = "";
|
|
235
|
+
let componentLoaderPath = "";
|
|
236
|
+
if (ssrMode) {
|
|
237
|
+
dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
238
|
+
if (nestedRoutesEntry) {
|
|
239
|
+
dataLoaderPath = `${dataLoaderPath}?routesDir=${nestedRoutesEntry}&mapFile=${loadersMapFile}!`;
|
|
240
|
+
}
|
|
241
|
+
componentLoaderPath = `${import_path.default.join(
|
|
242
|
+
__dirname,
|
|
243
|
+
"../builder/loaders/routerLoader"
|
|
244
|
+
)}!`;
|
|
245
|
+
}
|
|
246
|
+
const traverseRouteTree = (route) => {
|
|
247
|
+
var _a;
|
|
248
|
+
let children;
|
|
249
|
+
if ("children" in route && route.children) {
|
|
250
|
+
children = (_a = route == null ? void 0 : route.children) == null ? void 0 : _a.map(traverseRouteTree);
|
|
251
|
+
}
|
|
252
|
+
let loading;
|
|
253
|
+
let error;
|
|
254
|
+
let loader;
|
|
255
|
+
let component = "";
|
|
256
|
+
if (route.type === "nested") {
|
|
257
|
+
if (route.loading) {
|
|
258
|
+
loadings.push(route.loading);
|
|
259
|
+
loading = `loading_${loadings.length - 1}`;
|
|
260
|
+
}
|
|
261
|
+
if (route.error) {
|
|
262
|
+
errors.push(route.error);
|
|
263
|
+
error = `error_${errors.length - 1}`;
|
|
264
|
+
}
|
|
265
|
+
if (route.loader) {
|
|
266
|
+
loaders.push(route.loader);
|
|
267
|
+
const loaderId = loaders.length - 1;
|
|
268
|
+
loader = `loader_${loaderId}`;
|
|
269
|
+
loadersMap[loader] = route.id;
|
|
270
|
+
}
|
|
271
|
+
if (route._component) {
|
|
272
|
+
if (route.isRoot) {
|
|
273
|
+
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
274
|
+
component = `RootLayout`;
|
|
275
|
+
} else if (ssrMode === "string") {
|
|
276
|
+
component = `loadable(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
277
|
+
} else {
|
|
278
|
+
component = `lazy(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} else if (route._component) {
|
|
282
|
+
component = `loadable(() => import('${route._component}'))`;
|
|
283
|
+
}
|
|
284
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
285
|
+
loading,
|
|
286
|
+
loader,
|
|
287
|
+
error,
|
|
288
|
+
children
|
|
289
|
+
});
|
|
290
|
+
if (route._component) {
|
|
291
|
+
finalRoute.component = component;
|
|
292
|
+
}
|
|
293
|
+
return finalRoute;
|
|
294
|
+
};
|
|
295
|
+
let routeComponentsCode = `
|
|
296
|
+
export const routes = [
|
|
297
|
+
`;
|
|
298
|
+
for (const route of routes) {
|
|
299
|
+
if ("type" in route) {
|
|
300
|
+
const newRoute = traverseRouteTree(route);
|
|
301
|
+
routeComponentsCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, "$1").replace(/"(loadableLazy.*\))"/g, "$1").replace(/"(lazy.*\))"/g, "$1").replace(/"(loading_[^"])"/g, "$1").replace(/"(loader_[^"])"/g, "$1").replace(/"(RootLayout)"/g, "$1").replace(/"(error_[^"])"/g, "$1").replace(/\\"/g, '"')},`;
|
|
302
|
+
} else {
|
|
303
|
+
const component = `loadable(() => import('${route._component}'))`;
|
|
304
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
305
|
+
component
|
|
306
|
+
});
|
|
307
|
+
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1")},`;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
routeComponentsCode += `
|
|
311
|
+
];`;
|
|
312
|
+
const importLoadingCode = loadings.map((loading, index2) => {
|
|
313
|
+
return `import loading_${index2} from '${loading}';
|
|
104
314
|
`;
|
|
105
|
-
|
|
106
|
-
|
|
315
|
+
}).join("");
|
|
316
|
+
const importErrorComponentsCode = errors.map((error, index2) => {
|
|
317
|
+
return `import error_${index2} from '${error}';
|
|
318
|
+
`;
|
|
319
|
+
}).join("");
|
|
320
|
+
let importLoadersCode = "";
|
|
321
|
+
if (loaders.length > 0) {
|
|
322
|
+
importLoadersCode = `
|
|
323
|
+
import { ${loaders.map(
|
|
324
|
+
(loader, index2) => `loader_${index2}`
|
|
325
|
+
)} } from "${(0, import_utils.slash)(dataLoaderPath)}${(0, import_utils.slash)(loadersIndexFile)}"
|
|
326
|
+
`;
|
|
327
|
+
const loaderEntryCode = loaders.map((loader, index2) => {
|
|
328
|
+
return `export * from './loader_${index2}.js';`;
|
|
329
|
+
}).join("\n");
|
|
330
|
+
const loaderEntryFile = import_path.default.join(
|
|
331
|
+
internalDirectory,
|
|
332
|
+
entryName,
|
|
333
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
334
|
+
"entry.js"
|
|
335
|
+
);
|
|
336
|
+
yield import_utils.fs.ensureFile(loaderEntryFile);
|
|
337
|
+
yield import_utils.fs.writeFile(loaderEntryFile, loaderEntryCode);
|
|
338
|
+
yield import_utils.fs.writeJSON(loadersMapFile, loadersMap);
|
|
339
|
+
yield Promise.all(
|
|
340
|
+
loaders.map((loader, index2) => __async(void 0, null, function* () {
|
|
341
|
+
const name = `loader_${index2}`;
|
|
342
|
+
const filename = import_path.default.join(
|
|
343
|
+
internalDirectory,
|
|
344
|
+
entryName,
|
|
345
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
346
|
+
`${name}.js`
|
|
347
|
+
);
|
|
348
|
+
let code = "";
|
|
349
|
+
if (loader.includes(".loader.")) {
|
|
350
|
+
code = `
|
|
351
|
+
export { default as ${name} } from '${(0, import_utils.slash)(loader)}'
|
|
352
|
+
`;
|
|
353
|
+
} else {
|
|
354
|
+
code = `
|
|
355
|
+
export { loader as ${name} } from '${(0, import_utils.slash)(loader)}'
|
|
356
|
+
`;
|
|
357
|
+
}
|
|
358
|
+
yield import_utils.fs.ensureFile(filename);
|
|
359
|
+
yield import_utils.fs.writeFile(filename, code);
|
|
360
|
+
}))
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return `
|
|
364
|
+
${importLazyCode}
|
|
365
|
+
${rootLayoutCode}
|
|
366
|
+
${importLoadingCode}
|
|
367
|
+
${importErrorComponentsCode}
|
|
368
|
+
${importLoadersCode}
|
|
369
|
+
${routeComponentsCode}
|
|
370
|
+
`;
|
|
371
|
+
});
|
|
372
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
373
|
+
0 && (module.exports = {
|
|
374
|
+
fileSystemRoutes,
|
|
375
|
+
html,
|
|
376
|
+
index,
|
|
377
|
+
renderFunction,
|
|
378
|
+
routesForServer
|
|
379
|
+
});
|