@modern-js/app-tools 2.69.5 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/modern.js +2 -8
- package/dist/cjs/builder/builder-rspack/index.js +35 -27
- package/dist/cjs/builder/generator/adapterCopy.js +75 -46
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +83 -81
- package/dist/cjs/builder/generator/createCopyPattern.js +59 -58
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +80 -82
- package/dist/cjs/builder/generator/index.js +70 -85
- package/dist/cjs/builder/index.js +44 -47
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +106 -83
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +79 -74
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +131 -165
- package/dist/cjs/builder/shared/builderPlugins/builderHooks.js +47 -46
- package/dist/cjs/builder/shared/builderPlugins/index.js +76 -25
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +66 -49
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +51 -50
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +178 -317
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +69 -23
- package/dist/cjs/builder/shared/createCopyInfo.js +54 -43
- package/dist/cjs/builder/shared/index.js +69 -23
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +35 -23
- package/dist/cjs/builder/shared/types.js +17 -15
- package/dist/cjs/commands/build.js +107 -96
- package/dist/cjs/commands/deploy.js +40 -32
- package/dist/cjs/commands/dev.js +122 -141
- package/dist/cjs/commands/index.js +74 -121
- package/dist/cjs/commands/inspect.js +45 -39
- package/dist/cjs/commands/serve.js +87 -84
- package/dist/cjs/compat/hooks.js +97 -177
- package/dist/cjs/compat/index.js +57 -59
- package/dist/cjs/compat/utils.js +125 -116
- package/dist/cjs/config/default.js +118 -225
- package/dist/cjs/config/index.js +62 -23
- package/dist/cjs/config/initialize/index.js +37 -29
- package/dist/cjs/config/initialize/inits.js +92 -106
- package/dist/cjs/constants.js +37 -37
- package/dist/cjs/defineConfig.js +33 -35
- package/dist/cjs/esm/esbuild-loader.js +62 -0
- package/dist/cjs/esm/esbuild-loader.mjs +11 -23
- package/dist/cjs/esm/register-esm.js +85 -0
- package/dist/cjs/esm/register-esm.mjs +41 -54
- package/dist/cjs/esm/ts-node-loader.js +62 -0
- package/dist/cjs/esm/ts-node-loader.mjs +11 -23
- package/dist/cjs/esm/utils.js +69 -0
- package/dist/cjs/esm/utils.mjs +24 -36
- package/dist/cjs/exports/server.js +16 -26
- package/dist/cjs/index.js +288 -199
- package/dist/cjs/locale/en.js +70 -62
- package/dist/cjs/locale/index.js +42 -33
- package/dist/cjs/locale/zh.js +70 -62
- package/dist/cjs/plugins/analyze/constants.js +43 -36
- package/dist/cjs/plugins/analyze/getBundleEntry.js +90 -94
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +110 -137
- package/dist/cjs/plugins/analyze/getHtmlTemplate.js +125 -127
- package/dist/cjs/plugins/analyze/getServerRoutes.js +160 -164
- package/dist/cjs/plugins/analyze/index.js +221 -208
- package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +81 -76
- package/dist/cjs/plugins/analyze/templates.js +36 -28
- package/dist/cjs/plugins/analyze/utils.js +109 -104
- package/dist/cjs/plugins/deploy/index.js +64 -56
- package/dist/cjs/plugins/deploy/platforms/gh-pages.js +82 -86
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +35 -2
- package/dist/cjs/plugins/deploy/platforms/netlify-handler.js +86 -62
- package/dist/cjs/plugins/deploy/platforms/netlify.js +145 -157
- package/dist/cjs/plugins/deploy/platforms/node-entry.js +73 -45
- package/dist/cjs/plugins/deploy/platforms/node.js +113 -113
- package/dist/cjs/plugins/deploy/platforms/platform.js +17 -15
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +36 -2
- package/dist/cjs/plugins/deploy/platforms/vercel-handler.js +87 -63
- package/dist/cjs/plugins/deploy/platforms/vercel.js +165 -169
- package/dist/cjs/plugins/deploy/utils.js +85 -85
- package/dist/cjs/plugins/initialize/index.js +86 -91
- package/dist/cjs/plugins/serverBuild.js +85 -78
- package/dist/cjs/plugins/serverRuntime.js +46 -34
- package/dist/cjs/run/index.js +86 -128
- package/dist/cjs/types/config/deploy.js +17 -15
- package/dist/cjs/types/config/dev.js +17 -15
- package/dist/cjs/types/config/experiments.js +17 -15
- package/dist/cjs/types/config/html.js +17 -15
- package/dist/cjs/types/config/index.js +55 -19
- package/dist/cjs/types/config/output.js +17 -15
- package/dist/cjs/types/config/performance.js +17 -15
- package/dist/cjs/types/config/resolve.js +17 -15
- package/dist/cjs/types/config/security.js +17 -15
- package/dist/cjs/types/config/source.js +17 -15
- package/dist/cjs/types/config/testing.js +17 -15
- package/dist/cjs/types/config/tools.js +17 -15
- package/dist/cjs/types/index.js +55 -23
- package/dist/cjs/types/plugin.js +18 -0
- package/dist/cjs/types/utils.js +17 -15
- package/dist/cjs/utils/config.js +40 -80
- package/dist/cjs/utils/createServer.js +46 -47
- package/dist/cjs/utils/env.js +41 -35
- package/dist/cjs/utils/generateWatchFiles.js +49 -60
- package/dist/cjs/utils/getConfigFile.js +46 -38
- package/dist/cjs/utils/getSelectedEntries.js +55 -53
- package/dist/cjs/utils/initAppContext.js +66 -59
- package/dist/cjs/utils/loadPlugins.js +77 -70
- package/dist/cjs/utils/printInstructions.js +39 -31
- package/dist/cjs/utils/register.js +108 -117
- package/dist/cjs/utils/restart.js +46 -41
- package/dist/cjs/utils/routes.js +60 -52
- package/dist/cjs/utils/types.js +17 -15
- package/dist/esm/builder/builder-rspack/index.mjs +6 -0
- package/dist/esm/builder/generator/adapterCopy.mjs +35 -0
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +59 -0
- package/dist/esm/builder/generator/createCopyPattern.mjs +30 -0
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +56 -0
- package/dist/esm/builder/generator/index.mjs +45 -0
- package/dist/esm/builder/index.mjs +7 -0
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +78 -0
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +55 -0
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +117 -0
- package/dist/esm/builder/shared/builderPlugins/builderHooks.mjs +17 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +37 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.mjs +22 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +157 -0
- package/dist/esm/builder/shared/createCopyInfo.mjs +15 -0
- package/dist/esm/builder/shared/loaders/serverModuleLoader.mjs +5 -0
- package/dist/esm/commands/build.mjs +68 -0
- package/dist/esm/commands/deploy.mjs +10 -0
- package/dist/esm/commands/dev.mjs +82 -0
- package/dist/esm/commands/index.mjs +37 -0
- package/dist/esm/commands/inspect.mjs +15 -0
- package/dist/esm/commands/serve.mjs +47 -0
- package/dist/esm/compat/hooks.mjs +67 -0
- package/dist/esm/compat/index.mjs +28 -0
- package/dist/esm/compat/utils.mjs +95 -0
- package/dist/esm/config/default.mjs +90 -0
- package/dist/{esm-node/config/index.js → esm/config/index.mjs} +0 -1
- package/dist/esm/config/initialize/index.mjs +7 -0
- package/dist/esm/config/initialize/inits.mjs +54 -0
- package/dist/esm/constants.mjs +3 -0
- package/dist/esm/defineConfig.mjs +2 -0
- package/dist/esm/esm/esbuild-loader.mjs +18 -29
- package/dist/esm/esm/register-esm.mjs +45 -57
- package/dist/esm/esm/ts-node-loader.mjs +18 -30
- package/dist/esm/esm/utils.mjs +31 -42
- package/dist/esm/index.mjs +121 -0
- package/dist/esm/locale/en.mjs +42 -0
- package/dist/esm/locale/index.mjs +9 -0
- package/dist/esm/locale/zh.mjs +42 -0
- package/dist/esm/plugins/analyze/constants.mjs +8 -0
- package/dist/esm/plugins/analyze/getBundleEntry.mjs +53 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.mjs +66 -0
- package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +85 -0
- package/dist/esm/plugins/analyze/getServerRoutes.mjs +130 -0
- package/dist/esm/plugins/analyze/index.mjs +193 -0
- package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +41 -0
- package/dist/esm/plugins/analyze/templates.mjs +22 -0
- package/dist/esm/plugins/analyze/utils.mjs +55 -0
- package/dist/esm/plugins/deploy/index.mjs +38 -0
- package/dist/esm/plugins/deploy/platforms/gh-pages.mjs +43 -0
- package/dist/esm/plugins/deploy/platforms/netlify-entry.mjs +2 -1
- package/dist/esm/plugins/deploy/platforms/netlify-handler.mjs +85 -0
- package/dist/esm/plugins/deploy/platforms/netlify.mjs +111 -0
- package/dist/esm/plugins/deploy/platforms/node-entry.mjs +68 -0
- package/dist/esm/plugins/deploy/platforms/node.mjs +77 -0
- package/dist/esm/plugins/deploy/platforms/vercel-entry.mjs +3 -3
- package/dist/esm/plugins/deploy/platforms/vercel-handler.mjs +85 -0
- package/dist/esm/plugins/deploy/platforms/vercel.mjs +131 -0
- package/dist/esm/plugins/deploy/utils.mjs +39 -0
- package/dist/esm/plugins/initialize/index.mjs +59 -0
- package/dist/esm/plugins/serverBuild.mjs +48 -0
- package/dist/esm/plugins/serverRuntime.mjs +15 -0
- package/dist/esm/run/index.mjs +60 -0
- package/dist/esm/types/index.mjs +1 -0
- package/dist/esm/utils/config.mjs +11 -0
- package/dist/esm/utils/createServer.mjs +12 -0
- package/dist/esm/utils/env.mjs +12 -0
- package/dist/esm/utils/generateWatchFiles.mjs +10 -0
- package/dist/esm/utils/getConfigFile.mjs +5 -0
- package/dist/esm/utils/getSelectedEntries.mjs +26 -0
- package/dist/esm/utils/initAppContext.mjs +26 -0
- package/dist/esm/utils/loadPlugins.mjs +45 -0
- package/dist/esm/utils/printInstructions.mjs +9 -0
- package/dist/esm/utils/register.mjs +75 -0
- package/dist/esm/utils/restart.mjs +18 -0
- package/dist/esm/utils/routes.mjs +15 -0
- package/dist/esm-node/builder/builder-rspack/index.mjs +6 -0
- package/dist/esm-node/builder/generator/adapterCopy.mjs +35 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +59 -0
- package/dist/esm-node/builder/generator/createCopyPattern.mjs +30 -0
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +56 -0
- package/dist/esm-node/builder/generator/index.mjs +45 -0
- package/dist/esm-node/builder/index.mjs +7 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +78 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +55 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +117 -0
- package/dist/esm-node/builder/shared/builderPlugins/builderHooks.mjs +17 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.mjs +4 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +37 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.mjs +22 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +157 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +3 -0
- package/dist/esm-node/builder/shared/createCopyInfo.mjs +15 -0
- package/dist/esm-node/builder/shared/index.mjs +3 -0
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.mjs +5 -0
- package/dist/esm-node/commands/build.mjs +68 -0
- package/dist/esm-node/commands/deploy.mjs +10 -0
- package/dist/esm-node/commands/dev.mjs +82 -0
- package/dist/esm-node/commands/index.mjs +37 -0
- package/dist/esm-node/commands/inspect.mjs +15 -0
- package/dist/esm-node/commands/serve.mjs +47 -0
- package/dist/esm-node/compat/hooks.mjs +67 -0
- package/dist/esm-node/compat/index.mjs +28 -0
- package/dist/esm-node/compat/utils.mjs +95 -0
- package/dist/esm-node/config/default.mjs +90 -0
- package/dist/esm-node/config/index.mjs +2 -0
- package/dist/esm-node/config/initialize/index.mjs +7 -0
- package/dist/esm-node/config/initialize/inits.mjs +54 -0
- package/dist/esm-node/constants.mjs +3 -0
- package/dist/esm-node/defineConfig.mjs +2 -0
- package/dist/esm-node/esm/esbuild-loader.mjs +18 -29
- package/dist/esm-node/esm/register-esm.mjs +45 -57
- package/dist/esm-node/esm/ts-node-loader.mjs +18 -30
- package/dist/esm-node/esm/utils.mjs +31 -42
- package/dist/esm-node/index.mjs +121 -0
- package/dist/esm-node/locale/en.mjs +42 -0
- package/dist/esm-node/locale/index.mjs +9 -0
- package/dist/esm-node/locale/zh.mjs +42 -0
- package/dist/esm-node/plugins/analyze/constants.mjs +8 -0
- package/dist/esm-node/plugins/analyze/getBundleEntry.mjs +53 -0
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.mjs +66 -0
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +85 -0
- package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +130 -0
- package/dist/esm-node/plugins/analyze/index.mjs +193 -0
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +41 -0
- package/dist/esm-node/plugins/analyze/{templates.js → templates.mjs} +5 -7
- package/dist/esm-node/plugins/analyze/utils.mjs +55 -0
- package/dist/esm-node/plugins/deploy/index.mjs +38 -0
- package/dist/esm-node/plugins/deploy/platforms/gh-pages.mjs +43 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify-entry.mjs +2 -1
- package/dist/esm-node/plugins/deploy/platforms/netlify-handler.mjs +85 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +111 -0
- package/dist/esm-node/plugins/deploy/platforms/node-entry.mjs +68 -0
- package/dist/esm-node/plugins/deploy/platforms/node.mjs +77 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel-entry.mjs +3 -3
- package/dist/esm-node/plugins/deploy/platforms/vercel-handler.mjs +85 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +131 -0
- package/dist/esm-node/plugins/deploy/utils.mjs +39 -0
- package/dist/esm-node/plugins/initialize/index.mjs +59 -0
- package/dist/esm-node/plugins/serverBuild.mjs +48 -0
- package/dist/esm-node/plugins/serverRuntime.mjs +15 -0
- package/dist/esm-node/run/index.mjs +60 -0
- package/dist/esm-node/types/config/index.mjs +1 -0
- package/dist/esm-node/types/index.mjs +1 -0
- package/dist/esm-node/utils/config.mjs +11 -0
- package/dist/esm-node/utils/createServer.mjs +12 -0
- package/dist/esm-node/utils/env.mjs +12 -0
- package/dist/esm-node/utils/generateWatchFiles.mjs +10 -0
- package/dist/esm-node/utils/getConfigFile.mjs +5 -0
- package/dist/esm-node/utils/getSelectedEntries.mjs +26 -0
- package/dist/esm-node/utils/initAppContext.mjs +26 -0
- package/dist/esm-node/utils/loadPlugins.mjs +45 -0
- package/dist/esm-node/utils/printInstructions.mjs +9 -0
- package/dist/esm-node/utils/register.mjs +75 -0
- package/dist/esm-node/utils/restart.mjs +18 -0
- package/dist/esm-node/utils/routes.mjs +15 -0
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/generator/adapterCopy.d.ts +2 -3
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -3
- package/dist/types/builder/generator/createCopyPattern.d.ts +5 -5
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +4 -4
- package/dist/types/builder/generator/index.d.ts +2 -3
- package/dist/types/builder/index.d.ts +2 -2
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +1 -2
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -2
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -2
- package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +1 -2
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +4 -4
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +4 -4
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +3 -5
- package/dist/types/builder/shared/createCopyInfo.d.ts +4 -3
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +2 -2
- package/dist/types/builder/shared/types.d.ts +5 -5
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/index.d.ts +7 -9
- package/dist/types/commands/inspect.d.ts +2 -2
- package/dist/types/commands/serve.d.ts +2 -2
- package/dist/types/compat/hooks.d.ts +2 -2
- package/dist/types/compat/index.d.ts +2 -2
- package/dist/types/config/default.d.ts +3 -4
- package/dist/types/config/index.d.ts +0 -1
- package/dist/types/config/initialize/index.d.ts +2 -2
- package/dist/types/config/initialize/inits.d.ts +3 -4
- package/dist/types/constants.d.ts +0 -3
- package/dist/types/defineConfig.d.ts +7 -8
- package/dist/types/exports/server.d.ts +1 -5
- package/dist/types/index.d.ts +4 -5
- package/dist/types/locale/index.d.ts +1 -1
- package/dist/types/plugins/analyze/constants.d.ts +0 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +4 -4
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +3 -3
- package/dist/types/plugins/analyze/index.d.ts +2 -4
- package/dist/types/plugins/deploy/index.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
- package/dist/types/plugins/deploy/utils.d.ts +2 -2
- package/dist/types/plugins/initialize/index.d.ts +2 -4
- package/dist/types/plugins/serverBuild.d.ts +2 -2
- package/dist/types/plugins/serverRuntime.d.ts +2 -2
- package/dist/types/run/index.d.ts +3 -8
- package/dist/types/types/config/deploy.d.ts +0 -1
- package/dist/types/types/config/dev.d.ts +50 -9
- package/dist/types/types/config/experiments.d.ts +2 -2
- package/dist/types/types/config/html.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +10 -14
- package/dist/types/types/config/output.d.ts +8 -8
- package/dist/types/types/config/performance.d.ts +2 -2
- package/dist/types/types/config/resolve.d.ts +2 -2
- package/dist/types/types/config/security.d.ts +2 -2
- package/dist/types/types/config/source.d.ts +2 -23
- package/dist/types/types/config/tools.d.ts +5 -22
- package/dist/types/types/index.d.ts +7 -34
- package/dist/types/types/{new.d.ts → plugin.d.ts} +10 -39
- package/dist/types/types/utils.d.ts +0 -6
- package/dist/types/utils/config.d.ts +1 -11
- package/dist/types/utils/createServer.d.ts +1 -3
- package/dist/types/utils/env.d.ts +2 -2
- package/dist/types/utils/generateWatchFiles.d.ts +2 -3
- package/dist/types/utils/initAppContext.d.ts +1 -3
- package/dist/types/utils/loadPlugins.d.ts +5 -5
- package/dist/types/utils/printInstructions.d.ts +2 -2
- package/dist/types/utils/restart.d.ts +2 -2
- package/dist/types/utils/routes.d.ts +2 -3
- package/lib/types.d.ts +5 -16
- package/package.json +51 -38
- package/rslib.config.mts +20 -0
- package/dist/cjs/builder/builder-webpack/index.js +0 -50
- package/dist/cjs/config/legacy/createHtmlConfig.js +0 -45
- package/dist/cjs/config/legacy/createOutputConfig.js +0 -69
- package/dist/cjs/config/legacy/createSourceConfig.js +0 -53
- package/dist/cjs/config/legacy/createToolsConfig.js +0 -52
- package/dist/cjs/config/legacy/index.js +0 -68
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +0 -1
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +0 -3
- package/dist/cjs/types/hooks.js +0 -16
- package/dist/cjs/types/legacyConfig/deploy.js +0 -16
- package/dist/cjs/types/legacyConfig/dev.js +0 -16
- package/dist/cjs/types/legacyConfig/index.js +0 -16
- package/dist/cjs/types/legacyConfig/output.js +0 -16
- package/dist/cjs/types/legacyConfig/source.js +0 -16
- package/dist/cjs/types/legacyConfig/testing.js +0 -16
- package/dist/cjs/types/legacyConfig/tools.js +0 -16
- package/dist/cjs/types/new.js +0 -16
- package/dist/cjs/utils/getUserConfig.js +0 -34
- package/dist/esm/builder/builder-rspack/index.js +0 -30
- package/dist/esm/builder/builder-webpack/index.js +0 -48
- package/dist/esm/builder/generator/adapterCopy.js +0 -29
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -56
- package/dist/esm/builder/generator/createCopyPattern.js +0 -43
- package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -89
- package/dist/esm/builder/generator/index.js +0 -116
- package/dist/esm/builder/index.js +0 -50
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -92
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -262
- package/dist/esm/builder/shared/builderPlugins/builderHooks.js +0 -120
- package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -420
- package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm/builder/shared/index.js +0 -3
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm/commands/build.js +0 -142
- package/dist/esm/commands/deploy.js +0 -48
- package/dist/esm/commands/dev.js +0 -197
- package/dist/esm/commands/index.js +0 -401
- package/dist/esm/commands/inspect.js +0 -31
- package/dist/esm/commands/serve.js +0 -96
- package/dist/esm/compat/hooks.js +0 -503
- package/dist/esm/compat/index.js +0 -45
- package/dist/esm/compat/utils.js +0 -100
- package/dist/esm/config/default.js +0 -205
- package/dist/esm/config/index.js +0 -3
- package/dist/esm/config/initialize/index.js +0 -9
- package/dist/esm/config/initialize/inits.js +0 -89
- package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm/config/legacy/createSourceConfig.js +0 -46
- package/dist/esm/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm/config/legacy/index.js +0 -43
- package/dist/esm/constants.js +0 -12
- package/dist/esm/defineConfig.js +0 -16
- package/dist/esm/exports/server.js +0 -4
- package/dist/esm/index.js +0 -265
- package/dist/esm/locale/en.js +0 -44
- package/dist/esm/locale/index.js +0 -12
- package/dist/esm/locale/zh.js +0 -44
- package/dist/esm/plugins/analyze/constants.js +0 -14
- package/dist/esm/plugins/analyze/getBundleEntry.js +0 -108
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -268
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -251
- package/dist/esm/plugins/analyze/getServerRoutes.js +0 -148
- package/dist/esm/plugins/analyze/index.js +0 -439
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
- package/dist/esm/plugins/analyze/templates.js +0 -6
- package/dist/esm/plugins/analyze/utils.js +0 -106
- package/dist/esm/plugins/deploy/index.js +0 -133
- package/dist/esm/plugins/deploy/platforms/gh-pages.js +0 -184
- package/dist/esm/plugins/deploy/platforms/netlify-entry.js +0 -11
- package/dist/esm/plugins/deploy/platforms/netlify-handler.js +0 -207
- package/dist/esm/plugins/deploy/platforms/netlify.js +0 -346
- package/dist/esm/plugins/deploy/platforms/node-entry.js +0 -110
- package/dist/esm/plugins/deploy/platforms/node.js +0 -178
- package/dist/esm/plugins/deploy/platforms/vercel-entry.js +0 -11
- package/dist/esm/plugins/deploy/platforms/vercel-handler.js +0 -207
- package/dist/esm/plugins/deploy/platforms/vercel.js +0 -280
- package/dist/esm/plugins/deploy/utils.js +0 -59
- package/dist/esm/plugins/initialize/index.js +0 -116
- package/dist/esm/plugins/serverBuild.js +0 -83
- package/dist/esm/plugins/serverRuntime.js +0 -22
- package/dist/esm/run/index.js +0 -134
- package/dist/esm/types/config/index.js +0 -1
- package/dist/esm/types/config/source.js +0 -0
- package/dist/esm/types/config/testing.js +0 -0
- package/dist/esm/types/config/tools.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/legacyConfig/deploy.js +0 -0
- package/dist/esm/types/legacyConfig/dev.js +0 -0
- package/dist/esm/types/legacyConfig/index.js +0 -0
- package/dist/esm/types/legacyConfig/output.js +0 -0
- package/dist/esm/types/legacyConfig/source.js +0 -0
- package/dist/esm/types/legacyConfig/testing.js +0 -0
- package/dist/esm/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/new.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm/utils/config.js +0 -122
- package/dist/esm/utils/createServer.js +0 -58
- package/dist/esm/utils/env.js +0 -16
- package/dist/esm/utils/generateWatchFiles.js +0 -71
- package/dist/esm/utils/getConfigFile.js +0 -11
- package/dist/esm/utils/getSelectedEntries.js +0 -67
- package/dist/esm/utils/getUserConfig.js +0 -32
- package/dist/esm/utils/initAppContext.js +0 -30
- package/dist/esm/utils/loadPlugins.js +0 -162
- package/dist/esm/utils/printInstructions.js +0 -32
- package/dist/esm/utils/register.js +0 -182
- package/dist/esm/utils/restart.js +0 -68
- package/dist/esm/utils/routes.js +0 -42
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/index.js +0 -8
- package/dist/esm-node/builder/builder-webpack/index.js +0 -16
- package/dist/esm-node/builder/generator/adapterCopy.js +0 -26
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -67
- package/dist/esm-node/builder/generator/createCopyPattern.js +0 -41
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -68
- package/dist/esm-node/builder/generator/index.js +0 -60
- package/dist/esm-node/builder/index.js +0 -16
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -55
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -151
- package/dist/esm-node/builder/shared/builderPlugins/builderHooks.js +0 -26
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -305
- package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm-node/commands/build.js +0 -67
- package/dist/esm-node/commands/deploy.js +0 -12
- package/dist/esm-node/commands/dev.js +0 -111
- package/dist/esm-node/commands/index.js +0 -90
- package/dist/esm-node/commands/inspect.js +0 -19
- package/dist/esm-node/commands/serve.js +0 -54
- package/dist/esm-node/compat/hooks.js +0 -159
- package/dist/esm-node/compat/index.js +0 -40
- package/dist/esm-node/compat/utils.js +0 -100
- package/dist/esm-node/config/default.js +0 -206
- package/dist/esm-node/config/initialize/index.js +0 -9
- package/dist/esm-node/config/initialize/inits.js +0 -79
- package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
- package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm-node/config/legacy/index.js +0 -43
- package/dist/esm-node/constants.js +0 -12
- package/dist/esm-node/defineConfig.js +0 -13
- package/dist/esm-node/exports/server.js +0 -4
- package/dist/esm-node/index.js +0 -160
- package/dist/esm-node/locale/en.js +0 -44
- package/dist/esm-node/locale/index.js +0 -12
- package/dist/esm-node/locale/zh.js +0 -44
- package/dist/esm-node/plugins/analyze/constants.js +0 -14
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -67
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -108
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -99
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -146
- package/dist/esm-node/plugins/analyze/index.js +0 -184
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
- package/dist/esm-node/plugins/analyze/utils.js +0 -73
- package/dist/esm-node/plugins/deploy/index.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/gh-pages.js +0 -57
- package/dist/esm-node/plugins/deploy/platforms/netlify-entry.js +0 -11
- package/dist/esm-node/plugins/deploy/platforms/netlify-handler.js +0 -73
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -133
- package/dist/esm-node/plugins/deploy/platforms/node-entry.js +0 -46
- package/dist/esm-node/plugins/deploy/platforms/node.js +0 -87
- package/dist/esm-node/plugins/deploy/platforms/vercel-entry.js +0 -11
- package/dist/esm-node/plugins/deploy/platforms/vercel-handler.js +0 -73
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -145
- package/dist/esm-node/plugins/deploy/utils.js +0 -55
- package/dist/esm-node/plugins/initialize/index.js +0 -78
- package/dist/esm-node/plugins/serverBuild.js +0 -56
- package/dist/esm-node/plugins/serverRuntime.js +0 -17
- package/dist/esm-node/run/index.js +0 -104
- package/dist/esm-node/types/index.js +0 -3
- package/dist/esm-node/utils/config.js +0 -49
- package/dist/esm-node/utils/createServer.js +0 -26
- package/dist/esm-node/utils/env.js +0 -16
- package/dist/esm-node/utils/generateWatchFiles.js +0 -30
- package/dist/esm-node/utils/getConfigFile.js +0 -7
- package/dist/esm-node/utils/getSelectedEntries.js +0 -34
- package/dist/esm-node/utils/getUserConfig.js +0 -10
- package/dist/esm-node/utils/initAppContext.js +0 -29
- package/dist/esm-node/utils/loadPlugins.js +0 -52
- package/dist/esm-node/utils/printInstructions.js +0 -11
- package/dist/esm-node/utils/register.js +0 -94
- package/dist/esm-node/utils/restart.js +0 -23
- package/dist/esm-node/utils/routes.js +0 -21
- package/dist/types/builder/builder-webpack/index.d.ts +0 -2
- package/dist/types/config/legacy/createHtmlConfig.d.ts +0 -2
- package/dist/types/config/legacy/createOutputConfig.d.ts +0 -2
- package/dist/types/config/legacy/createSourceConfig.d.ts +0 -2
- package/dist/types/config/legacy/createToolsConfig.d.ts +0 -2
- package/dist/types/config/legacy/index.d.ts +0 -3
- package/dist/types/types/hooks.d.ts +0 -69
- package/dist/types/types/legacyConfig/deploy.d.ts +0 -8
- package/dist/types/types/legacyConfig/dev.d.ts +0 -12
- package/dist/types/types/legacyConfig/index.d.ts +0 -35
- package/dist/types/types/legacyConfig/output.d.ts +0 -50
- package/dist/types/types/legacyConfig/source.d.ts +0 -28
- package/dist/types/types/legacyConfig/testing.d.ts +0 -8
- package/dist/types/types/legacyConfig/tools.d.ts +0 -15
- package/dist/types/utils/getUserConfig.d.ts +0 -6
- /package/dist/{esm-node/builder/shared/builderPlugins/index.js → esm/builder/shared/builderPlugins/index.mjs} +0 -0
- /package/dist/{esm-node/builder/shared/bundlerPlugins/index.js → esm/builder/shared/bundlerPlugins/index.mjs} +0 -0
- /package/dist/{esm-node/builder/shared/index.js → esm/builder/shared/index.mjs} +0 -0
- /package/dist/{esm-node/types/legacyConfig/output.js → esm/builder/shared/types.mjs} +0 -0
- /package/dist/{esm-node/types/legacyConfig/source.js → esm/exports/server.mjs} +0 -0
- /package/dist/{esm-node/types/legacyConfig/testing.js → esm/plugins/deploy/platforms/platform.mjs} +0 -0
- /package/dist/{esm-node/types/legacyConfig/tools.js → esm/types/config/deploy.mjs} +0 -0
- /package/dist/{esm-node/types/new.js → esm/types/config/dev.mjs} +0 -0
- /package/dist/{esm-node/types/utils.js → esm/types/config/experiments.mjs} +0 -0
- /package/dist/{esm-node/utils/types.js → esm/types/config/html.mjs} +0 -0
- /package/dist/{esm-node/types/config/index.js → esm/types/config/index.mjs} +0 -0
- /package/dist/esm/{builder/shared/types.js → types/config/output.mjs} +0 -0
- /package/dist/esm/{plugins/deploy/platforms/platform.js → types/config/performance.mjs} +0 -0
- /package/dist/esm/types/config/{deploy.js → resolve.mjs} +0 -0
- /package/dist/esm/types/config/{dev.js → security.mjs} +0 -0
- /package/dist/esm/types/config/{experiments.js → source.mjs} +0 -0
- /package/dist/esm/types/config/{html.js → testing.mjs} +0 -0
- /package/dist/esm/types/config/{output.js → tools.mjs} +0 -0
- /package/dist/esm/types/{config/performance.js → plugin.mjs} +0 -0
- /package/dist/esm/types/{config/resolve.js → utils.mjs} +0 -0
- /package/dist/esm/{types/config/security.js → utils/types.mjs} +0 -0
- /package/dist/esm-node/builder/shared/{types.js → types.mjs} +0 -0
- /package/dist/esm-node/{plugins/deploy/platforms/platform.js → exports/server.mjs} +0 -0
- /package/dist/esm-node/{types/config/deploy.js → plugins/deploy/platforms/platform.mjs} +0 -0
- /package/dist/esm-node/types/config/{dev.js → deploy.mjs} +0 -0
- /package/dist/esm-node/types/config/{experiments.js → dev.mjs} +0 -0
- /package/dist/esm-node/types/config/{html.js → experiments.mjs} +0 -0
- /package/dist/esm-node/types/config/{output.js → html.mjs} +0 -0
- /package/dist/esm-node/types/config/{performance.js → output.mjs} +0 -0
- /package/dist/esm-node/types/config/{resolve.js → performance.mjs} +0 -0
- /package/dist/esm-node/types/config/{security.js → resolve.mjs} +0 -0
- /package/dist/esm-node/types/config/{source.js → security.mjs} +0 -0
- /package/dist/esm-node/types/config/{testing.js → source.mjs} +0 -0
- /package/dist/esm-node/types/config/{tools.js → testing.mjs} +0 -0
- /package/dist/esm-node/types/{hooks.js → config/tools.mjs} +0 -0
- /package/dist/esm-node/types/{legacyConfig/deploy.js → plugin.mjs} +0 -0
- /package/dist/esm-node/types/{legacyConfig/dev.js → utils.mjs} +0 -0
- /package/dist/esm-node/{types/legacyConfig/index.js → utils/types.mjs} +0 -0
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs, findExists } from "@modern-js/utils";
|
|
3
|
-
import { HTML_PARTIALS_EXTENSIONS, HTML_PARTIALS_FOLDER } from "./constants";
|
|
4
|
-
import * as templates from "./templates";
|
|
5
|
-
var PartialPosition;
|
|
6
|
-
(function(PartialPosition2) {
|
|
7
|
-
PartialPosition2["TOP"] = "top";
|
|
8
|
-
PartialPosition2["HEAD"] = "head";
|
|
9
|
-
PartialPosition2["BODY"] = "body";
|
|
10
|
-
PartialPosition2["BOTTOM"] = "bottom";
|
|
11
|
-
PartialPosition2["INDEX"] = "index";
|
|
12
|
-
})(PartialPosition || (PartialPosition = {}));
|
|
13
|
-
const findPartials = (dir, entryName, position) => {
|
|
14
|
-
if (fs.existsSync(dir)) {
|
|
15
|
-
const base = findExists(HTML_PARTIALS_EXTENSIONS.map((ext) => path.resolve(dir, `${position}${ext}`)));
|
|
16
|
-
const file = entryName ? findExists(HTML_PARTIALS_EXTENSIONS.map((ext) => path.resolve(dir, entryName, `${position}${ext}`))) || base : base;
|
|
17
|
-
return file ? {
|
|
18
|
-
file,
|
|
19
|
-
content: fs.readFileSync(file, "utf8")
|
|
20
|
-
} : null;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
const getModifyHtmlPartials = (partials) => {
|
|
25
|
-
const append = (type, ...script) => {
|
|
26
|
-
script.forEach((item) => {
|
|
27
|
-
partials[type].push(item);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const prepend = (type, ...script) => {
|
|
31
|
-
script.forEach((item) => {
|
|
32
|
-
partials[type].unshift(item);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
return {
|
|
36
|
-
top: {
|
|
37
|
-
append: (...script) => append("top", ...script),
|
|
38
|
-
prepend: (...script) => prepend("top", ...script),
|
|
39
|
-
current: partials.top
|
|
40
|
-
},
|
|
41
|
-
head: {
|
|
42
|
-
append: (...script) => append("head", ...script),
|
|
43
|
-
prepend: (...script) => prepend("head", ...script),
|
|
44
|
-
current: partials.head
|
|
45
|
-
},
|
|
46
|
-
body: {
|
|
47
|
-
append: (...script) => append("body", ...script),
|
|
48
|
-
prepend: (...script) => prepend("body", ...script),
|
|
49
|
-
current: partials.body
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const getHtmlTemplate = async (entrypoints, hooks, { appContext, config }) => {
|
|
54
|
-
const { appDirectory, internalDirectory } = appContext;
|
|
55
|
-
const { source: { configDir } } = config;
|
|
56
|
-
const htmlDir = path.resolve(appDirectory, configDir || "", HTML_PARTIALS_FOLDER);
|
|
57
|
-
const htmlTemplates = {};
|
|
58
|
-
const partialsByEntrypoint = {};
|
|
59
|
-
for (const entrypoint of entrypoints) {
|
|
60
|
-
const { entryName, isMainEntry } = entrypoint;
|
|
61
|
-
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
|
62
|
-
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
|
63
|
-
if (customIndexTemplate) {
|
|
64
|
-
htmlTemplates[entryName] = customIndexTemplate.file;
|
|
65
|
-
} else {
|
|
66
|
-
const getPartialInitValue = (position) => {
|
|
67
|
-
const partial = findPartials(htmlDir, name, position);
|
|
68
|
-
return partial ? [
|
|
69
|
-
partial.content
|
|
70
|
-
] : [];
|
|
71
|
-
};
|
|
72
|
-
const partials = {
|
|
73
|
-
top: getPartialInitValue("top"),
|
|
74
|
-
head: getPartialInitValue("head"),
|
|
75
|
-
body: getPartialInitValue("body")
|
|
76
|
-
};
|
|
77
|
-
await hooks.modifyHtmlPartials.call({
|
|
78
|
-
entrypoint,
|
|
79
|
-
partials: getModifyHtmlPartials(partials)
|
|
80
|
-
});
|
|
81
|
-
const templatePath = path.resolve(internalDirectory, entryName, "index.html");
|
|
82
|
-
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
|
83
|
-
htmlTemplates[entryName] = templatePath;
|
|
84
|
-
partialsByEntrypoint[entryName] = partials;
|
|
85
|
-
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
|
86
|
-
if (bottomTemplate) {
|
|
87
|
-
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
partialsByEntrypoint,
|
|
93
|
-
htmlTemplates
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
export {
|
|
97
|
-
getHtmlTemplate,
|
|
98
|
-
getModifyHtmlPartials
|
|
99
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
|
|
3
|
-
import { isMainEntry } from "../../utils/routes";
|
|
4
|
-
import { walkDirectory } from "./utils";
|
|
5
|
-
const applyBaseUrl = (baseUrl, routes) => {
|
|
6
|
-
if (baseUrl) {
|
|
7
|
-
if (Array.isArray(baseUrl)) {
|
|
8
|
-
return baseUrl.reduce((previous, current) => [
|
|
9
|
-
...previous,
|
|
10
|
-
...applyBaseUrl(current, routes)
|
|
11
|
-
], []);
|
|
12
|
-
} else {
|
|
13
|
-
return routes.map((route) => {
|
|
14
|
-
const urlPath = urlJoin(baseUrl, route.urlPath);
|
|
15
|
-
return {
|
|
16
|
-
...route,
|
|
17
|
-
urlPath: urlPath === "/" ? urlPath : removeTailSlash(urlPath)
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return routes;
|
|
23
|
-
};
|
|
24
|
-
const applyRouteOptions = (original, routeOptions) => {
|
|
25
|
-
const { route, disableSpa } = routeOptions;
|
|
26
|
-
original.isSPA = !disableSpa;
|
|
27
|
-
!original.isSPA && (original.entryPath = path.dirname(original.entryPath));
|
|
28
|
-
let routes;
|
|
29
|
-
if (route) {
|
|
30
|
-
if (Array.isArray(route)) {
|
|
31
|
-
routes = route.map((url) => {
|
|
32
|
-
if (isPlainObject(url)) {
|
|
33
|
-
const { path: urlPath, ...other } = url;
|
|
34
|
-
return {
|
|
35
|
-
...original,
|
|
36
|
-
...other,
|
|
37
|
-
urlPath
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
return {
|
|
41
|
-
...original,
|
|
42
|
-
urlPath: url
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
} else if (isPlainObject(route)) {
|
|
47
|
-
const { path: urlPath, ...other } = route;
|
|
48
|
-
routes = [
|
|
49
|
-
{
|
|
50
|
-
...original,
|
|
51
|
-
...other,
|
|
52
|
-
urlPath
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
} else {
|
|
56
|
-
routes = [
|
|
57
|
-
{
|
|
58
|
-
...original,
|
|
59
|
-
urlPath: route
|
|
60
|
-
}
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
routes = [
|
|
65
|
-
original
|
|
66
|
-
];
|
|
67
|
-
}
|
|
68
|
-
return routes;
|
|
69
|
-
};
|
|
70
|
-
const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
71
|
-
var _deploy_worker;
|
|
72
|
-
const { source: { mainEntryName }, html: { disableHtmlFolder, outputStructure }, output: { distPath: { html: htmlPath } = {} }, server: { baseUrl, routes, ssr, ssrByEntries, rsc }, deploy } = config;
|
|
73
|
-
const { packageName } = appContext;
|
|
74
|
-
const workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
|
|
75
|
-
let htmlRoutes = entrypoints.reduce((previous, { entryName }) => {
|
|
76
|
-
const isMain = isMainEntry(entryName, mainEntryName);
|
|
77
|
-
const entryOptions = getEntryOptions(entryName, isMain, ssr, ssrByEntries, packageName);
|
|
78
|
-
const isSSR = Boolean(entryOptions);
|
|
79
|
-
const isWorker = Boolean(workerSSR);
|
|
80
|
-
const isStream = typeof entryOptions === "object" && entryOptions.mode === "stream";
|
|
81
|
-
const { resHeaders } = (routes === null || routes === void 0 ? void 0 : routes[entryName]) || {};
|
|
82
|
-
const isRSC = !!rsc;
|
|
83
|
-
let route = {
|
|
84
|
-
urlPath: `/${isMain ? "" : entryName}`,
|
|
85
|
-
entryName,
|
|
86
|
-
entryPath: removeLeadingSlash(path.posix.normalize(`${htmlPath}/${entryName}${disableHtmlFolder || outputStructure === "flat" ? ".html" : "/index.html"}`)),
|
|
87
|
-
isSPA: true,
|
|
88
|
-
isStream: isStream || isRSC,
|
|
89
|
-
isSSR,
|
|
90
|
-
isRSC,
|
|
91
|
-
responseHeaders: resHeaders,
|
|
92
|
-
worker: isWorker ? `${SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
|
93
|
-
bundle: isSSR || isRSC ? `${SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
|
94
|
-
};
|
|
95
|
-
if (routes === null || routes === void 0 ? void 0 : routes.hasOwnProperty(entryName)) {
|
|
96
|
-
const routeOptions = isPlainObject(routes[entryName]) ? routes[entryName] : {
|
|
97
|
-
route: routes[entryName]
|
|
98
|
-
};
|
|
99
|
-
route = applyRouteOptions(route, routeOptions);
|
|
100
|
-
}
|
|
101
|
-
return Array.isArray(route) ? [
|
|
102
|
-
...previous,
|
|
103
|
-
...route
|
|
104
|
-
] : [
|
|
105
|
-
...previous,
|
|
106
|
-
route
|
|
107
|
-
];
|
|
108
|
-
}, []);
|
|
109
|
-
htmlRoutes = applyBaseUrl(baseUrl, htmlRoutes);
|
|
110
|
-
return htmlRoutes;
|
|
111
|
-
};
|
|
112
|
-
const collectStaticRoutes = (appContext, config) => {
|
|
113
|
-
const { appDirectory } = appContext;
|
|
114
|
-
const { source: { configDir }, server: { publicRoutes = {} } } = config;
|
|
115
|
-
const publicFolder = path.resolve(appDirectory, configDir || "", "public");
|
|
116
|
-
const ignoreFiles = [
|
|
117
|
-
".gitkeep"
|
|
118
|
-
];
|
|
119
|
-
return fs.existsSync(publicFolder) ? walkDirectory(publicFolder).filter((filePath) => !ignoreFiles.includes(path.basename(filePath))).map((filePath) => {
|
|
120
|
-
const urlPath = `${urlJoin(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
|
121
|
-
return {
|
|
122
|
-
urlPath: publicRoutes[removeLeadingSlash(urlPath)] || urlPath,
|
|
123
|
-
isSPA: true,
|
|
124
|
-
isSSR: false,
|
|
125
|
-
entryPath: toPosix(path.relative(path.resolve(appDirectory, configDir || ""), filePath))
|
|
126
|
-
};
|
|
127
|
-
}) : [];
|
|
128
|
-
};
|
|
129
|
-
const getServerRoutes = (entrypoints, { appContext, config }) => [
|
|
130
|
-
...collectHtmlRoutes(entrypoints, appContext, config),
|
|
131
|
-
...collectStaticRoutes(appContext, config)
|
|
132
|
-
];
|
|
133
|
-
const toPosix = (pathStr) => pathStr.split(path.sep).join(path.posix.sep);
|
|
134
|
-
const getProdServerRoutes = (distDirectory) => {
|
|
135
|
-
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
136
|
-
try {
|
|
137
|
-
const { routes } = fs.readJSONSync(routeJSON);
|
|
138
|
-
return routes;
|
|
139
|
-
} catch (e) {
|
|
140
|
-
throw new Error(`Failed to read routes from ${routeJSON}, please check if the file exists.`);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
export {
|
|
144
|
-
getProdServerRoutes,
|
|
145
|
-
getServerRoutes
|
|
146
|
-
};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { fs, createDebugger, getArgv, isApiOnly, isDevCommand, minimist } from "@modern-js/utils";
|
|
3
|
-
import { createBuilderGenerator } from "../../builder";
|
|
4
|
-
import { initialNormalizedConfig } from "../../config";
|
|
5
|
-
import { emitResolvedConfig } from "../../utils/config";
|
|
6
|
-
import { getSelectedEntries } from "../../utils/getSelectedEntries";
|
|
7
|
-
import { printInstructions } from "../../utils/printInstructions";
|
|
8
|
-
import { generateRoutes } from "../../utils/routes";
|
|
9
|
-
import { checkIsBuildCommands, checkIsServeCommand } from "./utils";
|
|
10
|
-
const debug = createDebugger("plugin-analyze");
|
|
11
|
-
var analyze_default = ({ bundler }) => ({
|
|
12
|
-
name: "@modern-js/plugin-analyze",
|
|
13
|
-
post: [
|
|
14
|
-
"@modern-js/runtime"
|
|
15
|
-
],
|
|
16
|
-
setup: (api) => {
|
|
17
|
-
let pagesDir = [];
|
|
18
|
-
let nestedRouteEntries = [];
|
|
19
|
-
api.onPrepare(async () => {
|
|
20
|
-
var _resolvedConfig_source;
|
|
21
|
-
let appContext = api.getAppContext();
|
|
22
|
-
const resolvedConfig = api.getNormalizedConfig();
|
|
23
|
-
const hooks = api.getHooks();
|
|
24
|
-
try {
|
|
25
|
-
if (checkIsBuildCommands()) {
|
|
26
|
-
fs.emptydirSync(appContext.internalDirectory);
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
const apiOnly = await isApiOnly(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
|
|
31
|
-
await hooks.addRuntimeExports.call();
|
|
32
|
-
const [{ getProdServerRoutes }] = await Promise.all([
|
|
33
|
-
import("./getServerRoutes.js")
|
|
34
|
-
]);
|
|
35
|
-
if (apiOnly) {
|
|
36
|
-
const routes2 = [];
|
|
37
|
-
if (checkIsServeCommand()) {
|
|
38
|
-
routes2.push(...getProdServerRoutes(appContext.distDirectory));
|
|
39
|
-
} else {
|
|
40
|
-
const { routes: modifiedRoutes } = await hooks.modifyServerRoutes.call({
|
|
41
|
-
routes: []
|
|
42
|
-
});
|
|
43
|
-
routes2.push(...modifiedRoutes);
|
|
44
|
-
}
|
|
45
|
-
debug(`server routes: %o`, routes2);
|
|
46
|
-
api.updateAppContext({
|
|
47
|
-
apiOnly,
|
|
48
|
-
serverRoutes: routes2
|
|
49
|
-
});
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const [{ getBundleEntry }, { getServerRoutes }, { getHtmlTemplate }] = await Promise.all([
|
|
53
|
-
import("./getBundleEntry.js"),
|
|
54
|
-
import("./getServerRoutes.js"),
|
|
55
|
-
import("./getHtmlTemplate.js")
|
|
56
|
-
]);
|
|
57
|
-
const { entrypoints } = await hooks.modifyEntrypoints.call({
|
|
58
|
-
entrypoints: await getBundleEntry(hooks, appContext, resolvedConfig)
|
|
59
|
-
});
|
|
60
|
-
debug(`entrypoints: %o`, entrypoints);
|
|
61
|
-
const routes = [];
|
|
62
|
-
if (checkIsServeCommand()) {
|
|
63
|
-
routes.push(...getProdServerRoutes(appContext.distDirectory));
|
|
64
|
-
} else {
|
|
65
|
-
const initialRoutes = getServerRoutes(entrypoints, {
|
|
66
|
-
appContext,
|
|
67
|
-
config: resolvedConfig
|
|
68
|
-
});
|
|
69
|
-
const { routes: modifiedRoutes } = await hooks.modifyServerRoutes.call({
|
|
70
|
-
routes: initialRoutes
|
|
71
|
-
});
|
|
72
|
-
routes.push(...modifiedRoutes);
|
|
73
|
-
}
|
|
74
|
-
debug(`server routes: %o`, routes);
|
|
75
|
-
appContext = {
|
|
76
|
-
...api.getAppContext(),
|
|
77
|
-
entrypoints,
|
|
78
|
-
serverRoutes: routes
|
|
79
|
-
};
|
|
80
|
-
api.updateAppContext(appContext);
|
|
81
|
-
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
82
|
-
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
|
|
83
|
-
const { partialsByEntrypoint, htmlTemplates } = await getHtmlTemplate(entrypoints, hooks, {
|
|
84
|
-
appContext,
|
|
85
|
-
config: resolvedConfig
|
|
86
|
-
});
|
|
87
|
-
debug(`html templates: %o`, htmlTemplates);
|
|
88
|
-
api.updateAppContext({
|
|
89
|
-
partialsByEntrypoint
|
|
90
|
-
});
|
|
91
|
-
let checkedEntries = entrypoints.map((point) => point.entryName);
|
|
92
|
-
if (isDevCommand()) {
|
|
93
|
-
const { entry } = minimist(getArgv());
|
|
94
|
-
checkedEntries = await getSelectedEntries(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
|
|
95
|
-
}
|
|
96
|
-
appContext = {
|
|
97
|
-
...api.getAppContext(),
|
|
98
|
-
entrypoints,
|
|
99
|
-
checkedEntries,
|
|
100
|
-
apiOnly,
|
|
101
|
-
serverRoutes: routes,
|
|
102
|
-
htmlTemplates
|
|
103
|
-
};
|
|
104
|
-
api.updateAppContext(appContext);
|
|
105
|
-
if (checkIsBuildCommands()) {
|
|
106
|
-
await hooks.generateEntryCode.call({
|
|
107
|
-
entrypoints
|
|
108
|
-
});
|
|
109
|
-
const normalizedConfig = api.getNormalizedConfig();
|
|
110
|
-
const createBuilderForModern = await createBuilderGenerator(bundler);
|
|
111
|
-
const builder = await createBuilderForModern({
|
|
112
|
-
normalizedConfig,
|
|
113
|
-
appContext
|
|
114
|
-
});
|
|
115
|
-
builder.onBeforeBuild(async ({ bundlerConfigs, isFirstCompile, environments, isWatch }) => {
|
|
116
|
-
if (!isFirstCompile) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
await generateRoutes(appContext);
|
|
120
|
-
await hooks.onBeforeBuild.call({
|
|
121
|
-
isFirstCompile,
|
|
122
|
-
isWatch,
|
|
123
|
-
environments,
|
|
124
|
-
bundlerConfigs
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
builder.onAfterBuild(async ({ stats, environments, isFirstCompile, isWatch }) => {
|
|
128
|
-
await hooks.onAfterBuild.call({
|
|
129
|
-
stats,
|
|
130
|
-
environments,
|
|
131
|
-
isFirstCompile,
|
|
132
|
-
isWatch
|
|
133
|
-
});
|
|
134
|
-
await emitResolvedConfig(appContext.appDirectory, normalizedConfig);
|
|
135
|
-
});
|
|
136
|
-
builder.onDevCompileDone(async ({ isFirstCompile, stats, environments }) => {
|
|
137
|
-
hooks.onDevCompileDone.call({
|
|
138
|
-
isFirstCompile,
|
|
139
|
-
stats,
|
|
140
|
-
environments
|
|
141
|
-
});
|
|
142
|
-
if (isFirstCompile) {
|
|
143
|
-
printInstructions(hooks, appContext, normalizedConfig);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
builder.onBeforeCreateCompiler(async ({ bundlerConfigs, environments }) => {
|
|
147
|
-
await hooks.onBeforeCreateCompiler.call({
|
|
148
|
-
environments,
|
|
149
|
-
bundlerConfigs
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
builder.onAfterCreateCompiler(async ({ compiler, environments }) => {
|
|
153
|
-
await hooks.onAfterCreateCompiler.call({
|
|
154
|
-
environments,
|
|
155
|
-
compiler
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
builder.onAfterStartDevServer(async ({ port }) => {
|
|
159
|
-
await hooks.onAfterDev.call({
|
|
160
|
-
port
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
builder.addPlugins(resolvedConfig.builderPlugins);
|
|
164
|
-
api.updateAppContext({
|
|
165
|
-
builder
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
api.addWatchFiles(() => {
|
|
170
|
-
return {
|
|
171
|
-
files: pagesDir,
|
|
172
|
-
isPrivate: true
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
api.modifyResolvedConfig((resolved) => {
|
|
176
|
-
const appContext = api.getAppContext();
|
|
177
|
-
const config = initialNormalizedConfig(resolved, appContext, bundler);
|
|
178
|
-
return config;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
export {
|
|
183
|
-
analyze_default as default
|
|
184
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { parse } from "@babel/parser";
|
|
3
|
-
import traverse from "@babel/traverse";
|
|
4
|
-
import * as t from "@babel/types";
|
|
5
|
-
const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
|
6
|
-
const isDefaultExportFunction = (file) => {
|
|
7
|
-
if (!file || !fs.existsSync(file)) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
const ast = parse(fs.readFileSync(file, "utf8"), {
|
|
11
|
-
sourceType: "unambiguous",
|
|
12
|
-
plugins: [
|
|
13
|
-
"jsx",
|
|
14
|
-
"typescript",
|
|
15
|
-
"classProperties",
|
|
16
|
-
"dynamicImport",
|
|
17
|
-
"exportDefaultFrom",
|
|
18
|
-
"exportNamespaceFrom",
|
|
19
|
-
"decorators-legacy",
|
|
20
|
-
"functionBind",
|
|
21
|
-
"classPrivateMethods",
|
|
22
|
-
[
|
|
23
|
-
"pipelineOperator",
|
|
24
|
-
{
|
|
25
|
-
proposal: "minimal"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"optionalChaining",
|
|
29
|
-
"optionalCatchBinding",
|
|
30
|
-
"objectRestSpread",
|
|
31
|
-
"numericSeparator"
|
|
32
|
-
]
|
|
33
|
-
});
|
|
34
|
-
let isExportFunction = false;
|
|
35
|
-
traverse(ast, {
|
|
36
|
-
ExportDefaultDeclaration: (path) => {
|
|
37
|
-
const { declaration } = path.node;
|
|
38
|
-
if (isFunction(declaration)) {
|
|
39
|
-
isExportFunction = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return isExportFunction;
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
isDefaultExportFunction
|
|
47
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { JS_EXTENSIONS, getCommand, normalizeToPosixPath } from "@modern-js/utils";
|
|
4
|
-
import { parse } from "es-module-lexer";
|
|
5
|
-
import { transform } from "esbuild";
|
|
6
|
-
const walkDirectory = (dir) => fs.readdirSync(dir).reduce((previous, filename) => {
|
|
7
|
-
const filePath = path.join(dir, filename);
|
|
8
|
-
if (fs.statSync(filePath).isDirectory()) {
|
|
9
|
-
return [
|
|
10
|
-
...previous,
|
|
11
|
-
...walkDirectory(filePath)
|
|
12
|
-
];
|
|
13
|
-
} else {
|
|
14
|
-
return [
|
|
15
|
-
...previous,
|
|
16
|
-
filePath
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
}, []);
|
|
20
|
-
const replaceWithAlias = (base, filePath, alias) => {
|
|
21
|
-
if (filePath.includes(base)) {
|
|
22
|
-
return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
23
|
-
} else {
|
|
24
|
-
return filePath;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const parseModule = async ({ source, filename }) => {
|
|
28
|
-
let content = source;
|
|
29
|
-
if (JS_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
30
|
-
const result = await transform(content, {
|
|
31
|
-
loader: path.extname(filename).slice(1),
|
|
32
|
-
format: "esm"
|
|
33
|
-
});
|
|
34
|
-
content = result.code;
|
|
35
|
-
}
|
|
36
|
-
return await parse(content);
|
|
37
|
-
};
|
|
38
|
-
const getServerCombinedModueFile = (internalDirectory, entryName) => {
|
|
39
|
-
return path.join(internalDirectory, entryName, "server-loader-combined.js");
|
|
40
|
-
};
|
|
41
|
-
const checkIsBuildCommands = () => {
|
|
42
|
-
const buildCommands = [
|
|
43
|
-
"dev",
|
|
44
|
-
"start",
|
|
45
|
-
"build",
|
|
46
|
-
"inspect",
|
|
47
|
-
"deploy",
|
|
48
|
-
"dev-worker"
|
|
49
|
-
];
|
|
50
|
-
const command = getCommand();
|
|
51
|
-
return buildCommands.includes(command);
|
|
52
|
-
};
|
|
53
|
-
const checkIsServeCommand = () => {
|
|
54
|
-
const command = getCommand();
|
|
55
|
-
return command === "serve";
|
|
56
|
-
};
|
|
57
|
-
const isSubDirOrEqual = (parent, child) => {
|
|
58
|
-
if (parent === child) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
const relative = path.relative(parent, child);
|
|
62
|
-
const isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
63
|
-
return Boolean(isSubdir);
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
checkIsBuildCommands,
|
|
67
|
-
checkIsServeCommand,
|
|
68
|
-
getServerCombinedModueFile,
|
|
69
|
-
isSubDirOrEqual,
|
|
70
|
-
parseModule,
|
|
71
|
-
replaceWithAlias,
|
|
72
|
-
walkDirectory
|
|
73
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { provider } from "std-env";
|
|
2
|
-
import { createGhPagesPreset } from "./platforms/gh-pages";
|
|
3
|
-
import { createNetlifyPreset } from "./platforms/netlify";
|
|
4
|
-
import { createNodePreset } from "./platforms/node";
|
|
5
|
-
import { createVercelPreset } from "./platforms/vercel";
|
|
6
|
-
import { getProjectUsage } from "./utils";
|
|
7
|
-
const deployPresets = {
|
|
8
|
-
node: createNodePreset,
|
|
9
|
-
vercel: createVercelPreset,
|
|
10
|
-
netlify: createNetlifyPreset,
|
|
11
|
-
ghPages: createGhPagesPreset
|
|
12
|
-
};
|
|
13
|
-
async function getDeployPreset(appContext, modernConfig, deployTarget) {
|
|
14
|
-
const { appDirectory, distDirectory, metaName } = appContext;
|
|
15
|
-
const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory, metaName);
|
|
16
|
-
const needModernServer = useSSR || useAPI || useWebServer;
|
|
17
|
-
const createPreset = deployPresets[deployTarget];
|
|
18
|
-
if (!createPreset) {
|
|
19
|
-
throw new Error(`Unknown deploy target: '${deployTarget}'. MODERNJS_DEPLOY should be 'node', 'vercel', or 'netlify'.`);
|
|
20
|
-
}
|
|
21
|
-
return createPreset(appContext, modernConfig, needModernServer);
|
|
22
|
-
}
|
|
23
|
-
var deploy_default = () => ({
|
|
24
|
-
name: "@modern-js/plugin-deploy",
|
|
25
|
-
setup: (api) => {
|
|
26
|
-
const deployTarget = process.env.MODERNJS_DEPLOY || provider || "node";
|
|
27
|
-
api.deploy(async () => {
|
|
28
|
-
const appContext = api.getAppContext();
|
|
29
|
-
const { metaName } = appContext;
|
|
30
|
-
if (metaName !== "modern-js" && !process.env.MODERNJS_DEPLOY) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const modernConfig = api.getNormalizedConfig();
|
|
34
|
-
const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget);
|
|
35
|
-
(deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.prepare());
|
|
36
|
-
(deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.writeOutput());
|
|
37
|
-
(deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.genEntry());
|
|
38
|
-
(deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end) && await (deployPreset === null || deployPreset === void 0 ? void 0 : deployPreset.end());
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
export {
|
|
43
|
-
deploy_default as default
|
|
44
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs } from "@modern-js/utils";
|
|
3
|
-
import { logger } from "@modern-js/utils";
|
|
4
|
-
async function reorganizeHtmlFiles(routes, baseDir, baseUrl = "/") {
|
|
5
|
-
if (!routes || !Array.isArray(routes)) {
|
|
6
|
-
logger.error("Invalid server routes");
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
await fs.ensureDir(baseDir);
|
|
10
|
-
const baseUrlRegexp = new RegExp(`^${baseUrl}\\/?`);
|
|
11
|
-
const collectedEntryPaths = /* @__PURE__ */ new Set();
|
|
12
|
-
const copyPromises = routes.map(async (route) => {
|
|
13
|
-
const { urlPath, entryPath } = route;
|
|
14
|
-
if (!entryPath) {
|
|
15
|
-
logger.warn(`Route ${urlPath} does not specify entryPath, skipping`);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (collectedEntryPaths.has(entryPath)) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
collectedEntryPaths.add(entryPath);
|
|
22
|
-
const sourceHtmlPath = path.join(baseDir, entryPath);
|
|
23
|
-
if (!await fs.pathExists(sourceHtmlPath)) {
|
|
24
|
-
logger.error(`Source HTML file does not exist: ${sourceHtmlPath}`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const targetDir = urlPath.replace(baseUrlRegexp, "");
|
|
28
|
-
await fs.ensureDir(path.dirname(targetDir));
|
|
29
|
-
const targetHtmlPath = path.join(baseDir, targetDir, "index.html");
|
|
30
|
-
try {
|
|
31
|
-
await fs.move(sourceHtmlPath, targetHtmlPath);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
logger.error(`Failed to copy HTML file: ${error.message}`);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
await Promise.all(copyPromises);
|
|
37
|
-
}
|
|
38
|
-
const createGhPagesPreset = (appContext, modernConfig) => {
|
|
39
|
-
const { serverRoutes, appDirectory, distDirectory } = appContext;
|
|
40
|
-
const { server: { baseUrl } } = modernConfig;
|
|
41
|
-
const outputDirectory = path.join(appDirectory, ".output");
|
|
42
|
-
return {
|
|
43
|
-
name: "gh-pages",
|
|
44
|
-
async prepare() {
|
|
45
|
-
await fs.remove(outputDirectory);
|
|
46
|
-
},
|
|
47
|
-
async writeOutput() {
|
|
48
|
-
await fs.copy(distDirectory, outputDirectory);
|
|
49
|
-
},
|
|
50
|
-
async end() {
|
|
51
|
-
await reorganizeHtmlFiles(serverRoutes, outputDirectory, Array.isArray(baseUrl) ? baseUrl[0] : baseUrl);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export {
|
|
56
|
-
createGhPagesPreset
|
|
57
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
var require_netlify_entry = __commonJS({
|
|
6
|
-
"src/plugins/deploy/platforms/netlify-entry.cjs"(exports, module) {
|
|
7
|
-
const { handler } = require("./netlify-handler.cjs");
|
|
8
|
-
module.exports.default = handler;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
export default require_netlify_entry();
|