@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
|
@@ -1,23 +1,3 @@
|
|
|
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 path from "path";
|
|
22
2
|
import {
|
|
23
3
|
fs,
|
|
@@ -32,6 +12,9 @@ class RouterPlugin {
|
|
|
32
12
|
if (target === "node" || Array.isArray(target) && target.includes("node")) {
|
|
33
13
|
return;
|
|
34
14
|
}
|
|
15
|
+
if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
35
18
|
const { webpack } = compiler;
|
|
36
19
|
const { Compilation, sources } = webpack;
|
|
37
20
|
const { RawSource } = sources;
|
|
@@ -50,7 +33,7 @@ class RouterPlugin {
|
|
|
50
33
|
name: PLUGIN_NAME,
|
|
51
34
|
stage: PROCESS_ASSETS_STAGE_REPORT
|
|
52
35
|
},
|
|
53
|
-
() =>
|
|
36
|
+
async () => {
|
|
54
37
|
const stats = compilation.getStats().toJson({
|
|
55
38
|
chunkGroups: true,
|
|
56
39
|
chunks: true
|
|
@@ -101,9 +84,9 @@ class RouterPlugin {
|
|
|
101
84
|
compilation.updateAsset(file, new RawSource(newContent));
|
|
102
85
|
}
|
|
103
86
|
const filename = path.join(outputPath, ROUTE_MINIFEST_FILE);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
87
|
+
await fs.ensureFile(filename);
|
|
88
|
+
await fs.writeFile(filename, JSON.stringify(manifest, null, 2));
|
|
89
|
+
}
|
|
107
90
|
);
|
|
108
91
|
});
|
|
109
92
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderConfig) {
|
|
2
|
+
const htmlConfig = { ...resolveConfig.html };
|
|
3
|
+
if (!htmlConfig.template) {
|
|
4
|
+
htmlConfig.templateByEntries = {
|
|
5
|
+
...htmlConfig.templateByEntries,
|
|
6
|
+
...appContext.htmlTemplates
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const config = {
|
|
10
|
+
...resolveConfig,
|
|
11
|
+
dev: {
|
|
12
|
+
...resolveConfig.dev,
|
|
13
|
+
port: appContext.port
|
|
14
|
+
},
|
|
15
|
+
html: htmlConfig,
|
|
16
|
+
output: {
|
|
17
|
+
...resolveConfig.output,
|
|
18
|
+
cleanDistPath: false
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
modifyBuilderConfig == null ? void 0 : modifyBuilderConfig(config);
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
createBuilderProviderConfig
|
|
26
|
+
};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isProd,
|
|
3
|
+
isServiceWorker,
|
|
4
|
+
isSSR,
|
|
5
|
+
isUseSSRBundle
|
|
6
|
+
} from "@modern-js/utils";
|
|
2
7
|
function getBuilderTargets(normalizedConfig) {
|
|
3
8
|
const targets = ["web"];
|
|
4
9
|
const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
|
|
5
10
|
if (useNodeTarget) {
|
|
6
11
|
targets.push("node");
|
|
7
12
|
}
|
|
13
|
+
const useWorkerTarget = isProd() ? isServiceWorker(normalizedConfig) : false;
|
|
14
|
+
if (useWorkerTarget) {
|
|
15
|
+
targets.push("service-worker");
|
|
16
|
+
}
|
|
8
17
|
return targets;
|
|
9
18
|
}
|
|
10
19
|
export {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createBuilder } from "@modern-js/builder";
|
|
2
|
+
import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
|
|
3
|
+
import { getBuilderTargets } from "./getBuilderTargets";
|
|
4
|
+
import { createBuilderOptions } from "./createBuilderOptions";
|
|
5
|
+
async function generateBuilder(options, generateProvider, utils) {
|
|
6
|
+
const { normalizedConfig, appContext } = options;
|
|
7
|
+
const { modifyBuilderConfig, modifyBuilderInstance } = utils || {};
|
|
8
|
+
const builderConfig = createBuilderProviderConfig(
|
|
9
|
+
normalizedConfig,
|
|
10
|
+
appContext,
|
|
11
|
+
modifyBuilderConfig
|
|
12
|
+
);
|
|
13
|
+
const provider = generateProvider({
|
|
14
|
+
builderConfig
|
|
15
|
+
});
|
|
16
|
+
const target = getBuilderTargets(normalizedConfig);
|
|
17
|
+
const builderOptions = createBuilderOptions(target, appContext);
|
|
18
|
+
const builder = await createBuilder(provider, builderOptions);
|
|
19
|
+
await applyBuilderPlugins(builder, options);
|
|
20
|
+
await (modifyBuilderInstance == null ? void 0 : modifyBuilderInstance(builder));
|
|
21
|
+
return builder;
|
|
22
|
+
}
|
|
23
|
+
async function applyBuilderPlugins(builder, options) {
|
|
24
|
+
const { builderPluginAdapterModern } = await import("../shared/builderPlugins/adapterModern");
|
|
25
|
+
builder.addPlugins([builderPluginAdapterModern(options)]);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
generateBuilder
|
|
29
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
async function createBuilderGenerator(bundler) {
|
|
2
|
+
if (bundler === "rspack") {
|
|
3
|
+
try {
|
|
4
|
+
const { createRspackBuilderForModern } = await import("./builder-rspack");
|
|
5
|
+
return createRspackBuilderForModern;
|
|
6
|
+
} catch (_) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"Failed to use rspack, please check if you have `@modern-js/builder-rspack-provider` installed"
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const { createWebpackBuilderForModern } = await import("./builder-webpack");
|
|
13
|
+
return createWebpackBuilderForModern;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
createBuilderGenerator
|
|
17
|
+
};
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import {
|
|
21
2
|
mergeBuilderConfig
|
|
22
3
|
} from "@modern-js/builder-shared";
|
|
@@ -58,13 +39,17 @@ const builderPluginAdapterModern = (options) => ({
|
|
|
58
39
|
const builderConfig = api.getNormalizedConfig();
|
|
59
40
|
if (target === "node") {
|
|
60
41
|
chain.name("server");
|
|
42
|
+
} else if (target === "service-worker") {
|
|
43
|
+
chain.name("service-worker");
|
|
44
|
+
} else if (target === "web-worker") {
|
|
45
|
+
chain.name("worker");
|
|
61
46
|
} else if (target === "modern-web") {
|
|
62
47
|
chain.name("modern");
|
|
63
48
|
} else {
|
|
64
49
|
chain.name("client");
|
|
65
50
|
}
|
|
66
|
-
if (target === "node") {
|
|
67
|
-
applyNodeCompat(chain, normalizedConfig, isProd);
|
|
51
|
+
if (target === "node" || target === "service-worker") {
|
|
52
|
+
applyNodeCompat(target, chain, normalizedConfig, isProd);
|
|
68
53
|
}
|
|
69
54
|
if (isHtmlEnabled(builderConfig, target)) {
|
|
70
55
|
applyBottomHtmlPlugin({
|
|
@@ -80,7 +65,7 @@ const builderPluginAdapterModern = (options) => ({
|
|
|
80
65
|
CHAIN_ID
|
|
81
66
|
});
|
|
82
67
|
}
|
|
83
|
-
if (target !== "node") {
|
|
68
|
+
if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
|
|
84
69
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
85
70
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
86
71
|
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
@@ -89,7 +74,7 @@ const builderPluginAdapterModern = (options) => ({
|
|
|
89
74
|
applyCallbacks(api, options);
|
|
90
75
|
function isHtmlEnabled(config, target) {
|
|
91
76
|
var _a;
|
|
92
|
-
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "web-worker";
|
|
77
|
+
return ((_a = config.tools) == null ? void 0 : _a.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
80
|
});
|
|
@@ -111,7 +96,7 @@ function applyBottomHtmlPlugin({
|
|
|
111
96
|
CHAIN_ID
|
|
112
97
|
}) {
|
|
113
98
|
for (const entryName of Object.keys(api.context.entry)) {
|
|
114
|
-
const baseTemplateParams =
|
|
99
|
+
const baseTemplateParams = {
|
|
115
100
|
entryName,
|
|
116
101
|
title: getEntryOptions(
|
|
117
102
|
entryName,
|
|
@@ -119,20 +104,22 @@ function applyBottomHtmlPlugin({
|
|
|
119
104
|
modernConfig.html.titleByEntries,
|
|
120
105
|
appContext.packageName
|
|
121
106
|
),
|
|
122
|
-
mountId: modernConfig.html.mountId
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
107
|
+
mountId: modernConfig.html.mountId,
|
|
108
|
+
...getEntryOptions(
|
|
109
|
+
entryName,
|
|
110
|
+
modernConfig.html.templateParameters,
|
|
111
|
+
modernConfig.html.templateParametersByEntries,
|
|
112
|
+
appContext.packageName
|
|
113
|
+
)
|
|
114
|
+
};
|
|
129
115
|
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap((args) => [
|
|
130
|
-
|
|
116
|
+
{
|
|
117
|
+
...args[0] || {},
|
|
131
118
|
__internal__: true,
|
|
132
119
|
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && lodashTemplate(appContext.htmlTemplates[`__${entryName}-bottom__`])(
|
|
133
120
|
baseTemplateParams
|
|
134
121
|
)
|
|
135
|
-
}
|
|
122
|
+
}
|
|
136
123
|
]);
|
|
137
124
|
}
|
|
138
125
|
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [HtmlWebpackPlugin]);
|
|
@@ -146,8 +133,8 @@ function applyAsyncChunkHtmlPlugin({
|
|
|
146
133
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [HtmlWebpackPlugin]);
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
|
-
function applyNodeCompat(chain, modernConfig, isProd) {
|
|
150
|
-
|
|
136
|
+
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
137
|
+
const nodeExts = [
|
|
151
138
|
".node.js",
|
|
152
139
|
".node.jsx",
|
|
153
140
|
".node.ts",
|
|
@@ -156,9 +143,21 @@ function applyNodeCompat(chain, modernConfig, isProd) {
|
|
|
156
143
|
".server.ts",
|
|
157
144
|
".server.ts",
|
|
158
145
|
".server.tsx"
|
|
159
|
-
]
|
|
146
|
+
];
|
|
147
|
+
const webWorkerExts = [
|
|
148
|
+
".worker.js",
|
|
149
|
+
".worker.jsx",
|
|
150
|
+
".worker.ts",
|
|
151
|
+
".worker.tsx"
|
|
152
|
+
];
|
|
153
|
+
for (const ext of nodeExts) {
|
|
160
154
|
chain.resolve.extensions.prepend(ext);
|
|
161
155
|
}
|
|
156
|
+
if (target === "service-worker") {
|
|
157
|
+
for (const ext of webWorkerExts) {
|
|
158
|
+
chain.resolve.extensions.prepend(ext);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
162
161
|
filterEntriesBySSRConfig(
|
|
163
162
|
isProd,
|
|
164
163
|
chain,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ResolvedConfigContext } from "@modern-js/core";
|
|
2
|
+
import { logger, printBuildError } from "@modern-js/utils";
|
|
3
|
+
import { generateRoutes } from "../utils/routes";
|
|
4
|
+
import { buildServerConfig } from "../utils/config";
|
|
5
|
+
const build = async (api, options) => {
|
|
6
|
+
if (options == null ? void 0 : options.analyze) {
|
|
7
|
+
process.env.BUNDLE_ANALYZE = "true";
|
|
8
|
+
}
|
|
9
|
+
let resolvedConfig = api.useResolvedConfigContext();
|
|
10
|
+
const appContext = api.useAppContext();
|
|
11
|
+
const hookRunners = api.useHookRunners();
|
|
12
|
+
const { apiOnly } = appContext;
|
|
13
|
+
if (apiOnly) {
|
|
14
|
+
const { appDirectory: appDirectory2, distDirectory: distDirectory2, serverConfigFile: serverConfigFile2 } = appContext;
|
|
15
|
+
await hookRunners.beforeBuild({
|
|
16
|
+
bundlerConfigs: void 0
|
|
17
|
+
});
|
|
18
|
+
await buildServerConfig({
|
|
19
|
+
appDirectory: appDirectory2,
|
|
20
|
+
distDirectory: distDirectory2,
|
|
21
|
+
configFile: serverConfigFile2
|
|
22
|
+
});
|
|
23
|
+
await generateRoutes(appContext);
|
|
24
|
+
await hookRunners.afterBuild({
|
|
25
|
+
stats: void 0
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
resolvedConfig = { ...resolvedConfig, cliOptions: options };
|
|
30
|
+
ResolvedConfigContext.set(resolvedConfig);
|
|
31
|
+
const { distDirectory, appDirectory, serverConfigFile } = appContext;
|
|
32
|
+
await buildServerConfig({
|
|
33
|
+
appDirectory,
|
|
34
|
+
distDirectory,
|
|
35
|
+
configFile: serverConfigFile
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
logger.info("Create a production build...\n");
|
|
39
|
+
if (!appContext.builder) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
await appContext.builder.build();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
printBuildError(error);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
build
|
|
52
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ResolvedConfigContext } from "@modern-js/core";
|
|
2
|
+
import { printInstructions } from "../utils/printInstructions";
|
|
3
|
+
import {
|
|
4
|
+
setServer,
|
|
5
|
+
createServer,
|
|
6
|
+
injectDataLoaderPlugin
|
|
7
|
+
} from "../utils/createServer";
|
|
8
|
+
import { generateRoutes } from "../utils/routes";
|
|
9
|
+
import { buildServerConfig } from "../utils/config";
|
|
10
|
+
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
11
|
+
const dev = async (api, options) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (options.analyze) {
|
|
14
|
+
process.env.BUNDLE_ANALYZE = "true";
|
|
15
|
+
}
|
|
16
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
17
|
+
const appContext = api.useAppContext();
|
|
18
|
+
const hookRunners = api.useHookRunners();
|
|
19
|
+
normalizedConfig = { ...normalizedConfig, cliOptions: options };
|
|
20
|
+
ResolvedConfigContext.set(normalizedConfig);
|
|
21
|
+
const { appDirectory, distDirectory, port, apiOnly, serverConfigFile } = appContext;
|
|
22
|
+
await buildServerConfig({
|
|
23
|
+
appDirectory,
|
|
24
|
+
distDirectory,
|
|
25
|
+
configFile: serverConfigFile,
|
|
26
|
+
options: {
|
|
27
|
+
esbuildOptions: {
|
|
28
|
+
watch: true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
await hookRunners.beforeDev();
|
|
33
|
+
if (!appContext.builder && !apiOnly) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
await generateRoutes(appContext);
|
|
39
|
+
const serverInternalPlugins = await getServerInternalPlugins(api);
|
|
40
|
+
const serverOptions = {
|
|
41
|
+
dev: {
|
|
42
|
+
port,
|
|
43
|
+
https: normalizedConfig.dev.https,
|
|
44
|
+
...(_a = normalizedConfig.tools) == null ? void 0 : _a.devServer
|
|
45
|
+
},
|
|
46
|
+
pwd: appDirectory,
|
|
47
|
+
config: normalizedConfig,
|
|
48
|
+
serverConfigFile,
|
|
49
|
+
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
50
|
+
};
|
|
51
|
+
if (apiOnly) {
|
|
52
|
+
const app = await createServer({
|
|
53
|
+
...serverOptions,
|
|
54
|
+
compiler: null
|
|
55
|
+
});
|
|
56
|
+
app.listen(port, async (err) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
const { server } = await appContext.builder.startDevServer({
|
|
64
|
+
printURLs: false,
|
|
65
|
+
serverOptions
|
|
66
|
+
});
|
|
67
|
+
setServer(server);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
dev
|
|
72
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
const inspect = async (api, options) => {
|
|
3
|
+
const appContext = api.useAppContext();
|
|
4
|
+
if (!appContext.builder) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
"Expect the Builder to have been initialized, But the appContext.builder received `undefined`"
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
return appContext.builder.inspectConfig({
|
|
10
|
+
env: options.env,
|
|
11
|
+
verbose: options.verbose,
|
|
12
|
+
outputPath: join(appContext == null ? void 0 : appContext.builder.context.distPath, options.output),
|
|
13
|
+
writeToDisk: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
inspect
|
|
18
|
+
};
|
|
@@ -1,54 +1,34 @@
|
|
|
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 { logger, chalk, isApiOnly } from "@modern-js/utils";
|
|
22
2
|
import server from "@modern-js/prod-server";
|
|
23
3
|
import { printInstructions } from "../utils/printInstructions";
|
|
24
4
|
import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
25
5
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
|
26
|
-
const start = (api) =>
|
|
6
|
+
const start = async (api) => {
|
|
27
7
|
var _a;
|
|
28
8
|
const appContext = api.useAppContext();
|
|
29
9
|
const userConfig = api.useResolvedConfigContext();
|
|
30
10
|
const hookRunners = api.useHookRunners();
|
|
31
11
|
const { appDirectory, port, serverConfigFile } = appContext;
|
|
32
12
|
logger.log(chalk.cyan(`Starting the modern server...`));
|
|
33
|
-
const apiOnly =
|
|
13
|
+
const apiOnly = await isApiOnly(
|
|
34
14
|
appContext.appDirectory,
|
|
35
15
|
(_a = userConfig == null ? void 0 : userConfig.source) == null ? void 0 : _a.entriesDir
|
|
36
16
|
);
|
|
37
|
-
const serverInternalPlugins =
|
|
38
|
-
const app =
|
|
17
|
+
const serverInternalPlugins = await getServerInternalPlugins(api);
|
|
18
|
+
const app = await server({
|
|
39
19
|
pwd: appDirectory,
|
|
40
20
|
config: userConfig,
|
|
41
21
|
serverConfigFile,
|
|
42
22
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins),
|
|
43
23
|
apiOnly
|
|
44
24
|
});
|
|
45
|
-
app.listen(port, (err) =>
|
|
25
|
+
app.listen(port, async (err) => {
|
|
46
26
|
if (err) {
|
|
47
27
|
throw err;
|
|
48
28
|
}
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
}
|
|
29
|
+
await printInstructions(hookRunners, appContext, userConfig);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
52
32
|
export {
|
|
53
33
|
start
|
|
54
34
|
};
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
|
21
2
|
function createDefaultConfig(appContext, bundler) {
|
|
22
3
|
const defaultBuilderConfig = createDefaultBuilderConfig();
|
|
23
|
-
const dev =
|
|
4
|
+
const dev = {
|
|
5
|
+
...defaultBuilderConfig.dev,
|
|
24
6
|
port: void 0
|
|
25
|
-
}
|
|
26
|
-
const output =
|
|
7
|
+
};
|
|
8
|
+
const output = {
|
|
9
|
+
...defaultBuilderConfig.output,
|
|
27
10
|
disableNodePolyfill: true
|
|
28
|
-
}
|
|
29
|
-
const source =
|
|
11
|
+
};
|
|
12
|
+
const source = {
|
|
13
|
+
...defaultBuilderConfig.source,
|
|
30
14
|
entries: void 0,
|
|
31
15
|
enableAsyncEntry: false,
|
|
32
16
|
disableDefaultEntries: false,
|
|
@@ -38,8 +22,9 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
38
22
|
"@": appContext.srcDirectory,
|
|
39
23
|
"@shared": appContext.sharedDirectory
|
|
40
24
|
}
|
|
41
|
-
}
|
|
42
|
-
const html =
|
|
25
|
+
};
|
|
26
|
+
const html = {
|
|
27
|
+
...defaultBuilderConfig.html,
|
|
43
28
|
title: "",
|
|
44
29
|
meta: {
|
|
45
30
|
charset: { charset: "utf-8" },
|
|
@@ -51,7 +36,7 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
51
36
|
"wap-font-scale": "no",
|
|
52
37
|
"format-detection": "telephone=no"
|
|
53
38
|
}
|
|
54
|
-
}
|
|
39
|
+
};
|
|
55
40
|
const server = {
|
|
56
41
|
routes: void 0,
|
|
57
42
|
publicRoutes: void 0,
|
|
@@ -60,7 +45,9 @@ function createDefaultConfig(appContext, bundler) {
|
|
|
60
45
|
baseUrl: "/",
|
|
61
46
|
port: 8080
|
|
62
47
|
};
|
|
63
|
-
const tools = bundler === "webpack" ?
|
|
48
|
+
const tools = bundler === "webpack" ? {
|
|
49
|
+
...defaultBuilderConfig.tools
|
|
50
|
+
} : void 0;
|
|
64
51
|
return {
|
|
65
52
|
source,
|
|
66
53
|
output,
|
|
File without changes
|
|
File without changes
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import path, { dirname, isAbsolute, posix, sep } from "path";
|
|
21
2
|
import {
|
|
22
3
|
applyOptionsChain,
|
|
@@ -68,7 +49,7 @@ function initSourceConfig(config, appContext, bundler) {
|
|
|
68
49
|
function createBuilderGlobalVars(config2, appContext2) {
|
|
69
50
|
const { globalVars = {} } = config2.source;
|
|
70
51
|
const publicEnv = getAutoInjectEnv(appContext2);
|
|
71
|
-
return
|
|
52
|
+
return { ...globalVars, ...publicEnv };
|
|
72
53
|
}
|
|
73
54
|
function createBuilderInclude(config2, appContext2) {
|
|
74
55
|
const { include } = config2.source;
|
|
@@ -138,10 +119,11 @@ function initToolsConfig(config) {
|
|
|
138
119
|
config.tools.tsChecker = applyOptionsChain(defaultTsChecker, tsChecker);
|
|
139
120
|
tsLoader && (config.tools.tsLoader = (tsLoaderConfig, utils) => {
|
|
140
121
|
applyOptionsChain(
|
|
141
|
-
|
|
122
|
+
{
|
|
123
|
+
...tsLoaderConfig,
|
|
142
124
|
transpileOnly: false,
|
|
143
125
|
allowTsInNodeModules: true
|
|
144
|
-
}
|
|
126
|
+
},
|
|
145
127
|
tsLoader || {},
|
|
146
128
|
utils
|
|
147
129
|
);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|