@modern-js/app-tools 2.4.0 → 2.5.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 +59 -0
- package/dist/{js/node → cjs}/analyze/constants.js +0 -0
- package/dist/cjs/analyze/generateCode.js +249 -0
- package/dist/{js/node → cjs}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutes.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/getRoutesLegacy.js +1 -18
- package/dist/{js/node → cjs}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/node → cjs}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/node → cjs}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/node → cjs}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/node → cjs}/analyze/getServerRoutes.js +22 -42
- package/dist/cjs/analyze/index.js +290 -0
- package/dist/{js/node → cjs}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/node → cjs}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/node → cjs}/analyze/nestedRoutes.js +16 -50
- package/dist/{js/node → cjs}/analyze/templates.js +16 -49
- package/dist/{js/node → cjs}/analyze/utils.js +9 -29
- package/dist/{js/node → cjs}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/node → cjs}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
- package/dist/{js/node → cjs}/builder/builder-webpack/index.js +22 -62
- package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
- package/dist/{js/node → cjs}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/node → cjs}/builder/generator/createBuilderOptions.js +0 -0
- package/dist/{js/node → cjs}/builder/generator/createBuilderProviderConfig.js +14 -25
- package/dist/{js/node → cjs}/builder/generator/getBuilderTargets.js +4 -0
- package/dist/cjs/builder/generator/index.js +58 -0
- package/dist/{js/node → cjs}/builder/index.js +12 -34
- package/dist/{js/node → cjs}/builder/shared/builderPlugins/adapterModern.js +35 -34
- package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/index.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/node → cjs}/builder/shared/types.js +0 -0
- package/dist/{js/node → cjs}/commands/build.js +9 -46
- package/dist/cjs/commands/deploy.js +31 -0
- package/dist/{js/node → cjs}/commands/dev.js +17 -52
- package/dist/{js/node → cjs}/commands/index.js +0 -0
- package/dist/{js/node → cjs}/commands/inspect.js +2 -22
- package/dist/{js/node → cjs}/commands/serve.js +8 -28
- package/dist/{js/node → cjs}/config/default.js +15 -26
- package/dist/{js/node → cjs}/config/index.js +0 -0
- package/dist/{js/node → cjs}/config/initialize/index.js +0 -0
- package/dist/{js/node → cjs}/config/initialize/inits.js +4 -20
- package/dist/{js/node → cjs}/config/legacy/createHtmlConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createOutputConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createSourceConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/createToolsConfig.js +0 -0
- package/dist/{js/node → cjs}/config/legacy/index.js +0 -0
- package/dist/cjs/defineConfig.js +33 -0
- package/dist/{js/node → cjs}/exports/server.js +0 -0
- package/dist/{js/node → cjs}/hooks.js +0 -0
- package/dist/cjs/index.js +198 -0
- package/dist/cjs/initialize/index.js +102 -0
- package/dist/{js/node → cjs}/locale/en.js +0 -0
- package/dist/{js/node → cjs}/locale/index.js +0 -0
- package/dist/{js/node → cjs}/locale/zh.js +0 -0
- package/dist/{js/node → cjs}/schema/Schema.js +0 -0
- package/dist/{js/node → cjs}/schema/index.js +0 -0
- package/dist/{js/node → cjs}/schema/legacy.js +0 -0
- package/dist/{js/node → cjs}/types/config/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/config/dev.js +0 -0
- package/dist/{js/node → cjs}/types/config/experiments.js +0 -0
- package/dist/{js/node → cjs}/types/config/html.js +0 -0
- package/dist/{js/node → cjs}/types/config/index.js +0 -0
- package/dist/{js/node → cjs}/types/config/output.js +0 -0
- package/dist/{js/node → cjs}/types/config/performance.js +0 -0
- package/dist/{js/node → cjs}/types/config/security.js +0 -0
- package/dist/{js/node → cjs}/types/config/source.js +0 -0
- package/dist/{js/node → cjs}/types/config/tools.js +0 -0
- package/dist/{js/node → cjs}/types/hooks.js +0 -0
- package/dist/{js/node → cjs}/types/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/index.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/output.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/source.js +0 -0
- package/dist/{js/node → cjs}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/node → cjs}/types/utils.js +0 -0
- package/dist/{js/node → cjs}/utils/config.js +19 -57
- package/dist/{js/node → cjs}/utils/createServer.js +10 -46
- package/dist/{js/node → cjs}/utils/env.js +0 -0
- package/dist/{js/node → cjs}/utils/generateWatchFiles.js +16 -38
- package/dist/{js/node → cjs}/utils/getSelectedEntries.js +3 -23
- package/dist/cjs/utils/getServerInternalPlugins.js +41 -0
- package/dist/{js/node → cjs}/utils/language.js +0 -0
- package/dist/{js/node → cjs}/utils/printInstructions.js +3 -23
- package/dist/cjs/utils/restart.js +45 -0
- package/dist/{js/node → cjs}/utils/routes.js +3 -23
- package/dist/{js/node → cjs}/utils/types.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/constants.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/generateCode.js +14 -14
- package/dist/{js/treeshaking → esm}/analyze/getBundleEntry.js +4 -2
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getFileSystemEntry.js +1 -1
- package/dist/{js/treeshaking → esm}/analyze/getHtmlTemplate.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/getServerRoutes.js +8 -6
- package/dist/{js/treeshaking → esm}/analyze/index.js +8 -8
- package/dist/{js/treeshaking → esm}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/treeshaking → esm}/analyze/nestedRoutes.js +5 -5
- package/dist/{js/treeshaking → esm}/analyze/templates.js +8 -7
- package/dist/{js/treeshaking → esm}/analyze/utils.js +3 -3
- package/dist/{js/treeshaking → esm}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/builderPlugins/compatModern.js +4 -4
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/index.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +5 -2
- package/dist/{js/treeshaking → esm}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/generator/createBuilderOptions.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/generator/createBuilderProviderConfig.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/generator/getBuilderTargets.js +5 -1
- package/dist/{js/treeshaking → esm}/builder/generator/index.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/builderPlugins/adapterModern.js +62 -13
- package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -2
- package/dist/{js/treeshaking → esm}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/index.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/treeshaking → esm}/builder/shared/types.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/build.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/dev.js +2 -2
- package/dist/{js/treeshaking → esm}/commands/index.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/inspect.js +0 -0
- package/dist/{js/treeshaking → esm}/commands/serve.js +2 -2
- package/dist/{js/treeshaking → esm}/config/default.js +0 -0
- package/dist/{js/treeshaking → esm}/config/index.js +0 -0
- package/dist/{js/treeshaking → esm}/config/initialize/index.js +0 -0
- package/dist/{js/treeshaking → esm}/config/initialize/inits.js +2 -2
- package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
- package/dist/{js/treeshaking → esm}/config/legacy/createOutputConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/createSourceConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/createToolsConfig.js +1 -1
- package/dist/{js/treeshaking → esm}/config/legacy/index.js +0 -0
- package/dist/{js/treeshaking → esm}/defineConfig.js +0 -0
- package/dist/{js/treeshaking → esm}/exports/server.js +0 -0
- package/dist/{js/treeshaking → esm}/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/index.js +0 -0
- package/dist/{js/treeshaking → esm}/initialize/index.js +2 -2
- package/dist/{js/treeshaking → esm}/locale/en.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/index.js +0 -0
- package/dist/{js/treeshaking → esm}/locale/zh.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/Schema.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/index.js +0 -0
- package/dist/{js/treeshaking → esm}/schema/legacy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/experiments.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/html.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/performance.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/security.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/config/tools.js +0 -0
- package/dist/{js/treeshaking → esm}/types/hooks.js +0 -0
- package/dist/{js/treeshaking → esm}/types/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/index.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/output.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/source.js +0 -0
- package/dist/{js/treeshaking → esm}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/treeshaking → esm}/types/utils.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/config.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/createServer.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/env.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/generateWatchFiles.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getSelectedEntries.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/getServerInternalPlugins.js +2 -2
- package/dist/{js/treeshaking → esm}/utils/language.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/printInstructions.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/restart.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/routes.js +0 -0
- package/dist/{js/treeshaking → esm}/utils/types.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/constants.js +0 -0
- package/dist/esm-node/analyze/generateCode.js +225 -0
- package/dist/{js/modern → esm-node}/analyze/getBundleEntry.js +6 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutes.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/getRoutesLegacy.js +1 -20
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/index.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getClientRoutes/utils.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getFileSystemEntry.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/getHtmlTemplate.js +4 -24
- package/dist/{js/modern → esm-node}/analyze/getServerRoutes.js +24 -45
- package/dist/esm-node/analyze/index.js +281 -0
- package/dist/{js/modern → esm-node}/analyze/isDefaultExportFunction.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/makeLegalIdentifier.js +0 -0
- package/dist/{js/modern → esm-node}/analyze/nestedRoutes.js +16 -52
- package/dist/{js/modern → esm-node}/analyze/templates.js +16 -51
- package/dist/{js/modern → esm-node}/analyze/utils.js +9 -29
- package/dist/{js/modern → esm-node}/builder/builder-rspack/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/builder-webpack/builderPlugins/compatModern.js +0 -0
- package/dist/esm-node/builder/builder-webpack/index.js +51 -0
- package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/RouterPlugin.js +7 -24
- package/dist/{js/modern → esm-node}/builder/builder-webpack/webpackPlugins/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/generator/createBuilderOptions.js +0 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
- package/dist/{js/modern → esm-node}/builder/generator/getBuilderTargets.js +10 -1
- package/dist/esm-node/builder/generator/index.js +29 -0
- package/dist/esm-node/builder/index.js +17 -0
- package/dist/{js/modern → esm-node}/builder/shared/builderPlugins/adapterModern.js +35 -36
- package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/createCopyPattern.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/index.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/modern → esm-node}/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +52 -0
- package/dist/esm-node/commands/deploy.js +8 -0
- package/dist/esm-node/commands/dev.js +72 -0
- package/dist/{js/modern → esm-node}/commands/index.js +0 -0
- package/dist/esm-node/commands/inspect.js +18 -0
- package/dist/{js/modern → esm-node}/commands/serve.js +8 -28
- package/dist/{js/modern → esm-node}/config/default.js +15 -28
- package/dist/{js/modern → esm-node}/config/index.js +0 -0
- package/dist/{js/modern → esm-node}/config/initialize/index.js +0 -0
- package/dist/{js/modern → esm-node}/config/initialize/inits.js +4 -22
- package/dist/{js/modern → esm-node}/config/legacy/createHtmlConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createOutputConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createSourceConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/createToolsConfig.js +0 -0
- package/dist/{js/modern → esm-node}/config/legacy/index.js +0 -0
- package/dist/esm-node/defineConfig.js +9 -0
- package/dist/{js/modern → esm-node}/exports/server.js +0 -0
- package/dist/{js/modern → esm-node}/hooks.js +0 -0
- package/dist/esm-node/index.js +172 -0
- package/dist/esm-node/initialize/index.js +91 -0
- package/dist/{js/modern → esm-node}/locale/en.js +0 -0
- package/dist/{js/modern → esm-node}/locale/index.js +0 -0
- package/dist/{js/modern → esm-node}/locale/zh.js +0 -0
- package/dist/{js/modern → esm-node}/schema/Schema.js +0 -0
- package/dist/{js/modern → esm-node}/schema/index.js +0 -0
- package/dist/{js/modern → esm-node}/schema/legacy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/experiments.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/html.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/performance.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/security.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/source.js +0 -0
- package/dist/{js/modern → esm-node}/types/config/tools.js +0 -0
- package/dist/{js/modern → esm-node}/types/hooks.js +0 -0
- package/dist/{js/modern → esm-node}/types/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/deploy.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/dev.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/index.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/output.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/source.js +0 -0
- package/dist/{js/modern → esm-node}/types/legacyConfig/tools.js +0 -0
- package/dist/{js/modern → esm-node}/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +88 -0
- package/dist/esm-node/utils/createServer.js +37 -0
- package/dist/{js/modern → esm-node}/utils/env.js +0 -0
- package/dist/esm-node/utils/generateWatchFiles.js +33 -0
- package/dist/{js/modern → esm-node}/utils/getSelectedEntries.js +3 -23
- package/dist/esm-node/utils/getServerInternalPlugins.js +18 -0
- package/dist/{js/modern → esm-node}/utils/language.js +0 -0
- package/dist/esm-node/utils/printInstructions.js +11 -0
- package/dist/esm-node/utils/restart.js +22 -0
- package/dist/esm-node/utils/routes.js +10 -0
- package/dist/{js/modern → esm-node}/utils/types.js +0 -0
- package/dist/types/types/config/tools.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +5 -4
- package/dist/types/types/index.d.ts +3 -1
- package/package.json +30 -31
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/index.js +0 -329
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/index.js +0 -39
- 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/inspect.js +0 -38
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/index.js +0 -221
- package/dist/js/modern/initialize/index.js +0 -132
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- 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/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/index.js +0 -336
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/index.js +0 -245
- package/dist/js/node/initialize/index.js +0 -141
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
|
File without changes
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import lintPlugin from "@modern-js/plugin-lint";
|
|
3
|
+
import {
|
|
4
|
+
cleanRequireCache,
|
|
5
|
+
emptyDir,
|
|
6
|
+
Import,
|
|
7
|
+
getCommand
|
|
8
|
+
} from "@modern-js/utils";
|
|
9
|
+
import { castArray } from "@modern-js/utils/lodash";
|
|
10
|
+
import analyzePlugin from "./analyze";
|
|
11
|
+
import initializePlugin from "./initialize";
|
|
12
|
+
import { hooks } from "./hooks";
|
|
13
|
+
import { i18n, localeKeys } from "./locale";
|
|
14
|
+
import { getLocaleLanguage } from "./utils/language";
|
|
15
|
+
import { restart } from "./utils/restart";
|
|
16
|
+
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
|
17
|
+
export * from "./defineConfig";
|
|
18
|
+
export * from "./types";
|
|
19
|
+
const upgradeModel = Import.lazy(
|
|
20
|
+
"@modern-js/upgrade",
|
|
21
|
+
require
|
|
22
|
+
);
|
|
23
|
+
const devCommand = async (program, api) => {
|
|
24
|
+
const runner = api.useHookRunners();
|
|
25
|
+
const devToolMetas = await runner.registerDev();
|
|
26
|
+
const devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).action(async (options) => {
|
|
27
|
+
const { dev } = await import("./commands/dev");
|
|
28
|
+
await dev(api, options);
|
|
29
|
+
});
|
|
30
|
+
for (const meta of devToolMetas) {
|
|
31
|
+
if (!meta.subCommands) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
for (const subCmd of meta.subCommands) {
|
|
35
|
+
devProgram.command(subCmd).action(async (options = {}) => {
|
|
36
|
+
const { appDirectory } = api.useAppContext();
|
|
37
|
+
const { isTypescript } = await import("@modern-js/utils");
|
|
38
|
+
await runner.beforeDevTask(meta);
|
|
39
|
+
await meta.action(options, {
|
|
40
|
+
isTsProject: isTypescript(appDirectory)
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const buildCommand = async (program, api) => {
|
|
47
|
+
const runner = api.useHookRunners();
|
|
48
|
+
const platformBuilders = await runner.registerBuildPlatform();
|
|
49
|
+
const buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(async (options) => {
|
|
50
|
+
const { build } = await import("./commands/build");
|
|
51
|
+
await build(api, options);
|
|
52
|
+
});
|
|
53
|
+
for (const platformBuilder of platformBuilders) {
|
|
54
|
+
const platforms = castArray(platformBuilder.platform);
|
|
55
|
+
for (const platform of platforms) {
|
|
56
|
+
buildProgram.command(platform).action(async () => {
|
|
57
|
+
const { appDirectory } = api.useAppContext();
|
|
58
|
+
const { isTypescript } = await import("@modern-js/utils");
|
|
59
|
+
await runner.beforeBuildPlatform(platformBuilders);
|
|
60
|
+
await platformBuilder.build(platform, {
|
|
61
|
+
isTsProject: isTypescript(appDirectory)
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var src_default = (options = {
|
|
68
|
+
bundler: "webpack"
|
|
69
|
+
}) => ({
|
|
70
|
+
name: "@modern-js/app-tools",
|
|
71
|
+
post: [
|
|
72
|
+
"@modern-js/plugin-initialize",
|
|
73
|
+
"@modern-js/plugin-analyze",
|
|
74
|
+
"@modern-js/plugin-ssr",
|
|
75
|
+
"@modern-js/plugin-document",
|
|
76
|
+
"@modern-js/plugin-state",
|
|
77
|
+
"@modern-js/plugin-router",
|
|
78
|
+
"@modern-js/plugin-router-v5",
|
|
79
|
+
"@modern-js/plugin-polyfill"
|
|
80
|
+
],
|
|
81
|
+
registerHook: hooks,
|
|
82
|
+
usePlugins: [
|
|
83
|
+
initializePlugin({
|
|
84
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
85
|
+
}),
|
|
86
|
+
analyzePlugin({
|
|
87
|
+
bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
|
88
|
+
}),
|
|
89
|
+
lintPlugin()
|
|
90
|
+
],
|
|
91
|
+
setup: (api) => {
|
|
92
|
+
const locale = getLocaleLanguage();
|
|
93
|
+
i18n.changeLanguage({ locale });
|
|
94
|
+
return {
|
|
95
|
+
async commands({ program }) {
|
|
96
|
+
await devCommand(program, api);
|
|
97
|
+
await buildCommand(program, api);
|
|
98
|
+
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option(
|
|
99
|
+
"-c --config <config>",
|
|
100
|
+
i18n.t(localeKeys.command.shared.config)
|
|
101
|
+
).action(async () => {
|
|
102
|
+
const { start } = await import("./commands/serve");
|
|
103
|
+
await start(api);
|
|
104
|
+
});
|
|
105
|
+
program.command("deploy").usage("[options]").option(
|
|
106
|
+
"-c --config <config>",
|
|
107
|
+
i18n.t(localeKeys.command.shared.config)
|
|
108
|
+
).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
|
|
109
|
+
const { build } = await import("./commands/build");
|
|
110
|
+
await build(api);
|
|
111
|
+
const { deploy } = await import("./commands/deploy");
|
|
112
|
+
await deploy(api, options2);
|
|
113
|
+
process.exit(0);
|
|
114
|
+
});
|
|
115
|
+
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option(
|
|
116
|
+
"-c, --config <config>",
|
|
117
|
+
i18n.t(localeKeys.command.new.config)
|
|
118
|
+
).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action(async (options2) => {
|
|
119
|
+
const { MWANewAction } = await import("@modern-js/new-action");
|
|
120
|
+
await MWANewAction({ ...options2, locale: options2.lang || locale });
|
|
121
|
+
});
|
|
122
|
+
program.command("inspect").description("inspect internal webpack config").option(
|
|
123
|
+
`--env <env>`,
|
|
124
|
+
i18n.t(localeKeys.command.inspect.env),
|
|
125
|
+
"development"
|
|
126
|
+
).option(
|
|
127
|
+
"--output <output>",
|
|
128
|
+
i18n.t(localeKeys.command.inspect.output),
|
|
129
|
+
"/"
|
|
130
|
+
).option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option(
|
|
131
|
+
"-c --config <config>",
|
|
132
|
+
i18n.t(localeKeys.command.shared.config)
|
|
133
|
+
).action(async (options2) => {
|
|
134
|
+
const { inspect } = await import("./commands/inspect");
|
|
135
|
+
inspect(api, options2);
|
|
136
|
+
});
|
|
137
|
+
upgradeModel.defineCommand(program.command("upgrade"));
|
|
138
|
+
},
|
|
139
|
+
async prepare() {
|
|
140
|
+
const command = getCommand();
|
|
141
|
+
if (command === "dev" || command === "start" || command === "build") {
|
|
142
|
+
const appContext = api.useAppContext();
|
|
143
|
+
await emptyDir(appContext.distDirectory);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
async watchFiles() {
|
|
147
|
+
const appContext = api.useAppContext();
|
|
148
|
+
const config = api.useResolvedConfigContext();
|
|
149
|
+
return generateWatchFiles(appContext, config.source.configDir);
|
|
150
|
+
},
|
|
151
|
+
async fileChange(e) {
|
|
152
|
+
const { filename, eventType } = e;
|
|
153
|
+
const appContext = api.useAppContext();
|
|
154
|
+
const { appDirectory, srcDirectory } = appContext;
|
|
155
|
+
const absolutePath = path.resolve(appDirectory, filename);
|
|
156
|
+
if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
|
|
157
|
+
const { closeServer } = await import("./utils/createServer");
|
|
158
|
+
await closeServer();
|
|
159
|
+
await restart(api.useHookRunners(), filename);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
async beforeRestart() {
|
|
163
|
+
cleanRequireCache([require.resolve("./analyze")]);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export {
|
|
169
|
+
buildCommand,
|
|
170
|
+
src_default as default,
|
|
171
|
+
devCommand
|
|
172
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureAbsolutePath,
|
|
3
|
+
getPort,
|
|
4
|
+
isDev,
|
|
5
|
+
isDevCommand
|
|
6
|
+
} from "@modern-js/utils";
|
|
7
|
+
import { legacySchema, schema } from "../schema";
|
|
8
|
+
import {
|
|
9
|
+
checkIsLegacyConfig,
|
|
10
|
+
createDefaultConfig,
|
|
11
|
+
createLegacyDefaultConfig,
|
|
12
|
+
transformNormalizedConfig
|
|
13
|
+
} from "../config";
|
|
14
|
+
var initialize_default = ({
|
|
15
|
+
bundler
|
|
16
|
+
}) => ({
|
|
17
|
+
name: "@modern-js/plugin-initialize",
|
|
18
|
+
setup(api) {
|
|
19
|
+
const config = () => {
|
|
20
|
+
const appContext = api.useAppContext();
|
|
21
|
+
const userConfig = api.useConfigContext();
|
|
22
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
|
23
|
+
};
|
|
24
|
+
const validateSchema = () => {
|
|
25
|
+
const userConfig = api.useConfigContext();
|
|
26
|
+
const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
|
27
|
+
return schemas.generate();
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
config,
|
|
31
|
+
validateSchema,
|
|
32
|
+
async resolvedConfig({ resolved }) {
|
|
33
|
+
var _a;
|
|
34
|
+
let appContext = api.useAppContext();
|
|
35
|
+
const userConfig = api.useConfigContext();
|
|
36
|
+
const port = await getServerPort(resolved);
|
|
37
|
+
appContext = {
|
|
38
|
+
...appContext,
|
|
39
|
+
port,
|
|
40
|
+
distDirectory: ensureAbsolutePath(
|
|
41
|
+
appContext.distDirectory,
|
|
42
|
+
((_a = resolved.output.distPath) == null ? void 0 : _a.root) || "dist"
|
|
43
|
+
)
|
|
44
|
+
};
|
|
45
|
+
api.setAppContext(appContext);
|
|
46
|
+
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
47
|
+
resolved._raw = userConfig;
|
|
48
|
+
resolved.server = {
|
|
49
|
+
...normalizedConfig.server || {},
|
|
50
|
+
port
|
|
51
|
+
};
|
|
52
|
+
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
|
|
53
|
+
stabilizeConfig(resolved, normalizedConfig, [
|
|
54
|
+
"source",
|
|
55
|
+
"bff",
|
|
56
|
+
"dev",
|
|
57
|
+
"html",
|
|
58
|
+
"output",
|
|
59
|
+
"tools",
|
|
60
|
+
"testing",
|
|
61
|
+
"plugins",
|
|
62
|
+
"builderPlugins",
|
|
63
|
+
"runtime",
|
|
64
|
+
"runtimeByEntries",
|
|
65
|
+
"deploy",
|
|
66
|
+
"performance"
|
|
67
|
+
]);
|
|
68
|
+
if (bundler === "webpack") {
|
|
69
|
+
resolved.security = normalizedConfig.security || {};
|
|
70
|
+
resolved.experiments = normalizedConfig.experiments;
|
|
71
|
+
}
|
|
72
|
+
return { resolved };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
function stabilizeConfig(resolve, config, keys) {
|
|
78
|
+
keys.forEach((key) => {
|
|
79
|
+
resolve[key] = config[key] || {};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function getServerPort(config) {
|
|
83
|
+
const prodPort = config.server.port || 8080;
|
|
84
|
+
if (isDev() && isDevCommand()) {
|
|
85
|
+
return getPort(config.dev.port || prodPort);
|
|
86
|
+
}
|
|
87
|
+
return prodPort;
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
initialize_default as default
|
|
91
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { bundle } from "@modern-js/node-bundle-require";
|
|
3
|
+
import {
|
|
4
|
+
CONFIG_FILE_EXTENSIONS,
|
|
5
|
+
fs,
|
|
6
|
+
getServerConfig,
|
|
7
|
+
OUTPUT_CONFIG_FILE
|
|
8
|
+
} from "@modern-js/utils";
|
|
9
|
+
const defineServerConfig = (config) => config;
|
|
10
|
+
const buildServerConfig = async ({
|
|
11
|
+
appDirectory,
|
|
12
|
+
distDirectory,
|
|
13
|
+
configFile,
|
|
14
|
+
options
|
|
15
|
+
}) => {
|
|
16
|
+
const configFilePath = await getServerConfig(appDirectory, configFile);
|
|
17
|
+
const getOutputFile = async (filepath) => path.resolve(
|
|
18
|
+
distDirectory,
|
|
19
|
+
`${filepath.replace(
|
|
20
|
+
new RegExp(CONFIG_FILE_EXTENSIONS.join("|")),
|
|
21
|
+
""
|
|
22
|
+
)}.js`
|
|
23
|
+
);
|
|
24
|
+
if (configFilePath) {
|
|
25
|
+
const configHelperFilePath = path.normalize(
|
|
26
|
+
path.join(distDirectory, "./config-helper.js")
|
|
27
|
+
);
|
|
28
|
+
const helperCode = `
|
|
29
|
+
export const defineConfig = (config) => config;
|
|
30
|
+
`;
|
|
31
|
+
await fs.ensureDir(distDirectory);
|
|
32
|
+
await fs.writeFile(configHelperFilePath, helperCode);
|
|
33
|
+
await bundle(configFilePath, {
|
|
34
|
+
...options,
|
|
35
|
+
getOutputFile,
|
|
36
|
+
esbuildPlugins: [
|
|
37
|
+
{
|
|
38
|
+
name: "native-build-config",
|
|
39
|
+
setup(ctx) {
|
|
40
|
+
ctx.onResolve(
|
|
41
|
+
{
|
|
42
|
+
filter: /app-tools\/server/
|
|
43
|
+
},
|
|
44
|
+
() => {
|
|
45
|
+
return {
|
|
46
|
+
path: configHelperFilePath
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const safeReplacer = () => {
|
|
57
|
+
const cache = [];
|
|
58
|
+
const keyCache = [];
|
|
59
|
+
return function(key, value) {
|
|
60
|
+
if (typeof value === "object" && value !== null) {
|
|
61
|
+
const index = cache.indexOf(value);
|
|
62
|
+
if (index !== -1) {
|
|
63
|
+
return `[Circular ${keyCache[index]}]`;
|
|
64
|
+
}
|
|
65
|
+
cache.push(value);
|
|
66
|
+
keyCache.push(key || "root");
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const outputPath = path.join(
|
|
74
|
+
appDirectory,
|
|
75
|
+
((_a = resolvedConfig.output.distPath) == null ? void 0 : _a.root) || "./dist",
|
|
76
|
+
OUTPUT_CONFIG_FILE
|
|
77
|
+
);
|
|
78
|
+
await fs.writeJSON(outputPath, resolvedConfig, {
|
|
79
|
+
spaces: 2,
|
|
80
|
+
replacer: safeReplacer()
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
buildServerConfig,
|
|
85
|
+
defineServerConfig,
|
|
86
|
+
emitResolvedConfig,
|
|
87
|
+
safeReplacer
|
|
88
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Server } from "@modern-js/server";
|
|
2
|
+
let server = null;
|
|
3
|
+
const getServer = () => server;
|
|
4
|
+
const setServer = (newServer) => {
|
|
5
|
+
server = newServer;
|
|
6
|
+
};
|
|
7
|
+
const closeServer = async () => {
|
|
8
|
+
if (server) {
|
|
9
|
+
await server.close();
|
|
10
|
+
server = null;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const createServer = async (options) => {
|
|
14
|
+
if (server) {
|
|
15
|
+
await server.close();
|
|
16
|
+
}
|
|
17
|
+
server = new Server(options);
|
|
18
|
+
const app = await server.init();
|
|
19
|
+
return app;
|
|
20
|
+
};
|
|
21
|
+
const injectDataLoaderPlugin = (internalPlugins) => {
|
|
22
|
+
const DataLoaderPlugin = require.resolve("@modern-js/plugin-data-loader/server");
|
|
23
|
+
return {
|
|
24
|
+
...internalPlugins,
|
|
25
|
+
"@modern-js/plugin-data-loader": {
|
|
26
|
+
path: DataLoaderPlugin,
|
|
27
|
+
forced: true
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
closeServer,
|
|
33
|
+
createServer,
|
|
34
|
+
getServer,
|
|
35
|
+
injectDataLoaderPlugin,
|
|
36
|
+
setServer
|
|
37
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fs, getServerConfig } from "@modern-js/utils";
|
|
3
|
+
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
4
|
+
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
5
|
+
const json = JSON.parse(
|
|
6
|
+
fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8")
|
|
7
|
+
);
|
|
8
|
+
return json[packageJsonConfig != null ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
|
9
|
+
};
|
|
10
|
+
const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
|
|
11
|
+
const serverConfig = await getServerConfig(appDirectory, serverConfigFile);
|
|
12
|
+
if (serverConfig) {
|
|
13
|
+
dependencies.push(serverConfig);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
async function generateWatchFiles(appContext, configDir) {
|
|
17
|
+
const { appDirectory, configFile } = appContext;
|
|
18
|
+
const configPath = path.join(appDirectory, configDir || "");
|
|
19
|
+
const dependencies = getPackageConfig(
|
|
20
|
+
appContext.appDirectory,
|
|
21
|
+
appContext.packageName
|
|
22
|
+
) ? [path.resolve(appDirectory, "./package.json")] : [];
|
|
23
|
+
await addServerConfigToDeps(
|
|
24
|
+
dependencies,
|
|
25
|
+
appContext.appDirectory,
|
|
26
|
+
appContext.serverConfigFile
|
|
27
|
+
);
|
|
28
|
+
return [`${configPath}/html`, configFile || "./config", ...dependencies];
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
addServerConfigToDeps,
|
|
32
|
+
generateWatchFiles
|
|
33
|
+
};
|
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
1
|
import { chalk, inquirer } from "@modern-js/utils";
|
|
22
2
|
import { i18n, localeKeys } from "../locale";
|
|
23
|
-
const getSelectedEntries = (entry, entrypoints) =>
|
|
3
|
+
const getSelectedEntries = async (entry, entrypoints) => {
|
|
24
4
|
const entryNames = entrypoints.map((e) => e.entryName);
|
|
25
5
|
if (!entry) {
|
|
26
6
|
return entryNames;
|
|
27
7
|
}
|
|
28
8
|
if (typeof entry === "boolean") {
|
|
29
|
-
const { selected } =
|
|
9
|
+
const { selected } = await inquirer.prompt([
|
|
30
10
|
{
|
|
31
11
|
type: "checkbox",
|
|
32
12
|
name: "selected",
|
|
@@ -52,7 +32,7 @@ const getSelectedEntries = (entry, entrypoints) => __async(void 0, null, functio
|
|
|
52
32
|
}
|
|
53
33
|
});
|
|
54
34
|
return entry;
|
|
55
|
-
}
|
|
35
|
+
};
|
|
56
36
|
export {
|
|
57
37
|
getSelectedEntries
|
|
58
38
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
async function getServerInternalPlugins(api) {
|
|
2
|
+
const hookRunners = api.useHookRunners();
|
|
3
|
+
const { plugins: serverPlugins } = await hookRunners.collectServerPlugins({
|
|
4
|
+
plugins: []
|
|
5
|
+
});
|
|
6
|
+
const serverInternalPlugins = serverPlugins.reduce(
|
|
7
|
+
(result, plugin) => Object.assign(result, plugin),
|
|
8
|
+
{}
|
|
9
|
+
);
|
|
10
|
+
api.setAppContext({
|
|
11
|
+
...api.useAppContext(),
|
|
12
|
+
serverInternalPlugins
|
|
13
|
+
});
|
|
14
|
+
return serverInternalPlugins;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getServerInternalPlugins
|
|
18
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { prettyInstructions, logger } from "@modern-js/utils";
|
|
2
|
+
const printInstructions = async (hookRunners, appContext, config) => {
|
|
3
|
+
const message = prettyInstructions(appContext, config);
|
|
4
|
+
const { instructions } = await hookRunners.beforePrintInstructions({
|
|
5
|
+
instructions: message
|
|
6
|
+
});
|
|
7
|
+
logger.info(instructions);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
printInstructions
|
|
11
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cli } from "@modern-js/core";
|
|
2
|
+
import { chalk, clearConsole, logger, program } from "@modern-js/utils";
|
|
3
|
+
async function restart(hooksRunner, filename) {
|
|
4
|
+
clearConsole();
|
|
5
|
+
logger.info(`Restart because ${chalk.yellow(filename)} is changed...
|
|
6
|
+
`);
|
|
7
|
+
let hasGetError = false;
|
|
8
|
+
await hooksRunner.beforeRestart();
|
|
9
|
+
try {
|
|
10
|
+
await cli.init(cli.getPrevInitOptions());
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(err);
|
|
13
|
+
hasGetError = true;
|
|
14
|
+
} finally {
|
|
15
|
+
if (!hasGetError) {
|
|
16
|
+
program.parse(process.argv);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
restart
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fs, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
|
3
|
+
const generateRoutes = async (appContext) => {
|
|
4
|
+
const { serverRoutes, distDirectory } = appContext;
|
|
5
|
+
const output = JSON.stringify({ routes: serverRoutes }, null, 2);
|
|
6
|
+
await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
generateRoutes
|
|
10
|
+
};
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ import type { UnwrapBuilderConfig } from '../utils';
|
|
|
8
8
|
export type BuilderToolsConfig = UnwrapBuilderConfig<BuilderConfig, 'tools'> & {
|
|
9
9
|
esbuild?: PluginEsbuildOptions;
|
|
10
10
|
};
|
|
11
|
-
export type RsBuilderToolsConfig = UnwrapBuilderConfig<RsBuilderConfig, '
|
|
11
|
+
export type RsBuilderToolsConfig = UnwrapBuilderConfig<RsBuilderConfig, 'tools'>;
|
|
12
12
|
/**
|
|
13
13
|
* The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
|
|
14
14
|
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
@@ -4,6 +4,7 @@ import type { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, Ser
|
|
|
4
4
|
import type { RegisterBuildPlatformResult, DevToolData } from '@modern-js/core';
|
|
5
5
|
import type { Stats, MultiStats } from '@modern-js/builder-shared';
|
|
6
6
|
import type { Rspack } from '@modern-js/builder-rspack-provider';
|
|
7
|
+
import { Bundler } from './utils';
|
|
7
8
|
export interface ImportSpecifier {
|
|
8
9
|
local?: string;
|
|
9
10
|
imported?: string;
|
|
@@ -18,7 +19,7 @@ export interface RuntimePlugin {
|
|
|
18
19
|
options: string;
|
|
19
20
|
args?: string;
|
|
20
21
|
}
|
|
21
|
-
export type AppToolsHooks = {
|
|
22
|
+
export type AppToolsHooks<B extends Bundler = 'webpack'> = {
|
|
22
23
|
modifyEntryExport: AsyncWaterfall<{
|
|
23
24
|
entrypoint: Entrypoint;
|
|
24
25
|
exportStatement: string;
|
|
@@ -61,16 +62,16 @@ export type AppToolsHooks = {
|
|
|
61
62
|
beforeDev: AsyncWorkflow<void, unknown>;
|
|
62
63
|
afterDev: AsyncWorkflow<void, unknown>;
|
|
63
64
|
beforeCreateCompiler: AsyncWorkflow<{
|
|
64
|
-
bundlerConfigs
|
|
65
|
+
bundlerConfigs?: B extends 'rspack' ? Rspack.Configuration[] : webpack.Configuration[];
|
|
65
66
|
}, unknown>;
|
|
66
67
|
afterCreateCompiler: AsyncWorkflow<{
|
|
67
|
-
compiler?:
|
|
68
|
+
compiler?: B extends 'rspack' ? Rspack.Compiler : webpack.Compiler | webpack.MultiCompiler;
|
|
68
69
|
}, unknown>;
|
|
69
70
|
beforePrintInstructions: AsyncWaterfall<{
|
|
70
71
|
instructions: string;
|
|
71
72
|
}>;
|
|
72
73
|
beforeBuild: AsyncWorkflow<{
|
|
73
|
-
bundlerConfigs?:
|
|
74
|
+
bundlerConfigs?: B extends 'rspack' ? Rspack.Configuration[] : webpack.Configuration[];
|
|
74
75
|
}, unknown>;
|
|
75
76
|
afterBuild: AsyncWorkflow<{
|
|
76
77
|
stats?: Stats | MultiStats;
|
|
@@ -6,11 +6,13 @@ import { Bundler, FromConfig } from './utils';
|
|
|
6
6
|
export * from './hooks';
|
|
7
7
|
export * from './config';
|
|
8
8
|
export * from './legacyConfig';
|
|
9
|
+
export type { webpack } from '@modern-js/builder-webpack-provider';
|
|
10
|
+
export type { Rspack } from '@modern-js/builder-rspack-provider';
|
|
9
11
|
export type { Bundler } from './utils';
|
|
10
12
|
export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig, SSR, SSRByEntries } from '@modern-js/server-core';
|
|
11
13
|
export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
12
14
|
export type AppTools<B extends Bundler = 'webpack'> = {
|
|
13
|
-
hooks: AppToolsHooks
|
|
15
|
+
hooks: AppToolsHooks<B>;
|
|
14
16
|
userConfig: FromConfig<B, {
|
|
15
17
|
rspack: RsAppToolsUserConfig;
|
|
16
18
|
webpack: AppToolsUserConfig;
|