@modern-js/app-tools 2.3.1-alpha.2 → 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 +115 -0
- package/README.md +14 -18
- 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/cjs/builder/builder-rspack/index.js +31 -0
- package/dist/cjs/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/cjs/builder/builder-webpack/index.js +78 -0
- package/dist/{js/node/builder/webpackPlugins/routerPlugin.js → cjs/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +14 -29
- package/dist/cjs/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/cjs/builder/generator/createBuilderOptions.js +47 -0
- package/dist/{js/node/config/initial/index.js → cjs/builder/generator/createBuilderProviderConfig.js} +26 -18
- package/dist/cjs/builder/generator/getBuilderTargets.js +39 -0
- package/dist/cjs/builder/generator/index.js +58 -0
- package/dist/cjs/builder/index.js +46 -0
- package/dist/{js/node/builder/builderPlugins/compatModern.js → cjs/builder/shared/builderPlugins/adapterModern.js} +109 -137
- package/dist/{js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js → cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
- package/dist/{js/node/builder/webpackPlugins/htmlBottomTemplate.js → cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
- package/dist/{js/node/builder/share.js → cjs/builder/shared/createCopyPattern.js} +3 -3
- package/dist/cjs/builder/shared/index.js +19 -0
- package/dist/{js/node/builder → cjs/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/node/utils → 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 +16 -27
- package/dist/cjs/config/index.js +19 -0
- package/dist/cjs/config/initialize/index.js +35 -0
- package/dist/{js/node/config/initial → cjs/config/initialize}/inits.js +8 -22
- package/dist/{js/node/config/initial → cjs/config/legacy}/createHtmlConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createOutputConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createSourceConfig.js +0 -0
- package/dist/{js/node/config/initial → cjs/config/legacy}/createToolsConfig.js +0 -0
- package/dist/{js/node/config/initial/transformNormalizedConfig.js → cjs/config/legacy/index.js} +8 -3
- 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 +1 -1
- 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/cjs/types/utils.js +15 -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/{js/node/config/index.js → cjs/utils/getServerInternalPlugins.js} +20 -13
- 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/cjs/utils/types.js +15 -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 +142 -137
- 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/esm/builder/builder-rspack/index.js +6 -0
- package/dist/esm/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/{js/treeshaking/builder → esm/builder/builder-webpack}/index.js +44 -117
- package/dist/{js/treeshaking/builder/webpackPlugins/routerPlugin.js → esm/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +6 -3
- package/dist/esm/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/esm/builder/generator/createBuilderOptions.js +41 -0
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/esm/builder/generator/getBuilderTargets.js +16 -0
- package/dist/esm/builder/generator/index.js +199 -0
- package/dist/esm/builder/index.js +175 -0
- package/dist/{js/treeshaking/builder/builderPlugins/compatModern.js → esm/builder/shared/builderPlugins/adapterModern.js} +138 -142
- package/dist/{js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js → esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- package/dist/{js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js → esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
- package/dist/{js/treeshaking/builder/share.js → esm/builder/shared/createCopyPattern.js} +0 -0
- package/dist/esm/builder/shared/index.js +3 -0
- package/dist/{js/treeshaking/builder → esm/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/treeshaking/utils → 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 +2 -2
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/config/initialize/index.js +10 -0
- package/dist/{js/treeshaking/config/initial → esm/config/initialize}/inits.js +6 -4
- package/dist/esm/config/legacy/createHtmlConfig.js +19 -0
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createOutputConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createSourceConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial → esm/config/legacy}/createToolsConfig.js +1 -1
- package/dist/{js/treeshaking/config/initial/transformNormalizedConfig.js → esm/config/legacy/index.js} +4 -1
- 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 +19 -12
- package/dist/{js/treeshaking → esm}/initialize/index.js +36 -28
- 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 +1 -1
- 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/esm/types/utils.js +1 -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/esm/utils/types.js +1 -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/esm-node/builder/builder-rspack/index.js +8 -0
- package/dist/esm-node/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/esm-node/builder/builder-webpack/index.js +51 -0
- package/dist/{js/modern/builder/webpackPlugins/routerPlugin.js → esm-node/builder/builder-webpack/webpackPlugins/RouterPlugin.js} +8 -25
- package/dist/esm-node/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/esm-node/builder/generator/createBuilderOptions.js +24 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +26 -0
- package/dist/esm-node/builder/generator/getBuilderTargets.js +21 -0
- package/dist/esm-node/builder/generator/index.js +29 -0
- package/dist/esm-node/builder/index.js +17 -0
- package/dist/{js/modern/builder/builderPlugins/compatModern.js → esm-node/builder/shared/builderPlugins/adapterModern.js} +104 -135
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/{js/modern/builder/share.js → esm-node/builder/shared/createCopyPattern.js} +0 -0
- package/dist/esm-node/builder/shared/index.js +3 -0
- package/dist/{js/modern/builder → esm-node/builder/shared}/loaders/serverModuleLoader.js +0 -0
- package/dist/{js/modern/utils → 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 +16 -29
- package/dist/esm-node/config/index.js +3 -0
- package/dist/esm-node/config/initialize/index.js +12 -0
- package/dist/{js/modern/config/initial → esm-node/config/initialize}/inits.js +8 -24
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createHtmlConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createOutputConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createSourceConfig.js +0 -0
- package/dist/{js/modern/config/initial → esm-node/config/legacy}/createToolsConfig.js +0 -0
- package/dist/{js/modern/config/initial/transformNormalizedConfig.js → esm-node/config/legacy/index.js} +4 -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 +1 -1
- 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/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/esm-node/utils/types.js +0 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
- package/dist/types/analyze/getServerRoutes.d.ts +1 -1
- package/dist/types/analyze/index.d.ts +5 -1
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +4 -0
- package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
- package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
- package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
- package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
- package/dist/types/builder/generator/index.d.ts +17 -0
- package/dist/types/builder/index.d.ts +1 -18
- package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
- package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
- package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
- package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
- package/dist/types/builder/shared/types.d.ts +16 -0
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/deploy.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/commands/serve.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/index.d.ts +3 -2
- package/dist/types/config/initialize/index.d.ts +2 -0
- package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
- package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
- package/dist/types/config/legacy/index.d.ts +3 -0
- package/dist/types/defineConfig.d.ts +2 -2
- package/dist/types/index.d.ts +7 -3
- package/dist/types/initialize/index.d.ts +6 -2
- package/dist/types/types/config/deploy.d.ts +1 -2
- package/dist/types/types/config/dev.d.ts +2 -3
- package/dist/types/types/config/experiments.d.ts +1 -2
- package/dist/types/types/config/html.d.ts +5 -3
- package/dist/types/types/config/index.d.ts +41 -48
- package/dist/types/types/config/output.d.ts +8 -3
- package/dist/types/types/config/performance.d.ts +6 -3
- package/dist/types/types/config/security.d.ts +3 -3
- package/dist/types/types/config/source.d.ts +7 -3
- package/dist/types/types/config/tools.d.ts +10 -4
- package/dist/types/types/hooks.d.ts +6 -4
- package/dist/types/types/index.d.ts +19 -7
- package/dist/types/types/utils.d.ts +7 -0
- package/dist/types/utils/config.d.ts +1 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/package.json +40 -32
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/index.js +0 -332
- package/dist/js/modern/builder/index.js +0 -159
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- 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/config/index.js +0 -8
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/index.js +0 -211
- package/dist/js/modern/initialize/index.js +0 -124
- 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 -339
- package/dist/js/node/builder/index.js +0 -177
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/index.js +0 -235
- package/dist/js/node/initialize/index.js +0 -134
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/treeshaking/config/index.js +0 -3
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
- package/dist/types/config/initial/index.d.ts +0 -4
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
package/dist/js/modern/index.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import path from "path";
|
|
41
|
-
import lintPlugin from "@modern-js/plugin-lint";
|
|
42
|
-
import {
|
|
43
|
-
cleanRequireCache,
|
|
44
|
-
emptyDir,
|
|
45
|
-
Import,
|
|
46
|
-
getCommand
|
|
47
|
-
} from "@modern-js/utils";
|
|
48
|
-
import { castArray } from "@modern-js/utils/lodash";
|
|
49
|
-
import analyzePlugin from "./analyze";
|
|
50
|
-
import initializePlugin from "./initialize";
|
|
51
|
-
import { hooks } from "./hooks";
|
|
52
|
-
import { i18n, localeKeys } from "./locale";
|
|
53
|
-
import { getLocaleLanguage } from "./utils/language";
|
|
54
|
-
import { restart } from "./utils/restart";
|
|
55
|
-
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
|
56
|
-
export * from "./defineConfig";
|
|
57
|
-
export * from "./types";
|
|
58
|
-
const upgradeModel = Import.lazy(
|
|
59
|
-
"@modern-js/upgrade",
|
|
60
|
-
require
|
|
61
|
-
);
|
|
62
|
-
const devCommand = (program, api) => __async(void 0, null, function* () {
|
|
63
|
-
const runner = api.useHookRunners();
|
|
64
|
-
const devToolMetas = yield runner.registerDev();
|
|
65
|
-
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((options) => __async(void 0, null, function* () {
|
|
66
|
-
const { dev } = yield import("./commands/dev");
|
|
67
|
-
yield dev(api, options);
|
|
68
|
-
}));
|
|
69
|
-
for (const meta of devToolMetas) {
|
|
70
|
-
if (!meta.subCommands) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
for (const subCmd of meta.subCommands) {
|
|
74
|
-
devProgram.command(subCmd).action((..._0) => __async(void 0, [..._0], function* (options = {}) {
|
|
75
|
-
const { appDirectory } = api.useAppContext();
|
|
76
|
-
const { isTypescript } = yield import("@modern-js/utils");
|
|
77
|
-
yield runner.beforeDevTask(meta);
|
|
78
|
-
yield meta.action(options, {
|
|
79
|
-
isTsProject: isTypescript(appDirectory)
|
|
80
|
-
});
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
const buildCommand = (program, api) => __async(void 0, null, function* () {
|
|
86
|
-
const runner = api.useHookRunners();
|
|
87
|
-
const platformBuilders = yield runner.registerBuildPlatform();
|
|
88
|
-
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((options) => __async(void 0, null, function* () {
|
|
89
|
-
const { build } = yield import("./commands/build");
|
|
90
|
-
yield build(api, options);
|
|
91
|
-
}));
|
|
92
|
-
for (const platformBuilder of platformBuilders) {
|
|
93
|
-
const platforms = castArray(platformBuilder.platform);
|
|
94
|
-
for (const platform of platforms) {
|
|
95
|
-
buildProgram.command(platform).action(() => __async(void 0, null, function* () {
|
|
96
|
-
const { appDirectory } = api.useAppContext();
|
|
97
|
-
const { isTypescript } = yield import("@modern-js/utils");
|
|
98
|
-
yield runner.beforeBuildPlatform(platformBuilders);
|
|
99
|
-
yield platformBuilder.build(platform, {
|
|
100
|
-
isTsProject: isTypescript(appDirectory)
|
|
101
|
-
});
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
var src_default = () => ({
|
|
107
|
-
name: "@modern-js/app-tools",
|
|
108
|
-
post: [
|
|
109
|
-
"@modern-js/plugin-initialize",
|
|
110
|
-
"@modern-js/plugin-analyze",
|
|
111
|
-
"@modern-js/plugin-ssr",
|
|
112
|
-
"@modern-js/plugin-document",
|
|
113
|
-
"@modern-js/plugin-state",
|
|
114
|
-
"@modern-js/plugin-router",
|
|
115
|
-
"@modern-js/plugin-router-v5",
|
|
116
|
-
"@modern-js/plugin-polyfill"
|
|
117
|
-
],
|
|
118
|
-
registerHook: hooks,
|
|
119
|
-
usePlugins: [initializePlugin(), analyzePlugin(), lintPlugin()],
|
|
120
|
-
setup: (api) => {
|
|
121
|
-
const locale = getLocaleLanguage();
|
|
122
|
-
i18n.changeLanguage({ locale });
|
|
123
|
-
return {
|
|
124
|
-
commands(_0) {
|
|
125
|
-
return __async(this, arguments, function* ({ program }) {
|
|
126
|
-
yield devCommand(program, api);
|
|
127
|
-
yield buildCommand(program, api);
|
|
128
|
-
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option(
|
|
129
|
-
"-c --config <config>",
|
|
130
|
-
i18n.t(localeKeys.command.shared.config)
|
|
131
|
-
).action(() => __async(this, null, function* () {
|
|
132
|
-
const { start } = yield import("./commands/serve");
|
|
133
|
-
yield start(api);
|
|
134
|
-
}));
|
|
135
|
-
program.command("deploy").usage("[options]").option(
|
|
136
|
-
"-c --config <config>",
|
|
137
|
-
i18n.t(localeKeys.command.shared.config)
|
|
138
|
-
).description(i18n.t(localeKeys.command.deploy.describe)).action((options) => __async(this, null, function* () {
|
|
139
|
-
const { build } = yield import("./commands/build");
|
|
140
|
-
yield build(api);
|
|
141
|
-
const { deploy } = yield import("./commands/deploy");
|
|
142
|
-
yield deploy(api, options);
|
|
143
|
-
process.exit(0);
|
|
144
|
-
}));
|
|
145
|
-
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(
|
|
146
|
-
"-c, --config <config>",
|
|
147
|
-
i18n.t(localeKeys.command.new.config)
|
|
148
|
-
).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).action((options) => __async(this, null, function* () {
|
|
149
|
-
const { MWANewAction } = yield import("@modern-js/new-action");
|
|
150
|
-
yield MWANewAction(__spreadProps(__spreadValues({}, options), { locale: options.lang || locale }));
|
|
151
|
-
}));
|
|
152
|
-
program.command("inspect").description("inspect internal webpack config").option(
|
|
153
|
-
`--env <env>`,
|
|
154
|
-
i18n.t(localeKeys.command.inspect.env),
|
|
155
|
-
"development"
|
|
156
|
-
).option(
|
|
157
|
-
"--output <output>",
|
|
158
|
-
i18n.t(localeKeys.command.inspect.output),
|
|
159
|
-
"/"
|
|
160
|
-
).option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option(
|
|
161
|
-
"-c --config <config>",
|
|
162
|
-
i18n.t(localeKeys.command.shared.config)
|
|
163
|
-
).action((options) => __async(this, null, function* () {
|
|
164
|
-
const { inspect } = yield import("./commands/inspect");
|
|
165
|
-
inspect(api, options);
|
|
166
|
-
}));
|
|
167
|
-
upgradeModel.defineCommand(program.command("upgrade"));
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
prepare() {
|
|
171
|
-
return __async(this, null, function* () {
|
|
172
|
-
const command = getCommand();
|
|
173
|
-
if (command === "dev" || command === "start" || command === "build") {
|
|
174
|
-
const appContext = api.useAppContext();
|
|
175
|
-
yield emptyDir(appContext.distDirectory);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
|
-
watchFiles() {
|
|
180
|
-
return __async(this, null, function* () {
|
|
181
|
-
const appContext = api.useAppContext();
|
|
182
|
-
const config = api.useResolvedConfigContext();
|
|
183
|
-
return generateWatchFiles(appContext, config.source.configDir);
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
fileChange(e) {
|
|
187
|
-
return __async(this, null, function* () {
|
|
188
|
-
const { filename, eventType } = e;
|
|
189
|
-
const appContext = api.useAppContext();
|
|
190
|
-
const { appDirectory, srcDirectory } = appContext;
|
|
191
|
-
const absolutePath = path.resolve(appDirectory, filename);
|
|
192
|
-
if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
|
|
193
|
-
const { closeServer } = yield import("./utils/createServer");
|
|
194
|
-
yield closeServer();
|
|
195
|
-
yield restart(api.useHookRunners(), filename);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
beforeRestart() {
|
|
200
|
-
return __async(this, null, function* () {
|
|
201
|
-
cleanRequireCache([require.resolve("./analyze")]);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
export {
|
|
208
|
-
buildCommand,
|
|
209
|
-
src_default as default,
|
|
210
|
-
devCommand
|
|
211
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import {
|
|
41
|
-
ensureAbsolutePath,
|
|
42
|
-
getPort,
|
|
43
|
-
isDev,
|
|
44
|
-
isDevCommand
|
|
45
|
-
} from "@modern-js/utils";
|
|
46
|
-
import { legacySchema, schema } from "../schema";
|
|
47
|
-
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
|
48
|
-
import {
|
|
49
|
-
checkIsLegacyConfig,
|
|
50
|
-
createDefaultConfig,
|
|
51
|
-
createLegacyDefaultConfig
|
|
52
|
-
} from "../config";
|
|
53
|
-
var initialize_default = () => ({
|
|
54
|
-
name: "@modern-js/plugin-initialize",
|
|
55
|
-
setup(api) {
|
|
56
|
-
const config = () => {
|
|
57
|
-
const appContext = api.useAppContext();
|
|
58
|
-
const userConfig = api.useConfigContext();
|
|
59
|
-
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
|
60
|
-
};
|
|
61
|
-
const validateSchema = () => {
|
|
62
|
-
const userConfig = api.useConfigContext();
|
|
63
|
-
const schemas = checkIsLegacyConfig(userConfig) ? legacySchema : schema;
|
|
64
|
-
return schemas.generate();
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
config,
|
|
68
|
-
validateSchema,
|
|
69
|
-
resolvedConfig(_0) {
|
|
70
|
-
return __async(this, arguments, function* ({ resolved }) {
|
|
71
|
-
var _a2;
|
|
72
|
-
let appContext = api.useAppContext();
|
|
73
|
-
const userConfig = api.useConfigContext();
|
|
74
|
-
const port = yield getServerPort(resolved);
|
|
75
|
-
appContext = __spreadProps(__spreadValues({}, appContext), {
|
|
76
|
-
port,
|
|
77
|
-
distDirectory: ensureAbsolutePath(
|
|
78
|
-
appContext.distDirectory,
|
|
79
|
-
((_a2 = resolved.output.distPath) == null ? void 0 : _a2.root) || "dist"
|
|
80
|
-
)
|
|
81
|
-
});
|
|
82
|
-
api.setAppContext(appContext);
|
|
83
|
-
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
84
|
-
return {
|
|
85
|
-
resolved: {
|
|
86
|
-
_raw: userConfig,
|
|
87
|
-
source: normalizedConfig.source || {},
|
|
88
|
-
server: __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
|
|
89
|
-
port
|
|
90
|
-
}),
|
|
91
|
-
bff: normalizedConfig.bff || {},
|
|
92
|
-
dev: normalizedConfig.dev || {},
|
|
93
|
-
html: normalizedConfig.html || {},
|
|
94
|
-
output: normalizedConfig.output || {},
|
|
95
|
-
security: normalizedConfig.security || {},
|
|
96
|
-
tools: normalizedConfig.tools || {},
|
|
97
|
-
testing: normalizedConfig.testing || {},
|
|
98
|
-
plugins: normalizedConfig.plugins || [],
|
|
99
|
-
builderPlugins: normalizedConfig.builderPlugins || [],
|
|
100
|
-
runtime: normalizedConfig.runtime || {},
|
|
101
|
-
runtimeByEntries: normalizedConfig.runtimeByEntries || {},
|
|
102
|
-
deploy: normalizedConfig.deploy || {},
|
|
103
|
-
performance: normalizedConfig.performance || {},
|
|
104
|
-
experiments: normalizedConfig.experiments || {},
|
|
105
|
-
autoLoadPlugins: normalizedConfig.autoLoadPlugins || false
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
function getServerPort(config) {
|
|
114
|
-
return __async(this, null, function* () {
|
|
115
|
-
const prodPort = config.server.port || 8080;
|
|
116
|
-
if (isDev() && isDevCommand()) {
|
|
117
|
-
return getPort(config.dev.port || prodPort);
|
|
118
|
-
}
|
|
119
|
-
return prodPort;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
export {
|
|
123
|
-
initialize_default as default
|
|
124
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import * as path from "path";
|
|
41
|
-
import { bundle } from "@modern-js/node-bundle-require";
|
|
42
|
-
import {
|
|
43
|
-
CONFIG_FILE_EXTENSIONS,
|
|
44
|
-
fs,
|
|
45
|
-
getServerConfig,
|
|
46
|
-
OUTPUT_CONFIG_FILE
|
|
47
|
-
} from "@modern-js/utils";
|
|
48
|
-
const defineServerConfig = (config) => config;
|
|
49
|
-
const buildServerConfig = (_0) => __async(void 0, [_0], function* ({
|
|
50
|
-
appDirectory,
|
|
51
|
-
distDirectory,
|
|
52
|
-
configFile,
|
|
53
|
-
options
|
|
54
|
-
}) {
|
|
55
|
-
const configFilePath = yield getServerConfig(appDirectory, configFile);
|
|
56
|
-
const getOutputFile = (filepath) => __async(void 0, null, function* () {
|
|
57
|
-
return path.resolve(
|
|
58
|
-
distDirectory,
|
|
59
|
-
`${filepath.replace(
|
|
60
|
-
new RegExp(CONFIG_FILE_EXTENSIONS.join("|")),
|
|
61
|
-
""
|
|
62
|
-
)}.js`
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
if (configFilePath) {
|
|
66
|
-
const configHelperFilePath = path.normalize(
|
|
67
|
-
path.join(distDirectory, "./config-helper.js")
|
|
68
|
-
);
|
|
69
|
-
const helperCode = `
|
|
70
|
-
export const defineConfig = (config) => config;
|
|
71
|
-
`;
|
|
72
|
-
yield fs.ensureDir(distDirectory);
|
|
73
|
-
yield fs.writeFile(configHelperFilePath, helperCode);
|
|
74
|
-
yield bundle(configFilePath, __spreadProps(__spreadValues({}, options), {
|
|
75
|
-
getOutputFile,
|
|
76
|
-
esbuildPlugins: [
|
|
77
|
-
{
|
|
78
|
-
name: "native-build-config",
|
|
79
|
-
setup(ctx) {
|
|
80
|
-
ctx.onResolve(
|
|
81
|
-
{
|
|
82
|
-
filter: /app-tools\/server/
|
|
83
|
-
},
|
|
84
|
-
() => {
|
|
85
|
-
return {
|
|
86
|
-
path: configHelperFilePath
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const safeReplacer = () => {
|
|
97
|
-
const cache = [];
|
|
98
|
-
const keyCache = [];
|
|
99
|
-
return function(key, value) {
|
|
100
|
-
if (typeof value === "object" && value !== null) {
|
|
101
|
-
const index = cache.indexOf(value);
|
|
102
|
-
if (index !== -1) {
|
|
103
|
-
return `[Circular ${keyCache[index]}]`;
|
|
104
|
-
}
|
|
105
|
-
cache.push(value);
|
|
106
|
-
keyCache.push(key || "root");
|
|
107
|
-
}
|
|
108
|
-
return value;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const emitResolvedConfig = (appDirectory, resolvedConfig) => __async(void 0, null, function* () {
|
|
112
|
-
var _a;
|
|
113
|
-
const outputPath = path.join(
|
|
114
|
-
appDirectory,
|
|
115
|
-
((_a = resolvedConfig.output.distPath) == null ? void 0 : _a.root) || "./dist",
|
|
116
|
-
OUTPUT_CONFIG_FILE
|
|
117
|
-
);
|
|
118
|
-
yield fs.writeJSON(outputPath, resolvedConfig, {
|
|
119
|
-
spaces: 2,
|
|
120
|
-
replacer: safeReplacer()
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
export {
|
|
124
|
-
buildServerConfig,
|
|
125
|
-
defineServerConfig,
|
|
126
|
-
emitResolvedConfig,
|
|
127
|
-
safeReplacer
|
|
128
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import { Server } from "@modern-js/server";
|
|
41
|
-
let server = null;
|
|
42
|
-
const getServer = () => server;
|
|
43
|
-
const setServer = (newServer) => {
|
|
44
|
-
server = newServer;
|
|
45
|
-
};
|
|
46
|
-
const closeServer = () => __async(void 0, null, function* () {
|
|
47
|
-
if (server) {
|
|
48
|
-
yield server.close();
|
|
49
|
-
server = null;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const createServer = (options) => __async(void 0, null, function* () {
|
|
53
|
-
if (server) {
|
|
54
|
-
yield server.close();
|
|
55
|
-
}
|
|
56
|
-
server = new Server(options);
|
|
57
|
-
const app = yield server.init();
|
|
58
|
-
return app;
|
|
59
|
-
});
|
|
60
|
-
const injectDataLoaderPlugin = (internalPlugins) => {
|
|
61
|
-
const DataLoaderPlugin = require.resolve("@modern-js/plugin-data-loader/server");
|
|
62
|
-
return __spreadProps(__spreadValues({}, internalPlugins), {
|
|
63
|
-
"@modern-js/plugin-data-loader": {
|
|
64
|
-
path: DataLoaderPlugin,
|
|
65
|
-
forced: true
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
export {
|
|
70
|
-
closeServer,
|
|
71
|
-
createServer,
|
|
72
|
-
getServer,
|
|
73
|
-
injectDataLoaderPlugin,
|
|
74
|
-
setServer
|
|
75
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
import path from "path";
|
|
22
|
-
import { fs, getServerConfig } from "@modern-js/utils";
|
|
23
|
-
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
24
|
-
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
25
|
-
const json = JSON.parse(
|
|
26
|
-
fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8")
|
|
27
|
-
);
|
|
28
|
-
return json[packageJsonConfig != null ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
|
29
|
-
};
|
|
30
|
-
const addServerConfigToDeps = (dependencies, appDirectory, serverConfigFile) => __async(void 0, null, function* () {
|
|
31
|
-
const serverConfig = yield getServerConfig(appDirectory, serverConfigFile);
|
|
32
|
-
if (serverConfig) {
|
|
33
|
-
dependencies.push(serverConfig);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
function generateWatchFiles(appContext, configDir) {
|
|
37
|
-
return __async(this, null, function* () {
|
|
38
|
-
const { appDirectory, configFile } = appContext;
|
|
39
|
-
const configPath = path.join(appDirectory, configDir || "");
|
|
40
|
-
const dependencies = getPackageConfig(
|
|
41
|
-
appContext.appDirectory,
|
|
42
|
-
appContext.packageName
|
|
43
|
-
) ? [path.resolve(appDirectory, "./package.json")] : [];
|
|
44
|
-
yield addServerConfigToDeps(
|
|
45
|
-
dependencies,
|
|
46
|
-
appContext.appDirectory,
|
|
47
|
-
appContext.serverConfigFile
|
|
48
|
-
);
|
|
49
|
-
return [`${configPath}/html`, configFile || "./config", ...dependencies];
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
addServerConfigToDeps,
|
|
54
|
-
generateWatchFiles
|
|
55
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
function getServerInternalPlugins(api) {
|
|
41
|
-
return __async(this, null, function* () {
|
|
42
|
-
const hookRunners = api.useHookRunners();
|
|
43
|
-
const { plugins: serverPlugins } = yield hookRunners.collectServerPlugins({
|
|
44
|
-
plugins: []
|
|
45
|
-
});
|
|
46
|
-
const serverInternalPlugins = serverPlugins.reduce(
|
|
47
|
-
(result, plugin) => Object.assign(result, plugin),
|
|
48
|
-
{}
|
|
49
|
-
);
|
|
50
|
-
api.setAppContext(__spreadProps(__spreadValues({}, api.useAppContext()), {
|
|
51
|
-
serverInternalPlugins
|
|
52
|
-
}));
|
|
53
|
-
return serverInternalPlugins;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
getServerInternalPlugins
|
|
58
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
import { prettyInstructions, logger } from "@modern-js/utils";
|
|
22
|
-
const printInstructions = (hookRunners, appContext, config) => __async(void 0, null, function* () {
|
|
23
|
-
const message = prettyInstructions(appContext, config);
|
|
24
|
-
const { instructions } = yield hookRunners.beforePrintInstructions({
|
|
25
|
-
instructions: message
|
|
26
|
-
});
|
|
27
|
-
logger.info(instructions);
|
|
28
|
-
});
|
|
29
|
-
export {
|
|
30
|
-
printInstructions
|
|
31
|
-
};
|