@modern-js/app-tools 2.5.1-alpha.1 → 2.6.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 +50 -0
- package/dist/cjs/analyze/generateCode.js +17 -19
- package/dist/cjs/analyze/getBundleEntry.js +5 -1
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +4 -0
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +4 -0
- package/dist/cjs/analyze/getClientRoutes/utils.js +4 -0
- package/dist/cjs/analyze/getFileSystemEntry.js +4 -0
- package/dist/cjs/analyze/getHtmlTemplate.js +4 -0
- package/dist/cjs/analyze/getServerRoutes.js +4 -0
- package/dist/cjs/analyze/index.js +5 -0
- package/dist/cjs/analyze/isDefaultExportFunction.js +4 -0
- package/dist/cjs/analyze/nestedRoutes.js +4 -0
- package/dist/cjs/analyze/templates.js +5 -1
- package/dist/cjs/analyze/utils.js +4 -0
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +3 -3
- package/dist/cjs/builder/builder-webpack/index.js +9 -11
- package/dist/cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js +4 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -0
- package/dist/cjs/builder/generator/getBuilderTargets.js +1 -1
- package/dist/cjs/builder/generator/index.js +4 -0
- package/dist/cjs/builder/index.js +4 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterModern.js +4 -0
- package/dist/cjs/builder/shared/createCopyPattern.js +8 -0
- package/dist/cjs/commands/build.js +2 -0
- package/dist/cjs/commands/dev.js +15 -12
- package/dist/cjs/commands/serve.js +4 -17
- package/dist/cjs/config/default.js +2 -0
- package/dist/cjs/config/initialize/inits.js +4 -0
- package/dist/cjs/config/legacy/createOutputConfig.js +2 -0
- package/dist/cjs/config/legacy/createToolsConfig.js +4 -1
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/schema/index.js +4 -0
- package/dist/cjs/utils/config.js +4 -0
- package/dist/cjs/utils/createServer.js +4 -0
- package/dist/cjs/utils/generateWatchFiles.js +4 -0
- package/dist/cjs/utils/routes.js +4 -0
- package/dist/esm/analyze/generateCode.js +26 -37
- package/dist/esm/analyze/getBundleEntry.js +2 -2
- package/dist/esm/analyze/index.js +2 -1
- 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/createBuilderProviderConfig.js +1 -0
- package/dist/esm/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm/builder/shared/createCopyPattern.js +4 -0
- package/dist/esm/commands/build.js +2 -0
- package/dist/esm/commands/dev.js +9 -9
- package/dist/esm/commands/serve.js +1 -6
- package/dist/esm/config/default.js +2 -0
- package/dist/esm/config/legacy/createOutputConfig.js +2 -0
- package/dist/esm/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm-node/analyze/generateCode.js +14 -20
- package/dist/esm-node/analyze/getBundleEntry.js +3 -2
- package/dist/esm-node/analyze/index.js +1 -0
- package/dist/esm-node/analyze/templates.js +1 -1
- 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/createBuilderProviderConfig.js +1 -0
- package/dist/esm-node/builder/generator/getBuilderTargets.js +1 -1
- package/dist/esm-node/builder/shared/createCopyPattern.js +4 -0
- package/dist/esm-node/commands/build.js +2 -0
- package/dist/esm-node/commands/dev.js +15 -12
- package/dist/esm-node/commands/serve.js +1 -18
- package/dist/esm-node/config/default.js +2 -0
- package/dist/esm-node/config/legacy/createOutputConfig.js +2 -0
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/index.js +1 -0
- package/dist/types/builder/builder-webpack/builderPlugins/compatModern.d.ts +1 -7
- package/package.json +26 -26
- package/dist/js/modern/analyze/constants.js +0 -56
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/getBundleEntry.js +0 -71
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
- package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
- package/dist/js/modern/analyze/getServerRoutes.js +0 -178
- package/dist/js/modern/analyze/index.js +0 -333
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/modern/analyze/nestedRoutes.js +0 -186
- package/dist/js/modern/analyze/templates.js +0 -328
- package/dist/js/modern/analyze/utils.js +0 -141
- package/dist/js/modern/builder/builder-rspack/index.js +0 -8
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -116
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -21
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/index.js +0 -39
- package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +0 -219
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
- package/dist/js/modern/builder/shared/createCopyPattern.js +0 -46
- package/dist/js/modern/builder/shared/index.js +0 -3
- package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/commands/build.js +0 -91
- package/dist/js/modern/commands/deploy.js +0 -28
- package/dist/js/modern/commands/dev.js +0 -109
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -38
- package/dist/js/modern/commands/serve.js +0 -54
- package/dist/js/modern/config/default.js +0 -175
- package/dist/js/modern/config/index.js +0 -3
- package/dist/js/modern/config/initialize/index.js +0 -12
- package/dist/js/modern/config/initialize/inits.js +0 -154
- package/dist/js/modern/config/legacy/createHtmlConfig.js +0 -35
- package/dist/js/modern/config/legacy/createOutputConfig.js +0 -68
- package/dist/js/modern/config/legacy/createSourceConfig.js +0 -39
- package/dist/js/modern/config/legacy/createToolsConfig.js +0 -42
- package/dist/js/modern/config/legacy/index.js +0 -51
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/exports/server.js +0 -4
- package/dist/js/modern/hooks.js +0 -35
- package/dist/js/modern/index.js +0 -221
- package/dist/js/modern/initialize/index.js +0 -132
- package/dist/js/modern/locale/en.js +0 -36
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -36
- package/dist/js/modern/schema/Schema.js +0 -40
- package/dist/js/modern/schema/index.js +0 -88
- package/dist/js/modern/schema/legacy.js +0 -148
- 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 +0 -1
- 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 +0 -3
- 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/types/utils.js +0 -0
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/env.js +0 -15
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getSelectedEntries.js +0 -58
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- package/dist/js/modern/utils/language.js +0 -8
- package/dist/js/modern/utils/printInstructions.js +0 -31
- package/dist/js/modern/utils/restart.js +0 -44
- package/dist/js/modern/utils/routes.js +0 -30
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -100
- package/dist/js/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/getBundleEntry.js +0 -95
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
- package/dist/js/node/analyze/getServerRoutes.js +0 -196
- package/dist/js/node/analyze/index.js +0 -340
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
- package/dist/js/node/analyze/nestedRoutes.js +0 -213
- package/dist/js/node/analyze/templates.js +0 -359
- package/dist/js/node/analyze/utils.js +0 -172
- package/dist/js/node/builder/builder-rspack/index.js +0 -31
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/node/builder/builder-webpack/index.js +0 -118
- package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -140
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
- package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
- package/dist/js/node/builder/generator/getBuilderTargets.js +0 -39
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/builder/index.js +0 -68
- package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +0 -245
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -50
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -57
- package/dist/js/node/builder/shared/createCopyPattern.js +0 -75
- package/dist/js/node/builder/shared/index.js +0 -19
- package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +0 -28
- package/dist/js/node/builder/shared/types.js +0 -15
- package/dist/js/node/commands/build.js +0 -112
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/commands/dev.js +0 -126
- package/dist/js/node/commands/index.js +0 -19
- package/dist/js/node/commands/inspect.js +0 -61
- package/dist/js/node/commands/serve.js +0 -83
- package/dist/js/node/config/default.js +0 -197
- package/dist/js/node/config/index.js +0 -19
- package/dist/js/node/config/initialize/index.js +0 -35
- package/dist/js/node/config/initialize/inits.js +0 -177
- package/dist/js/node/config/legacy/createHtmlConfig.js +0 -58
- package/dist/js/node/config/legacy/createOutputConfig.js +0 -91
- package/dist/js/node/config/legacy/createSourceConfig.js +0 -62
- package/dist/js/node/config/legacy/createToolsConfig.js +0 -65
- package/dist/js/node/config/legacy/index.js +0 -75
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/exports/server.js +0 -27
- package/dist/js/node/hooks.js +0 -54
- package/dist/js/node/index.js +0 -245
- package/dist/js/node/initialize/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -59
- package/dist/js/node/locale/index.js +0 -33
- package/dist/js/node/locale/zh.js +0 -59
- package/dist/js/node/schema/Schema.js +0 -63
- package/dist/js/node/schema/index.js +0 -118
- package/dist/js/node/schema/legacy.js +0 -169
- package/dist/js/node/types/config/deploy.js +0 -15
- package/dist/js/node/types/config/dev.js +0 -15
- package/dist/js/node/types/config/experiments.js +0 -15
- package/dist/js/node/types/config/html.js +0 -15
- package/dist/js/node/types/config/index.js +0 -17
- package/dist/js/node/types/config/output.js +0 -15
- package/dist/js/node/types/config/performance.js +0 -15
- package/dist/js/node/types/config/security.js +0 -15
- package/dist/js/node/types/config/source.js +0 -15
- package/dist/js/node/types/config/tools.js +0 -15
- package/dist/js/node/types/hooks.js +0 -15
- package/dist/js/node/types/index.js +0 -19
- package/dist/js/node/types/legacyConfig/deploy.js +0 -15
- package/dist/js/node/types/legacyConfig/dev.js +0 -15
- package/dist/js/node/types/legacyConfig/index.js +0 -15
- package/dist/js/node/types/legacyConfig/output.js +0 -15
- package/dist/js/node/types/legacyConfig/source.js +0 -15
- package/dist/js/node/types/legacyConfig/tools.js +0 -15
- package/dist/js/node/types/utils.js +0 -15
- package/dist/js/node/utils/config.js +0 -153
- package/dist/js/node/utils/createServer.js +0 -106
- package/dist/js/node/utils/env.js +0 -38
- package/dist/js/node/utils/generateWatchFiles.js +0 -85
- package/dist/js/node/utils/getSelectedEntries.js +0 -81
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/language.js +0 -31
- package/dist/js/node/utils/printInstructions.js +0 -54
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/node/utils/routes.js +0 -59
- package/dist/js/node/utils/types.js +0 -15
- package/dist/js/treeshaking/analyze/constants.js +0 -42
- package/dist/js/treeshaking/analyze/generateCode.js +0 -485
- package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
- package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -224
- package/dist/js/treeshaking/analyze/index.js +0 -702
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -409
- package/dist/js/treeshaking/analyze/templates.js +0 -465
- package/dist/js/treeshaking/analyze/utils.js +0 -374
- package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -346
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -16
- package/dist/js/treeshaking/builder/generator/index.js +0 -199
- package/dist/js/treeshaking/builder/index.js +0 -175
- package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +0 -300
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -110
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -72
- package/dist/js/treeshaking/builder/shared/createCopyPattern.js +0 -40
- package/dist/js/treeshaking/builder/shared/index.js +0 -3
- package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +0 -5
- package/dist/js/treeshaking/builder/shared/types.js +0 -1
- package/dist/js/treeshaking/commands/build.js +0 -291
- package/dist/js/treeshaking/commands/deploy.js +0 -154
- package/dist/js/treeshaking/commands/dev.js +0 -301
- package/dist/js/treeshaking/commands/index.js +0 -3
- package/dist/js/treeshaking/commands/inspect.js +0 -149
- package/dist/js/treeshaking/commands/serve.js +0 -199
- package/dist/js/treeshaking/config/default.js +0 -210
- package/dist/js/treeshaking/config/index.js +0 -3
- package/dist/js/treeshaking/config/initialize/index.js +0 -10
- package/dist/js/treeshaking/config/initialize/inits.js +0 -211
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/legacy/createOutputConfig.js +0 -41
- package/dist/js/treeshaking/config/legacy/createSourceConfig.js +0 -42
- package/dist/js/treeshaking/config/legacy/createToolsConfig.js +0 -23
- package/dist/js/treeshaking/config/legacy/index.js +0 -38
- package/dist/js/treeshaking/defineConfig.js +0 -61
- package/dist/js/treeshaking/exports/server.js +0 -2
- package/dist/js/treeshaking/hooks.js +0 -29
- package/dist/js/treeshaking/index.js +0 -713
- package/dist/js/treeshaking/initialize/index.js +0 -284
- package/dist/js/treeshaking/locale/en.js +0 -38
- package/dist/js/treeshaking/locale/index.js +0 -9
- package/dist/js/treeshaking/locale/zh.js +0 -38
- package/dist/js/treeshaking/schema/Schema.js +0 -273
- package/dist/js/treeshaking/schema/index.js +0 -181
- package/dist/js/treeshaking/schema/legacy.js +0 -337
- package/dist/js/treeshaking/types/config/deploy.js +0 -1
- package/dist/js/treeshaking/types/config/dev.js +0 -1
- package/dist/js/treeshaking/types/config/experiments.js +0 -1
- package/dist/js/treeshaking/types/config/html.js +0 -1
- package/dist/js/treeshaking/types/config/index.js +0 -1
- package/dist/js/treeshaking/types/config/output.js +0 -1
- package/dist/js/treeshaking/types/config/performance.js +0 -1
- package/dist/js/treeshaking/types/config/security.js +0 -1
- package/dist/js/treeshaking/types/config/source.js +0 -1
- package/dist/js/treeshaking/types/config/tools.js +0 -1
- package/dist/js/treeshaking/types/hooks.js +0 -1
- package/dist/js/treeshaking/types/index.js +0 -3
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
- package/dist/js/treeshaking/types/utils.js +0 -1
- package/dist/js/treeshaking/utils/config.js +0 -302
- package/dist/js/treeshaking/utils/createServer.js +0 -258
- package/dist/js/treeshaking/utils/env.js +0 -13
- package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
- package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
- package/dist/js/treeshaking/utils/language.js +0 -6
- package/dist/js/treeshaking/utils/printInstructions.js +0 -152
- package/dist/js/treeshaking/utils/restart.js +0 -187
- package/dist/js/treeshaking/utils/routes.js +0 -153
- package/dist/js/treeshaking/utils/types.js +0 -1
package/dist/cjs/schema/index.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/cjs/utils/config.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/cjs/utils/routes.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -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)) {
|
|
@@ -570,7 +570,8 @@ var analyze_default = function(param) {
|
|
|
570
570
|
resolved: config
|
|
571
571
|
};
|
|
572
572
|
},
|
|
573
|
-
modifyEntryImports:
|
|
573
|
+
modifyEntryImports: // This logic is not in the router plugin to avoid having to include some dependencies in the utils package
|
|
574
|
+
function modifyEntryImports(param) {
|
|
574
575
|
var entrypoint = param.entrypoint, imports = param.imports;
|
|
575
576
|
return _asyncToGenerator(function() {
|
|
576
577
|
var appContext, srcDirectory, internalSrcAlias, fileSystemRoutes, nestedRoutesEntry, rootLayoutPath, rootLayoutFile, rootLayoutBuffer, rootLayout, _ref, moduleExports, hasAppConfig, generateLayoutPath, hasAppInit;
|
|
@@ -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
|
|
@@ -61,6 +61,7 @@ function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderCon
|
|
|
61
61
|
}),
|
|
62
62
|
html: htmlConfig,
|
|
63
63
|
output: _objectSpreadProps(_objectSpread({}, resolveConfig.output), {
|
|
64
|
+
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
64
65
|
cleanDistPath: false
|
|
65
66
|
})
|
|
66
67
|
});
|
|
@@ -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
|
}
|
|
@@ -7,6 +7,9 @@ function createCopyPattern(appContext, config, patternsType, chain) {
|
|
|
7
7
|
var minifiedJsRexExp = /\.min\.js/;
|
|
8
8
|
var info = function(file) {
|
|
9
9
|
return {
|
|
10
|
+
// If the file name ends with `.min.js`, we assume it's a compressed file.
|
|
11
|
+
// So we don't want copy-webpack-plugin to minify it.
|
|
12
|
+
// ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
|
|
10
13
|
minimized: minifiedJsRexExp.test(file.sourceFilename)
|
|
11
14
|
};
|
|
12
15
|
};
|
|
@@ -20,6 +23,7 @@ function createCopyPattern(appContext, config, patternsType, chain) {
|
|
|
20
23
|
to: "public",
|
|
21
24
|
context: publicDir,
|
|
22
25
|
noErrorOnMissing: true,
|
|
26
|
+
// eslint-disable-next-line node/prefer-global/buffer
|
|
23
27
|
transform: function(content, absoluteFrom) {
|
|
24
28
|
if (!/\.html?$/.test(absoluteFrom)) {
|
|
25
29
|
return content;
|
|
@@ -199,6 +199,7 @@ var build = function() {
|
|
|
199
199
|
return [
|
|
200
200
|
4,
|
|
201
201
|
hookRunners.beforeBuild({
|
|
202
|
+
// "null" bundlerConfigs
|
|
202
203
|
bundlerConfigs: void 0
|
|
203
204
|
})
|
|
204
205
|
];
|
|
@@ -223,6 +224,7 @@ var build = function() {
|
|
|
223
224
|
return [
|
|
224
225
|
4,
|
|
225
226
|
hookRunners.afterBuild({
|
|
227
|
+
// "null" stats
|
|
226
228
|
stats: void 0
|
|
227
229
|
})
|
|
228
230
|
];
|
package/dist/esm/commands/dev.js
CHANGED
|
@@ -175,6 +175,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
import { ResolvedConfigContext } from "@modern-js/core";
|
|
178
|
+
import { DEFAULT_DEV_HOST } from "@modern-js/utils";
|
|
178
179
|
import { printInstructions } from "../utils/printInstructions";
|
|
179
180
|
import { setServer, createServer, injectDataLoaderPlugin } from "../utils/createServer";
|
|
180
181
|
import { generateRoutes } from "../utils/routes";
|
|
@@ -182,7 +183,7 @@ import { buildServerConfig } from "../utils/config";
|
|
|
182
183
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
183
184
|
var dev = function() {
|
|
184
185
|
var _ref = _asyncToGenerator(function(api, options) {
|
|
185
|
-
var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, app, server;
|
|
186
|
+
var _normalizedConfig_tools, normalizedConfig, appContext, hookRunners, appDirectory, distDirectory, port, apiOnly, serverConfigFile, serverInternalPlugins, serverOptions, _normalizedConfig_dev, app, host, server;
|
|
186
187
|
return __generator(this, function(_state) {
|
|
187
188
|
switch(_state.label){
|
|
188
189
|
case 0:
|
|
@@ -236,14 +237,9 @@ var dev = function() {
|
|
|
236
237
|
serverOptions = {
|
|
237
238
|
dev: _objectSpread({
|
|
238
239
|
port: port,
|
|
239
|
-
https: normalizedConfig.dev.https
|
|
240
|
+
https: normalizedConfig.dev.https,
|
|
241
|
+
host: normalizedConfig.dev.host
|
|
240
242
|
}, (_normalizedConfig_tools = normalizedConfig.tools) === null || _normalizedConfig_tools === void 0 ? void 0 : _normalizedConfig_tools.devServer),
|
|
241
|
-
appContext: {
|
|
242
|
-
appDirectory: appContext.appDirectory,
|
|
243
|
-
sharedDirectory: appContext.sharedDirectory,
|
|
244
|
-
apiDirectory: appContext.apiDirectory,
|
|
245
|
-
lambdaDirectory: appContext.lambdaDirectory
|
|
246
|
-
},
|
|
247
243
|
pwd: appDirectory,
|
|
248
244
|
config: normalizedConfig,
|
|
249
245
|
serverConfigFile: serverConfigFile,
|
|
@@ -261,7 +257,11 @@ var dev = function() {
|
|
|
261
257
|
];
|
|
262
258
|
case 5:
|
|
263
259
|
app = _state.sent();
|
|
264
|
-
|
|
260
|
+
host = ((_normalizedConfig_dev = normalizedConfig.dev) === null || _normalizedConfig_dev === void 0 ? void 0 : _normalizedConfig_dev.host) || DEFAULT_DEV_HOST;
|
|
261
|
+
app.listen({
|
|
262
|
+
port: port,
|
|
263
|
+
host: host
|
|
264
|
+
}, function() {
|
|
265
265
|
var _ref = _asyncToGenerator(function(err) {
|
|
266
266
|
return __generator(this, function(_state) {
|
|
267
267
|
if (err) {
|
|
@@ -122,7 +122,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
import { logger, chalk, isApiOnly
|
|
125
|
+
import { logger, chalk, isApiOnly } from "@modern-js/utils";
|
|
126
126
|
import server from "@modern-js/prod-server";
|
|
127
127
|
import { printInstructions } from "../utils/printInstructions";
|
|
128
128
|
import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
@@ -155,11 +155,6 @@ var start = function() {
|
|
|
155
155
|
server({
|
|
156
156
|
pwd: appDirectory,
|
|
157
157
|
config: userConfig,
|
|
158
|
-
appContext: {
|
|
159
|
-
sharedDirectory: getTargetDir(appContext.sharedDirectory, appContext.appDirectory, appContext.distDirectory),
|
|
160
|
-
apiDirectory: getTargetDir(appContext.apiDirectory, appContext.appDirectory, appContext.distDirectory),
|
|
161
|
-
lambdaDirectory: getTargetDir(appContext.lambdaDirectory, appContext.appDirectory, appContext.distDirectory)
|
|
162
|
-
},
|
|
163
158
|
serverConfigFile: serverConfigFile,
|
|
164
159
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins),
|
|
165
160
|
apiOnly: apiOnly
|
|
@@ -54,6 +54,8 @@ import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/bu
|
|
|
54
54
|
function createDefaultConfig(appContext, bundler) {
|
|
55
55
|
var defaultBuilderConfig = createDefaultBuilderConfig();
|
|
56
56
|
var dev = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.dev), {
|
|
57
|
+
// `dev.port` should not have a default value
|
|
58
|
+
// because we will use `server.port` by default
|
|
57
59
|
port: void 0
|
|
58
60
|
});
|
|
59
61
|
var output = _objectSpreadProps(_objectSpread({}, defaultBuilderConfig.output), {
|
|
@@ -8,6 +8,7 @@ function createOutputConfig(config) {
|
|
|
8
8
|
css: cssPath,
|
|
9
9
|
js: jsPath,
|
|
10
10
|
html: htmlPath,
|
|
11
|
+
// modern.js v1 output all media files to `dist/media` by default
|
|
11
12
|
svg: mediaPath || "media",
|
|
12
13
|
image: mediaPath || "media",
|
|
13
14
|
font: mediaPath || "media",
|
|
@@ -33,6 +34,7 @@ function createOutputConfig(config) {
|
|
|
33
34
|
disableFilenameHash: disableAssetsCache,
|
|
34
35
|
enableLatestDecorators: enableLatestDecorators,
|
|
35
36
|
ssg: ssg,
|
|
37
|
+
// set `true`, only in legacy config
|
|
36
38
|
enableAssetFallback: true,
|
|
37
39
|
enableAssetManifest: true,
|
|
38
40
|
disableNodePolyfill: disableNodePolyfill
|
package/dist/esm/index.js
CHANGED
|
@@ -653,7 +653,8 @@ var src_default = function() {
|
|
|
653
653
|
});
|
|
654
654
|
})();
|
|
655
655
|
},
|
|
656
|
-
fileChange:
|
|
656
|
+
fileChange: // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
|
657
|
+
function fileChange(e) {
|
|
657
658
|
return _asyncToGenerator(function() {
|
|
658
659
|
var filename, eventType, appContext, appDirectory, srcDirectory, absolutePath, closeServer;
|
|
659
660
|
return __generator(this, function(_state) {
|
|
@@ -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)) {
|
|
@@ -209,6 +209,7 @@ var analyze_default = ({
|
|
|
209
209
|
resolved: config
|
|
210
210
|
};
|
|
211
211
|
},
|
|
212
|
+
// This logic is not in the router plugin to avoid having to include some dependencies in the utils package
|
|
212
213
|
async modifyEntryImports({ entrypoint, imports }) {
|
|
213
214
|
const appContext = api.useAppContext();
|
|
214
215
|
const { srcDirectory, internalSrcAlias } = appContext;
|
|
@@ -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
|
};
|