@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.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/LICENSE +21 -0
- package/README.md +26 -0
- package/bin/modern.js +36 -0
- package/dist/cjs/baseline.js +83 -0
- package/dist/cjs/builder/builder-rspack/index.js +40 -0
- package/dist/cjs/builder/generator/adapterCopy.js +79 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +100 -0
- package/dist/cjs/builder/generator/createCopyPattern.js +67 -0
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +90 -0
- package/dist/cjs/builder/generator/index.js +80 -0
- package/dist/cjs/builder/index.js +50 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +133 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +89 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +112 -0
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +151 -0
- package/dist/cjs/builder/shared/builderPlugins/builderHooks.js +51 -0
- package/dist/cjs/builder/shared/builderPlugins/index.js +86 -0
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +71 -0
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +56 -0
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +191 -0
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +72 -0
- package/dist/cjs/builder/shared/createCopyInfo.js +59 -0
- package/dist/cjs/builder/shared/index.js +72 -0
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +39 -0
- package/dist/cjs/builder/shared/types.js +18 -0
- package/dist/cjs/commands/build.js +107 -0
- package/dist/cjs/commands/deploy.js +44 -0
- package/dist/cjs/commands/dev.js +121 -0
- package/dist/cjs/commands/index.js +99 -0
- package/dist/cjs/commands/info.js +110 -0
- package/dist/cjs/commands/inspect.js +49 -0
- package/dist/cjs/commands/runtime.js +159 -0
- package/dist/cjs/commands/serve.js +92 -0
- package/dist/cjs/compat/hooks.js +104 -0
- package/dist/cjs/compat/index.js +62 -0
- package/dist/cjs/compat/utils.js +135 -0
- package/dist/cjs/config/default.js +125 -0
- package/dist/cjs/config/index.js +65 -0
- package/dist/cjs/config/initialize/index.js +41 -0
- package/dist/cjs/config/initialize/inits.js +101 -0
- package/dist/cjs/constants.js +40 -0
- package/dist/cjs/defineConfig.js +36 -0
- package/dist/cjs/esm/register-esm.js +48 -0
- package/dist/cjs/esm/register-esm.mjs +10 -0
- package/dist/cjs/esm/ts-paths-loader.js +73 -0
- package/dist/cjs/esm/ts-paths-loader.mjs +35 -0
- package/dist/cjs/exports/server.js +18 -0
- package/dist/cjs/index.js +358 -0
- package/dist/cjs/locale/en.js +79 -0
- package/dist/cjs/locale/index.js +46 -0
- package/dist/cjs/locale/zh.js +79 -0
- package/dist/cjs/plugins/analyze/constants.js +48 -0
- package/dist/cjs/plugins/analyze/getBundleEntry.js +97 -0
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +117 -0
- package/dist/cjs/plugins/analyze/getHtmlTemplate.js +144 -0
- package/dist/cjs/plugins/analyze/getServerRoutes.js +177 -0
- package/dist/cjs/plugins/analyze/index.js +237 -0
- package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +86 -0
- package/dist/cjs/plugins/analyze/templates.js +56 -0
- package/dist/cjs/plugins/analyze/utils.js +126 -0
- package/dist/cjs/plugins/deploy/index.js +77 -0
- package/dist/cjs/plugins/deploy/platforms/gh-pages.js +87 -0
- package/dist/cjs/plugins/deploy/platforms/netlify.js +140 -0
- package/dist/cjs/plugins/deploy/platforms/node.js +100 -0
- package/dist/cjs/plugins/deploy/platforms/platform.js +18 -0
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +46 -0
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +57 -0
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/cjs/plugins/deploy/platforms/vercel.js +159 -0
- package/dist/cjs/plugins/deploy/types.js +18 -0
- package/dist/cjs/plugins/deploy/utils/generator.js +104 -0
- package/dist/cjs/plugins/deploy/utils/index.js +123 -0
- package/dist/cjs/plugins/initialize/index.js +93 -0
- package/dist/cjs/plugins/serverBuild.js +90 -0
- package/dist/cjs/plugins/serverRuntime.js +49 -0
- package/dist/cjs/presetUltramodern.js +41 -0
- package/dist/cjs/rsbuild.js +90 -0
- package/dist/cjs/run/index.js +98 -0
- package/dist/cjs/types/config/deploy.js +18 -0
- package/dist/cjs/types/config/dev.js +18 -0
- package/dist/cjs/types/config/experiments.js +18 -0
- package/dist/cjs/types/config/html.js +18 -0
- package/dist/cjs/types/config/index.js +58 -0
- package/dist/cjs/types/config/output.js +18 -0
- package/dist/cjs/types/config/performance.js +18 -0
- package/dist/cjs/types/config/resolve.js +18 -0
- package/dist/cjs/types/config/security.js +18 -0
- package/dist/cjs/types/config/source.js +18 -0
- package/dist/cjs/types/config/testing.js +18 -0
- package/dist/cjs/types/config/tools.js +18 -0
- package/dist/cjs/types/index.js +58 -0
- package/dist/cjs/types/plugin.js +18 -0
- package/dist/cjs/types/utils.js +18 -0
- package/dist/cjs/ultramodern/designSystem.js +119 -0
- package/dist/cjs/utils/config.js +45 -0
- package/dist/cjs/utils/createServer.js +52 -0
- package/dist/cjs/utils/env.js +46 -0
- package/dist/cjs/utils/generateWatchFiles.js +54 -0
- package/dist/cjs/utils/getConfigFile.js +49 -0
- package/dist/cjs/utils/getSelectedEntries.js +60 -0
- package/dist/cjs/utils/initAppContext.js +71 -0
- package/dist/cjs/utils/loadPlugins.js +85 -0
- package/dist/cjs/utils/printInstructions.js +43 -0
- package/dist/cjs/utils/register.js +128 -0
- package/dist/cjs/utils/restart.js +52 -0
- package/dist/cjs/utils/routes.js +65 -0
- package/dist/cjs/utils/types.js +18 -0
- package/dist/esm/baseline.mjs +46 -0
- 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 +66 -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 +46 -0
- package/dist/esm/builder/index.mjs +7 -0
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +89 -0
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +55 -0
- package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +68 -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/builderPlugins/index.mjs +5 -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/bundlerPlugins/index.mjs +3 -0
- package/dist/esm/builder/shared/createCopyInfo.mjs +15 -0
- package/dist/esm/builder/shared/index.mjs +3 -0
- package/dist/esm/builder/shared/loaders/serverModuleLoader.mjs +5 -0
- package/dist/esm/builder/shared/types.mjs +0 -0
- package/dist/esm/commands/build.mjs +63 -0
- package/dist/esm/commands/deploy.mjs +10 -0
- package/dist/esm/commands/dev.mjs +77 -0
- package/dist/esm/commands/index.mjs +47 -0
- package/dist/esm/commands/info.mjs +76 -0
- package/dist/esm/commands/inspect.mjs +15 -0
- package/dist/esm/commands/runtime.mjs +116 -0
- package/dist/esm/commands/serve.mjs +48 -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 +91 -0
- package/dist/esm/config/index.mjs +2 -0
- 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/register-esm.mjs +11 -0
- package/dist/esm/esm/ts-paths-loader.mjs +36 -0
- package/dist/esm/exports/server.mjs +0 -0
- package/dist/esm/index.mjs +131 -0
- package/dist/esm/locale/en.mjs +45 -0
- package/dist/esm/locale/index.mjs +9 -0
- package/dist/esm/locale/zh.mjs +45 -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 +97 -0
- package/dist/esm/plugins/analyze/getServerRoutes.mjs +130 -0
- package/dist/esm/plugins/analyze/index.mjs +203 -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 +63 -0
- package/dist/esm/plugins/deploy/index.mjs +43 -0
- package/dist/esm/plugins/deploy/platforms/gh-pages.mjs +43 -0
- package/dist/esm/plugins/deploy/platforms/netlify.mjs +96 -0
- package/dist/esm/plugins/deploy/platforms/node.mjs +56 -0
- package/dist/esm/plugins/deploy/platforms/platform.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +46 -0
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +57 -0
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/esm/plugins/deploy/platforms/vercel.mjs +115 -0
- package/dist/esm/plugins/deploy/types.mjs +0 -0
- package/dist/esm/plugins/deploy/utils/generator.mjs +48 -0
- package/dist/esm/plugins/deploy/utils/index.mjs +67 -0
- package/dist/esm/plugins/initialize/index.mjs +59 -0
- package/dist/esm/plugins/serverBuild.mjs +45 -0
- package/dist/esm/plugins/serverRuntime.mjs +15 -0
- package/dist/esm/presetUltramodern.mjs +4 -0
- package/dist/esm/rsbuild.mjs +47 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/run/index.mjs +61 -0
- package/dist/esm/types/config/deploy.mjs +0 -0
- package/dist/esm/types/config/dev.mjs +0 -0
- package/dist/esm/types/config/experiments.mjs +0 -0
- package/dist/esm/types/config/html.mjs +0 -0
- package/dist/esm/types/config/index.mjs +1 -0
- package/dist/esm/types/config/output.mjs +0 -0
- package/dist/esm/types/config/performance.mjs +0 -0
- package/dist/esm/types/config/resolve.mjs +0 -0
- package/dist/esm/types/config/security.mjs +0 -0
- package/dist/esm/types/config/source.mjs +0 -0
- package/dist/esm/types/config/testing.mjs +0 -0
- package/dist/esm/types/config/tools.mjs +0 -0
- package/dist/esm/types/index.mjs +1 -0
- package/dist/esm/types/plugin.mjs +0 -0
- package/dist/esm/types/utils.mjs +0 -0
- package/dist/esm/ultramodern/designSystem.mjs +73 -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 +27 -0
- package/dist/esm/utils/loadPlugins.mjs +45 -0
- package/dist/esm/utils/printInstructions.mjs +9 -0
- package/dist/esm/utils/register.mjs +81 -0
- package/dist/esm/utils/restart.mjs +18 -0
- package/dist/esm/utils/routes.mjs +15 -0
- package/dist/esm/utils/types.mjs +0 -0
- package/dist/esm-node/baseline.mjs +47 -0
- package/dist/esm-node/builder/builder-rspack/index.mjs +7 -0
- package/dist/esm-node/builder/generator/adapterCopy.mjs +36 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +67 -0
- package/dist/esm-node/builder/generator/createCopyPattern.mjs +31 -0
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +57 -0
- package/dist/esm-node/builder/generator/index.mjs +47 -0
- package/dist/esm-node/builder/index.mjs +8 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +93 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +56 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +69 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +119 -0
- package/dist/esm-node/builder/shared/builderPlugins/builderHooks.mjs +18 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.mjs +6 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +38 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.mjs +23 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +158 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +4 -0
- package/dist/esm-node/builder/shared/createCopyInfo.mjs +16 -0
- package/dist/esm-node/builder/shared/index.mjs +4 -0
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.mjs +6 -0
- package/dist/esm-node/builder/shared/types.mjs +1 -0
- package/dist/esm-node/commands/build.mjs +64 -0
- package/dist/esm-node/commands/deploy.mjs +11 -0
- package/dist/esm-node/commands/dev.mjs +78 -0
- package/dist/esm-node/commands/index.mjs +48 -0
- package/dist/esm-node/commands/info.mjs +77 -0
- package/dist/esm-node/commands/inspect.mjs +16 -0
- package/dist/esm-node/commands/runtime.mjs +117 -0
- package/dist/esm-node/commands/serve.mjs +49 -0
- package/dist/esm-node/compat/hooks.mjs +68 -0
- package/dist/esm-node/compat/index.mjs +29 -0
- package/dist/esm-node/compat/utils.mjs +96 -0
- package/dist/esm-node/config/default.mjs +92 -0
- package/dist/esm-node/config/index.mjs +3 -0
- package/dist/esm-node/config/initialize/index.mjs +8 -0
- package/dist/esm-node/config/initialize/inits.mjs +55 -0
- package/dist/esm-node/constants.mjs +4 -0
- package/dist/esm-node/defineConfig.mjs +3 -0
- package/dist/esm-node/esm/register-esm.mjs +12 -0
- package/dist/esm-node/esm/ts-paths-loader.mjs +37 -0
- package/dist/esm-node/exports/server.mjs +1 -0
- package/dist/esm-node/index.mjs +133 -0
- package/dist/esm-node/locale/en.mjs +46 -0
- package/dist/esm-node/locale/index.mjs +10 -0
- package/dist/esm-node/locale/zh.mjs +46 -0
- package/dist/esm-node/plugins/analyze/constants.mjs +9 -0
- package/dist/esm-node/plugins/analyze/getBundleEntry.mjs +54 -0
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.mjs +67 -0
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +98 -0
- package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +131 -0
- package/dist/esm-node/plugins/analyze/index.mjs +204 -0
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +42 -0
- package/dist/esm-node/plugins/analyze/templates.mjs +23 -0
- package/dist/esm-node/plugins/analyze/utils.mjs +64 -0
- package/dist/esm-node/plugins/deploy/index.mjs +44 -0
- package/dist/esm-node/plugins/deploy/platforms/gh-pages.mjs +44 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify.mjs +98 -0
- package/dist/esm-node/plugins/deploy/platforms/node.mjs +58 -0
- package/dist/esm-node/plugins/deploy/platforms/platform.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +57 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +59 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +44 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +57 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +58 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.mjs +117 -0
- package/dist/esm-node/plugins/deploy/types.mjs +1 -0
- package/dist/esm-node/plugins/deploy/utils/generator.mjs +49 -0
- package/dist/esm-node/plugins/deploy/utils/index.mjs +71 -0
- package/dist/esm-node/plugins/initialize/index.mjs +60 -0
- package/dist/esm-node/plugins/serverBuild.mjs +46 -0
- package/dist/esm-node/plugins/serverRuntime.mjs +16 -0
- package/dist/esm-node/presetUltramodern.mjs +5 -0
- package/dist/esm-node/rsbuild.mjs +48 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/esm-node/run/index.mjs +62 -0
- package/dist/esm-node/types/config/deploy.mjs +1 -0
- package/dist/esm-node/types/config/dev.mjs +1 -0
- package/dist/esm-node/types/config/experiments.mjs +1 -0
- package/dist/esm-node/types/config/html.mjs +1 -0
- package/dist/esm-node/types/config/index.mjs +2 -0
- package/dist/esm-node/types/config/output.mjs +1 -0
- package/dist/esm-node/types/config/performance.mjs +1 -0
- package/dist/esm-node/types/config/resolve.mjs +1 -0
- package/dist/esm-node/types/config/security.mjs +1 -0
- package/dist/esm-node/types/config/source.mjs +1 -0
- package/dist/esm-node/types/config/testing.mjs +1 -0
- package/dist/esm-node/types/config/tools.mjs +1 -0
- package/dist/esm-node/types/index.mjs +2 -0
- package/dist/esm-node/types/plugin.mjs +1 -0
- package/dist/esm-node/types/utils.mjs +1 -0
- package/dist/esm-node/ultramodern/designSystem.mjs +74 -0
- package/dist/esm-node/utils/config.mjs +12 -0
- package/dist/esm-node/utils/createServer.mjs +13 -0
- package/dist/esm-node/utils/env.mjs +13 -0
- package/dist/esm-node/utils/generateWatchFiles.mjs +11 -0
- package/dist/esm-node/utils/getConfigFile.mjs +6 -0
- package/dist/esm-node/utils/getSelectedEntries.mjs +27 -0
- package/dist/esm-node/utils/initAppContext.mjs +28 -0
- package/dist/esm-node/utils/loadPlugins.mjs +46 -0
- package/dist/esm-node/utils/printInstructions.mjs +10 -0
- package/dist/esm-node/utils/register.mjs +83 -0
- package/dist/esm-node/utils/restart.mjs +19 -0
- package/dist/esm-node/utils/routes.mjs +16 -0
- package/dist/esm-node/utils/types.mjs +1 -0
- package/dist/types/baseline.d.ts +46 -0
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/generator/adapterCopy.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -0
- package/dist/types/builder/generator/createCopyPattern.d.ts +16 -0
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +6 -0
- package/dist/types/builder/generator/index.d.ts +8 -0
- package/dist/types/builder/index.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterPrecompress.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +5 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +7 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +9 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +32 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +3 -0
- package/dist/types/builder/shared/createCopyInfo.d.ts +8 -0
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/shared/types.d.ts +6 -0
- package/dist/types/commands/build.d.ts +4 -0
- package/dist/types/commands/deploy.d.ts +3 -0
- package/dist/types/commands/dev.d.ts +9 -0
- package/dist/types/commands/index.d.ts +10 -0
- package/dist/types/commands/info.d.ts +18 -0
- package/dist/types/commands/inspect.d.ts +4 -0
- package/dist/types/commands/runtime.d.ts +11 -0
- package/dist/types/commands/serve.d.ts +8 -0
- package/dist/types/compat/hooks.d.ts +7 -0
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/compat/utils.d.ts +13 -0
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initialize/index.d.ts +3 -0
- package/dist/types/config/initialize/inits.d.ts +4 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +11 -0
- package/dist/types/esm/register-esm.d.mts +11 -0
- package/dist/types/esm/ts-node-loader.d.mts +6 -0
- package/dist/types/esm/ts-paths-loader.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/locale/en.d.ts +44 -0
- package/dist/types/locale/index.d.ts +90 -0
- package/dist/types/locale/zh.d.ts +44 -0
- package/dist/types/plugins/analyze/constants.d.ts +3 -0
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +7 -0
- package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +27 -0
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +8 -0
- package/dist/types/plugins/analyze/index.d.ts +3 -0
- package/dist/types/plugins/analyze/isDefaultExportFunction.d.ts +1 -0
- package/dist/types/plugins/analyze/templates.d.ts +5 -0
- package/dist/types/plugins/analyze/utils.d.ts +10 -0
- package/dist/types/plugins/deploy/index.d.ts +3 -0
- package/dist/types/plugins/deploy/platforms/gh-pages.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +17 -0
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -0
- package/dist/types/plugins/deploy/types.d.ts +3 -0
- package/dist/types/plugins/deploy/utils/generator.d.ts +24 -0
- package/dist/types/plugins/deploy/utils/index.d.ts +16 -0
- package/dist/types/plugins/initialize/index.d.ts +3 -0
- package/dist/types/plugins/serverBuild.d.ts +3 -0
- package/dist/types/plugins/serverRuntime.d.ts +3 -0
- package/dist/types/presetUltramodern.d.ts +6 -0
- package/dist/types/rsbuild.d.ts +12 -0
- package/dist/types/run/index.d.ts +20 -0
- package/dist/types/types/config/deploy.d.ts +38 -0
- package/dist/types/types/config/dev.d.ts +55 -0
- package/dist/types/types/config/experiments.d.ts +3 -0
- package/dist/types/types/config/html.d.ts +3 -0
- package/dist/types/types/config/index.d.ts +48 -0
- package/dist/types/types/config/output.d.ts +61 -0
- package/dist/types/types/config/performance.d.ts +3 -0
- package/dist/types/types/config/resolve.d.ts +2 -0
- package/dist/types/types/config/security.d.ts +2 -0
- package/dist/types/types/config/source.d.ts +61 -0
- package/dist/types/types/config/testing.d.ts +8 -0
- package/dist/types/types/config/tools.d.ts +21 -0
- package/dist/types/types/index.d.ts +10 -0
- package/dist/types/types/plugin.d.ts +114 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/ultramodern/designSystem.d.ts +54 -0
- package/dist/types/utils/config.d.ts +2 -0
- package/dist/types/utils/createServer.d.ts +5 -0
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/generateWatchFiles.d.ts +2 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -0
- package/dist/types/utils/getSelectedEntries.d.ts +5 -0
- package/dist/types/utils/initAppContext.d.ts +31 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -0
- package/dist/types/utils/printInstructions.d.ts +3 -0
- package/dist/types/utils/register.d.ts +19 -0
- package/dist/types/utils/restart.d.ts +2 -0
- package/dist/types/utils/routes.d.ts +4 -0
- package/dist/types/utils/types.d.ts +49 -0
- package/lib/types.d.ts +252 -0
- package/package.json +138 -0
- package/rslib.config.mts +39 -0
- package/rstest.config.mts +20 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { fs, removeModuleSyncFromExports } from "@modern-js/utils";
|
|
5
|
+
import { nodeDepEmit } from "ndepe";
|
|
6
|
+
import { isMainEntry } from "../../../utils/routes.mjs";
|
|
7
|
+
import { readTemplate, resolveESMDependency } from "../utils/index.mjs";
|
|
8
|
+
import { generateHandler } from "../utils/generator.mjs";
|
|
9
|
+
const createVercelPreset = ({ appContext, modernConfig, needModernServer })=>{
|
|
10
|
+
const { appDirectory, distDirectory, entrypoints, moduleType } = appContext;
|
|
11
|
+
const isEsmProject = 'module' === moduleType;
|
|
12
|
+
const vercelOutput = node_path.join(appDirectory, '.vercel');
|
|
13
|
+
const outputDirectory = node_path.join(vercelOutput, 'output');
|
|
14
|
+
const funcsDirectory = node_path.join(outputDirectory, 'functions', 'index.func');
|
|
15
|
+
const entryFilePath = node_path.join(funcsDirectory, 'index.js');
|
|
16
|
+
return {
|
|
17
|
+
async prepare () {
|
|
18
|
+
await fs.remove(vercelOutput);
|
|
19
|
+
},
|
|
20
|
+
async writeOutput () {
|
|
21
|
+
const config = {
|
|
22
|
+
version: 3,
|
|
23
|
+
routes: [
|
|
24
|
+
{
|
|
25
|
+
src: '/static/(.*)',
|
|
26
|
+
headers: {
|
|
27
|
+
'cache-control': 's-maxage=31536000, immutable'
|
|
28
|
+
},
|
|
29
|
+
continue: true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
handle: 'filesystem'
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
if (needModernServer) config.routes.push({
|
|
37
|
+
src: '/(.*)',
|
|
38
|
+
dest: "/index"
|
|
39
|
+
});
|
|
40
|
+
else {
|
|
41
|
+
const { source: { mainEntryName }, html: { outputStructure } } = modernConfig;
|
|
42
|
+
entrypoints.forEach((entry)=>{
|
|
43
|
+
const isMain = isMainEntry(entry.entryName, mainEntryName);
|
|
44
|
+
const htmlPath = 'flat' === outputStructure ? `/html/${entry.entryName}.html` : `/html/${entry.entryName}/index.html`;
|
|
45
|
+
config.routes.push({
|
|
46
|
+
src: `/${isMain ? '' : entry.entryName}(?:/.*)?`,
|
|
47
|
+
headers: {
|
|
48
|
+
'cache-control': 's-maxage=0'
|
|
49
|
+
},
|
|
50
|
+
dest: htmlPath
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
await fs.ensureDir(outputDirectory);
|
|
55
|
+
await fs.writeJSON(node_path.join(outputDirectory, 'config.json'), config, {
|
|
56
|
+
spaces: 2
|
|
57
|
+
});
|
|
58
|
+
const staticDirectory = node_path.join(outputDirectory, 'static/static');
|
|
59
|
+
await fs.copy(node_path.join(distDirectory, 'static'), staticDirectory);
|
|
60
|
+
if (needModernServer) {
|
|
61
|
+
await fs.ensureDir(funcsDirectory);
|
|
62
|
+
await fs.copy(distDirectory, funcsDirectory, {
|
|
63
|
+
filter: (src)=>{
|
|
64
|
+
const distStaticDirectory = node_path.join(distDirectory, 'static');
|
|
65
|
+
return !src.includes(distStaticDirectory);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const nodeVersion = process.versions.node.split('.')[0];
|
|
69
|
+
await fs.writeJSON(node_path.join(funcsDirectory, '.vc-config.json'), {
|
|
70
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
71
|
+
handler: 'index.js',
|
|
72
|
+
launcherType: 'Nodejs',
|
|
73
|
+
shouldAddHelpers: false,
|
|
74
|
+
supportsResponseStreaming: true
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
const destHtmlDirectory = node_path.join(distDirectory, 'html');
|
|
78
|
+
const outputHtmlDirectory = node_path.join(node_path.join(outputDirectory, 'static'), 'html');
|
|
79
|
+
await fs.copy(destHtmlDirectory, outputHtmlDirectory);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async genEntry () {
|
|
83
|
+
if (!needModernServer) return;
|
|
84
|
+
const template = await readTemplate(`vercel-entry.${isEsmProject ? 'mjs' : 'cjs'}`);
|
|
85
|
+
const code = await generateHandler({
|
|
86
|
+
template,
|
|
87
|
+
appContext,
|
|
88
|
+
config: modernConfig,
|
|
89
|
+
isESM: isEsmProject
|
|
90
|
+
});
|
|
91
|
+
await fs.writeFile(entryFilePath, code);
|
|
92
|
+
},
|
|
93
|
+
async end () {
|
|
94
|
+
if (!needModernServer) return;
|
|
95
|
+
const entry = isEsmProject ? await resolveESMDependency('@modern-js/prod-server') : require.resolve('@modern-js/prod-server');
|
|
96
|
+
if (!entry) throw new Error('Cannot find @modern-js/prod-server');
|
|
97
|
+
await nodeDepEmit({
|
|
98
|
+
appDir: appDirectory,
|
|
99
|
+
sourceDir: funcsDirectory,
|
|
100
|
+
includeEntries: [
|
|
101
|
+
entry
|
|
102
|
+
],
|
|
103
|
+
copyWholePackage (pkgName) {
|
|
104
|
+
return '@modern-js/utils' === pkgName;
|
|
105
|
+
},
|
|
106
|
+
transformPackageJson: ({ pkgJSON })=>{
|
|
107
|
+
if (!pkgJSON.exports || 'object' != typeof pkgJSON.exports) return pkgJSON;
|
|
108
|
+
return {
|
|
109
|
+
...pkgJSON,
|
|
110
|
+
exports: removeModuleSyncFromExports(pkgJSON.exports)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export { createVercelPreset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { ROUTE_SPEC_FILE, SERVER_DIR, getMeta } from "@modern-js/utils";
|
|
4
|
+
import { merge } from "@modern-js/utils/lodash";
|
|
5
|
+
import { normalizePath } from "./index.mjs";
|
|
6
|
+
const serverAppContextTemplate = (appContext)=>{
|
|
7
|
+
const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName, bffRuntimeFramework } = appContext;
|
|
8
|
+
const getRelativePathTemplate = (targetDirectory)=>`path.join(__dirname, ${JSON.stringify(normalizePath(node_path.relative(appDirectory, targetDirectory)))})`;
|
|
9
|
+
return {
|
|
10
|
+
sharedDirectory: getRelativePathTemplate(sharedDirectory),
|
|
11
|
+
apiDirectory: getRelativePathTemplate(apiDirectory),
|
|
12
|
+
lambdaDirectory: getRelativePathTemplate(lambdaDirectory),
|
|
13
|
+
metaName,
|
|
14
|
+
bffRuntimeFramework: bffRuntimeFramework || 'hono'
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const genPluginImportsCode = (plugins, isESM = false)=>plugins.map(([name, options], index)=>{
|
|
18
|
+
const im = isESM ? `import * as plugin_${index}_ns from '${name}'` : `const plugin_${index}_ns = require('${name}')`;
|
|
19
|
+
return `${im};const plugin_${index} = plugin_${index}_ns.default || plugin_${index}_ns`;
|
|
20
|
+
}).join(';\n');
|
|
21
|
+
const getPluginsCode = (plugins)=>`[${plugins.map(([, options], index)=>`plugin_${index}(${options ? JSON.stringify(options) : ''})`).join(',')}]`;
|
|
22
|
+
const getServerConfigPath = (meta)=>`path.join(__dirname, "${SERVER_DIR}", "${meta}.server")`;
|
|
23
|
+
const generateHandler = async ({ template, appContext, config, serverConfig: modifyServerConfig, genAppContextTemplate = serverAppContextTemplate, genPluginImports = genPluginImportsCode, isESM })=>{
|
|
24
|
+
const { serverPlugins, metaName } = appContext;
|
|
25
|
+
const plugins = serverPlugins.map((plugin)=>[
|
|
26
|
+
plugin.name,
|
|
27
|
+
plugin.options
|
|
28
|
+
]);
|
|
29
|
+
const serverConfig = merge({
|
|
30
|
+
bff: {
|
|
31
|
+
prefix: config?.bff?.prefix
|
|
32
|
+
},
|
|
33
|
+
output: {
|
|
34
|
+
distPath: {
|
|
35
|
+
root: '.'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}, modifyServerConfig || {});
|
|
39
|
+
const meta = getMeta(metaName);
|
|
40
|
+
const pluginImportCode = genPluginImports(plugins || [], Boolean(isESM));
|
|
41
|
+
const dynamicProdOptions = {
|
|
42
|
+
config: serverConfig
|
|
43
|
+
};
|
|
44
|
+
const serverConfigPath = getServerConfigPath(meta);
|
|
45
|
+
const pluginsCode = getPluginsCode(plugins);
|
|
46
|
+
const serverAppContext = genAppContextTemplate(appContext);
|
|
47
|
+
return template.replace('p_genPluginImportsCode', pluginImportCode).replace('p_ROUTE_SPEC_FILE', `"${ROUTE_SPEC_FILE}"`).replace('p_dynamicProdOptions', JSON.stringify(dynamicProdOptions)).replace('p_plugins', pluginsCode).replace('p_bffRuntimeFramework', `"${serverAppContext.bffRuntimeFramework}"`).replace('p_serverDirectory', serverConfigPath).replace('p_sharedDirectory', serverAppContext.sharedDirectory).replace('p_apiDirectory', serverAppContext.apiDirectory).replace('p_lambdaDirectory', serverAppContext.lambdaDirectory);
|
|
48
|
+
};
|
|
49
|
+
export { genPluginImportsCode, generateHandler, getPluginsCode, getServerConfigPath, serverAppContextTemplate };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { ROUTE_SPEC_FILE, SERVER_DIR, fs, getMeta } from "@modern-js/utils";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
6
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
7
|
+
var utils_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
8
|
+
const normalizePath = (filePath)=>filePath.replace(/\\/g, '/');
|
|
9
|
+
const getProjectUsage = (appDirectory, distDirectory, metaName)=>{
|
|
10
|
+
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
11
|
+
const { routes } = fs.readJSONSync(routeJSON);
|
|
12
|
+
let useSSR = false;
|
|
13
|
+
let useAPI = false;
|
|
14
|
+
routes.forEach((route)=>{
|
|
15
|
+
if (route.isSSR) useSSR = true;
|
|
16
|
+
if (route.isApi) useAPI = true;
|
|
17
|
+
});
|
|
18
|
+
const meta = getMeta(metaName);
|
|
19
|
+
const serverConfigPath = path.resolve(appDirectory, SERVER_DIR, `${meta}.server`);
|
|
20
|
+
const isServerConfigExists = [
|
|
21
|
+
'.ts',
|
|
22
|
+
'.js'
|
|
23
|
+
].some((ex)=>fs.existsSync(`${serverConfigPath}${ex}`));
|
|
24
|
+
return {
|
|
25
|
+
useSSR,
|
|
26
|
+
useAPI,
|
|
27
|
+
useWebServer: isServerConfigExists
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const getTemplatePath = (file)=>path.join(utils_dirname, '../platforms/templates', file);
|
|
31
|
+
const readTemplate = async (file)=>(await fs.readFile(getTemplatePath(file))).toString();
|
|
32
|
+
const localRequire = createRequire(path.join(utils_dirname, 'package.json'));
|
|
33
|
+
const findNearestPackageJson = (resolvedEntry)=>{
|
|
34
|
+
let currentDir = path.dirname(resolvedEntry);
|
|
35
|
+
while(currentDir !== path.dirname(currentDir)){
|
|
36
|
+
const manifestPath = path.join(currentDir, 'package.json');
|
|
37
|
+
if (fs.existsSync(manifestPath)) return manifestPath;
|
|
38
|
+
currentDir = path.dirname(currentDir);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const splitPackageSpecifier = (entry)=>{
|
|
42
|
+
const segments = entry.split('/');
|
|
43
|
+
if (entry.startsWith('@')) {
|
|
44
|
+
const [scope, name, ...rest] = segments;
|
|
45
|
+
return {
|
|
46
|
+
packageName: `${scope}/${name}`,
|
|
47
|
+
exportKey: rest.length > 0 ? `./${rest.join('/')}` : '.'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const [name, ...rest] = segments;
|
|
51
|
+
return {
|
|
52
|
+
packageName: name,
|
|
53
|
+
exportKey: rest.length > 0 ? `./${rest.join('/')}` : '.'
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const resolveESMDependency = async (entry)=>{
|
|
57
|
+
try {
|
|
58
|
+
const { packageName, exportKey } = splitPackageSpecifier(entry);
|
|
59
|
+
const resolvedEntry = localRequire.resolve(entry);
|
|
60
|
+
const packageJsonPath = findNearestPackageJson(localRequire.resolve(packageName));
|
|
61
|
+
if (!packageJsonPath) return normalizePath(resolvedEntry);
|
|
62
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
63
|
+
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
64
|
+
const exportConfig = packageJson.exports?.[exportKey];
|
|
65
|
+
if ('string' == typeof exportConfig) return normalizePath(path.join(packageDir, exportConfig));
|
|
66
|
+
const esmExportPath = exportConfig?.node?.import || exportConfig?.import || exportConfig?.default;
|
|
67
|
+
if ('string' == typeof esmExportPath) return normalizePath(path.join(packageDir, esmExportPath));
|
|
68
|
+
return normalizePath(resolvedEntry);
|
|
69
|
+
} catch (err) {}
|
|
70
|
+
};
|
|
71
|
+
export { getProjectUsage, getTemplatePath, normalizePath, readTemplate, resolveESMDependency };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
3
|
+
import { createDefaultConfig } from "../../config/index.mjs";
|
|
4
|
+
const initialize = ()=>({
|
|
5
|
+
name: '@modern-js/plugin-initialize',
|
|
6
|
+
post: [
|
|
7
|
+
'@modern-js/plugin-ssr',
|
|
8
|
+
'@modern-js/plugin-document',
|
|
9
|
+
'@modern-js/plugin-router',
|
|
10
|
+
'@modern-js/plugin-polyfill'
|
|
11
|
+
],
|
|
12
|
+
setup (api) {
|
|
13
|
+
api.config(()=>{
|
|
14
|
+
const appContext = api.getAppContext();
|
|
15
|
+
return createDefaultConfig(appContext);
|
|
16
|
+
});
|
|
17
|
+
api.modifyResolvedConfig(async (resolved)=>{
|
|
18
|
+
let appContext = api.getAppContext();
|
|
19
|
+
const userConfig = api.getConfig();
|
|
20
|
+
const port = await getServerPort(resolved);
|
|
21
|
+
appContext = {
|
|
22
|
+
...appContext,
|
|
23
|
+
port,
|
|
24
|
+
distDirectory: ensureAbsolutePath(appContext.appDirectory, resolved.output.distPath?.root || 'dist')
|
|
25
|
+
};
|
|
26
|
+
api.updateAppContext(appContext);
|
|
27
|
+
const normalizedConfig = resolved;
|
|
28
|
+
resolved._raw = userConfig;
|
|
29
|
+
resolved.server = {
|
|
30
|
+
...normalizedConfig.server || {},
|
|
31
|
+
port
|
|
32
|
+
};
|
|
33
|
+
stabilizeConfig(resolved, normalizedConfig, [
|
|
34
|
+
'source',
|
|
35
|
+
'bff',
|
|
36
|
+
'dev',
|
|
37
|
+
'html',
|
|
38
|
+
'output',
|
|
39
|
+
'tools',
|
|
40
|
+
'testing',
|
|
41
|
+
'plugins',
|
|
42
|
+
'builderPlugins',
|
|
43
|
+
'deploy',
|
|
44
|
+
'performance'
|
|
45
|
+
]);
|
|
46
|
+
return resolved;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
function stabilizeConfig(resolve, config, keys) {
|
|
51
|
+
keys.forEach((key)=>{
|
|
52
|
+
resolve[key] = config[key] || {};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function getServerPort(config) {
|
|
56
|
+
const prodPort = Number(process.env.PORT) || config.server.port || 8080;
|
|
57
|
+
if (isDev() && isDevCommand()) return getPort(Number(process.env.PORT) || prodPort);
|
|
58
|
+
return prodPort;
|
|
59
|
+
}
|
|
60
|
+
export default initialize;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { compile } from "@modern-js/server-utils";
|
|
3
|
+
import { SERVER_DIR, SHARED_DIR, getMeta, resolveServerTsconfig } from "@modern-js/utils";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
function checkHasCache(appDir) {
|
|
7
|
+
const tsFilepath = path.resolve(appDir, SERVER_DIR, 'cache.ts');
|
|
8
|
+
const jsfilepath = path.resolve(appDir, SERVER_DIR, 'cache.js');
|
|
9
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
10
|
+
}
|
|
11
|
+
function checkHasConfig(appDir, metaName = 'modern-js') {
|
|
12
|
+
const meta = getMeta(metaName);
|
|
13
|
+
const tsFilepath = path.resolve(appDir, SERVER_DIR, `${meta}.server.ts`);
|
|
14
|
+
const jsfilepath = path.resolve(appDir, SERVER_DIR, `${meta}.server.js`);
|
|
15
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
16
|
+
}
|
|
17
|
+
const serverBuild = ()=>({
|
|
18
|
+
name: '@modern-js/server-build',
|
|
19
|
+
setup (api) {
|
|
20
|
+
api.onAfterBuild(async ()=>{
|
|
21
|
+
const { appDirectory, distDirectory, metaName } = api.getAppContext();
|
|
22
|
+
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) return;
|
|
23
|
+
const modernConfig = api.getNormalizedConfig();
|
|
24
|
+
const distDir = path.resolve(distDirectory);
|
|
25
|
+
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
26
|
+
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
27
|
+
const tsconfigPath = resolveServerTsconfig(appDirectory, modernConfig?.server?.tsconfigPath);
|
|
28
|
+
const sourceDirs = [];
|
|
29
|
+
if (fs.existsSync(serverDir)) {
|
|
30
|
+
sourceDirs.push(serverDir);
|
|
31
|
+
if (fs.existsSync(sharedDir)) sourceDirs.push(sharedDir);
|
|
32
|
+
}
|
|
33
|
+
const { server } = modernConfig;
|
|
34
|
+
const { alias } = modernConfig.source;
|
|
35
|
+
if (sourceDirs.length > 0) await compile(appDirectory, {
|
|
36
|
+
server,
|
|
37
|
+
alias
|
|
38
|
+
}, {
|
|
39
|
+
sourceDirs,
|
|
40
|
+
distDir,
|
|
41
|
+
tsconfigPath
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export default serverBuild;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const serverRuntime = ()=>({
|
|
3
|
+
name: '@modern-js/plugin-server-runtime',
|
|
4
|
+
setup (api) {
|
|
5
|
+
api.config(()=>({
|
|
6
|
+
output: {
|
|
7
|
+
externals: [
|
|
8
|
+
{
|
|
9
|
+
'@modern-js/server-runtime': '@modern-js/server-runtime'
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export default serverRuntime;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { createAppBaselineConfig, withAppBaseline } from "./baseline.mjs";
|
|
3
|
+
const createPresetUltramodernConfig = (options = {})=>createAppBaselineConfig(options);
|
|
4
|
+
const presetUltramodern = (config, options = {})=>withAppBaseline(config, options);
|
|
5
|
+
export { createPresetUltramodernConfig, presetUltramodern };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { parseRspackConfig } from "@modern-js/builder";
|
|
3
|
+
import { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./builder/shared/builderPlugins/index.mjs";
|
|
4
|
+
import { DEFAULT_CONFIG_FILE } from "./constants.mjs";
|
|
5
|
+
import { getConfigFile } from "./utils/getConfigFile.mjs";
|
|
6
|
+
import { __webpack_require__ } from "./rslib-runtime.mjs";
|
|
7
|
+
import * as __rspack_external__modern_js_plugin_cli_caa09fa2 from "@modern-js/plugin/cli";
|
|
8
|
+
__webpack_require__.add({
|
|
9
|
+
"@modern-js/plugin/cli?f956" (module) {
|
|
10
|
+
module.exports = __rspack_external__modern_js_plugin_cli_caa09fa2;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const MODERN_META_NAME = 'modern-js';
|
|
14
|
+
const { createConfigOptions: createConfigOptions } = __webpack_require__("@modern-js/plugin/cli?f956");
|
|
15
|
+
async function resolveModernRsbuildConfig(options) {
|
|
16
|
+
const { cwd = process.cwd(), metaName = MODERN_META_NAME } = options;
|
|
17
|
+
const configFile = options.configPath || getConfigFile(void 0, cwd);
|
|
18
|
+
if (!configFile) throw new Error(`Cannot find config file in ${cwd}. Please make sure you have a ${DEFAULT_CONFIG_FILE} file in your project.`);
|
|
19
|
+
const { config: modernConfig, getAppContext } = await createConfigOptions({
|
|
20
|
+
command: options.command,
|
|
21
|
+
cwd,
|
|
22
|
+
configFile,
|
|
23
|
+
metaName,
|
|
24
|
+
modifyModernConfig: options.modifyModernConfig
|
|
25
|
+
});
|
|
26
|
+
const nonStandardConfig = {
|
|
27
|
+
...modernConfig,
|
|
28
|
+
plugins: modernConfig.builderPlugins
|
|
29
|
+
};
|
|
30
|
+
const appContext = getAppContext();
|
|
31
|
+
const { rsbuildConfig, rsbuildPlugins } = await parseRspackConfig(nonStandardConfig, {
|
|
32
|
+
cwd
|
|
33
|
+
});
|
|
34
|
+
const adapterParams = {
|
|
35
|
+
appContext,
|
|
36
|
+
normalizedConfig: modernConfig
|
|
37
|
+
};
|
|
38
|
+
rsbuildConfig.plugins = [
|
|
39
|
+
...rsbuildPlugins,
|
|
40
|
+
...rsbuildConfig.plugins || [],
|
|
41
|
+
builderPluginAdapterBasic(adapterParams),
|
|
42
|
+
builderPluginAdapterHooks(adapterParams)
|
|
43
|
+
];
|
|
44
|
+
return {
|
|
45
|
+
rsbuildConfig
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export { resolveModernRsbuildConfig };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
var __webpack_modules__ = {};
|
|
3
|
+
var __webpack_module_cache__ = {};
|
|
4
|
+
function __webpack_require__(moduleId) {
|
|
5
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
+
return module.exports;
|
|
12
|
+
}
|
|
13
|
+
__webpack_require__.m = __webpack_modules__;
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.add = function(modules) {
|
|
16
|
+
Object.assign(__webpack_require__.m, modules);
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { initAppDir } from "@modern-js/plugin/cli";
|
|
3
|
+
import { run } from "@modern-js/plugin/run";
|
|
4
|
+
import { chalk, minimist } from "@modern-js/utils";
|
|
5
|
+
import { handleSetupResult } from "../compat/hooks.mjs";
|
|
6
|
+
import { getConfigFile } from "../utils/getConfigFile.mjs";
|
|
7
|
+
import { loadInternalPlugins } from "../utils/loadPlugins.mjs";
|
|
8
|
+
async function createRunOptions({ cwd, initialLog, metaName = 'modern-js', version, internalPlugins, configFile }) {
|
|
9
|
+
const nodeVersion = process.versions.node;
|
|
10
|
+
const versionArr = nodeVersion.split('.').map(Number);
|
|
11
|
+
if (versionArr[0] <= 16) console.warn(`
|
|
12
|
+
${chalk.bgRed.white.bold(' ⚠️ CRITICAL NODE.JS VERSION ALERT ⚠️ ')}
|
|
13
|
+
|
|
14
|
+
${chalk.red.bold('Node.js 16 End-of-Life Notice:')}
|
|
15
|
+
${chalk.red('- Security updates and support have ended for Node.js 16')}
|
|
16
|
+
|
|
17
|
+
${chalk.yellow('▸ Detected Runtime:')} ${chalk.yellow.bold(`Node.js v${nodeVersion}`)}
|
|
18
|
+
${chalk.green('▸ Required Minimum:')} ${chalk.green.bold('Node.js LTS (v18.x or higher)')}
|
|
19
|
+
${chalk.green('▸ Recommended:')} ${chalk.green.bold('Node.js LTS (v22.x or higher)')}
|
|
20
|
+
|
|
21
|
+
${chalk.cyan('Immediate Action Required:')}
|
|
22
|
+
${chalk.gray('├──')} ${chalk.yellow('Recommended Upgrade')}
|
|
23
|
+
${chalk.bold('nvm install 22 --lts && nvm use 22')}
|
|
24
|
+
${chalk.gray('├──')} ${chalk.yellow('Manual Installation')}
|
|
25
|
+
${chalk.underline('https://nodejs.org/download/release/lts-hydrogen/')}
|
|
26
|
+
${chalk.gray('└──')} ${chalk.yellow('Environment Verification')}
|
|
27
|
+
${chalk.bold('node -v && npm -v')}
|
|
28
|
+
|
|
29
|
+
${chalk.hex('#AAAAAA').italic('[Security Advisory] Node.js 16 is no longer supported. Upgrade immediately for security and compatibility.')}
|
|
30
|
+
`);
|
|
31
|
+
const command = process.argv[2];
|
|
32
|
+
const cliParams = minimist(process.argv.slice(2));
|
|
33
|
+
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
|
34
|
+
'dev',
|
|
35
|
+
'build',
|
|
36
|
+
'deploy',
|
|
37
|
+
'start',
|
|
38
|
+
'serve',
|
|
39
|
+
'inspect',
|
|
40
|
+
'info',
|
|
41
|
+
'upgrade'
|
|
42
|
+
];
|
|
43
|
+
let customConfigFile;
|
|
44
|
+
if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command)) customConfigFile = cliParams.config || cliParams.c;
|
|
45
|
+
if ('new' === command) customConfigFile = cliParams['config-file'];
|
|
46
|
+
const appDirectory = await initAppDir(cwd);
|
|
47
|
+
const finalConfigFile = customConfigFile || getConfigFile(configFile);
|
|
48
|
+
const plugins = await loadInternalPlugins(appDirectory, internalPlugins);
|
|
49
|
+
return {
|
|
50
|
+
cwd,
|
|
51
|
+
initialLog: initialLog || `Modern.js Framework v${version}`,
|
|
52
|
+
configFile: finalConfigFile,
|
|
53
|
+
metaName,
|
|
54
|
+
internalPlugins: plugins,
|
|
55
|
+
handleSetupResult: handleSetupResult
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function run_run(options) {
|
|
59
|
+
const runOptions = await createRunOptions(options);
|
|
60
|
+
await run(runOptions);
|
|
61
|
+
}
|
|
62
|
+
export { createRunOptions, run_run as run };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const DESIGN_SYSTEM_MODES = [
|
|
3
|
+
'off',
|
|
4
|
+
'tokens',
|
|
5
|
+
'components',
|
|
6
|
+
'strict'
|
|
7
|
+
];
|
|
8
|
+
const DESIGN_SYSTEM_OVERRIDE_LAYERS = [
|
|
9
|
+
'brand',
|
|
10
|
+
'vertical',
|
|
11
|
+
'application'
|
|
12
|
+
];
|
|
13
|
+
const VALID_MODES = new Set(DESIGN_SYSTEM_MODES);
|
|
14
|
+
const VALID_OVERRIDE_LAYERS = new Set(DESIGN_SYSTEM_OVERRIDE_LAYERS);
|
|
15
|
+
const createValidationResult = (issues)=>({
|
|
16
|
+
valid: 0 === issues.length,
|
|
17
|
+
issues
|
|
18
|
+
});
|
|
19
|
+
const addIssue = (issues, path, message)=>{
|
|
20
|
+
issues.push({
|
|
21
|
+
path,
|
|
22
|
+
message
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const createDesignSystemTokenPackMap = (tokenPacks)=>new Map(tokenPacks.map((tokenPack)=>[
|
|
26
|
+
tokenPack.id,
|
|
27
|
+
tokenPack
|
|
28
|
+
]));
|
|
29
|
+
const validateDesignSystemConsumerCompatibility = (vertical, tokenPack, path = 'vertical')=>{
|
|
30
|
+
const issues = [];
|
|
31
|
+
const consumers = vertical.consumers ?? [];
|
|
32
|
+
for (const [consumerIndex, consumer] of consumers.entries()){
|
|
33
|
+
const consumerPath = `${path}.consumers[${consumerIndex}]`;
|
|
34
|
+
if (consumer.unsupportedModes?.includes(vertical.mode)) addIssue(issues, `${consumerPath}.unsupportedModes`, `consumer "${consumer.id}" does not support "${vertical.mode}" mode`);
|
|
35
|
+
if (!tokenPack) continue;
|
|
36
|
+
const expectedVersion = consumer.tokenPackVersions?.[tokenPack.id];
|
|
37
|
+
if (expectedVersion && expectedVersion !== tokenPack.version) addIssue(issues, `${consumerPath}.tokenPackVersions.${tokenPack.id}`, `consumer "${consumer.id}" requires "${tokenPack.id}" version "${expectedVersion}" but received "${tokenPack.version}"`);
|
|
38
|
+
for (const tokenName of consumer.requiredTokens ?? [])if (!(tokenName in tokenPack.tokens)) addIssue(issues, `${consumerPath}.requiredTokens`, `consumer "${consumer.id}" requires missing token "${tokenName}" from "${tokenPack.id}"`);
|
|
39
|
+
}
|
|
40
|
+
return createValidationResult(issues);
|
|
41
|
+
};
|
|
42
|
+
const validateDesignSystemContract = (contract)=>{
|
|
43
|
+
const issues = [];
|
|
44
|
+
const tokenPackMap = createDesignSystemTokenPackMap(contract.tokenPacks);
|
|
45
|
+
for (const [tokenPackIndex, tokenPack] of contract.tokenPacks.entries()){
|
|
46
|
+
const tokenPackPath = `tokenPacks[${tokenPackIndex}]`;
|
|
47
|
+
if (tokenPackMap.get(tokenPack.id) !== tokenPack) addIssue(issues, `${tokenPackPath}.id`, `duplicate token pack id "${tokenPack.id}"`);
|
|
48
|
+
if (0 === Object.keys(tokenPack.tokens).length) addIssue(issues, `${tokenPackPath}.tokens`, `token pack "${tokenPack.id}" must define at least one token`);
|
|
49
|
+
}
|
|
50
|
+
for (const [verticalName, vertical] of Object.entries(contract.verticals)){
|
|
51
|
+
const verticalPath = `verticals.${verticalName}`;
|
|
52
|
+
const tokenPack = vertical.tokenPack ? tokenPackMap.get(vertical.tokenPack) : void 0;
|
|
53
|
+
if (!VALID_MODES.has(vertical.mode)) addIssue(issues, `${verticalPath}.mode`, `unsupported design system mode "${vertical.mode}"`);
|
|
54
|
+
if ('off' !== vertical.mode && !vertical.tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `vertical "${verticalName}" must select a token pack when mode is "${vertical.mode}"`);
|
|
55
|
+
if (vertical.tokenPack && !tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `unknown token pack "${vertical.tokenPack}"`);
|
|
56
|
+
for (const [overrideIndex, override] of (vertical.overrides ?? []).entries())if (!VALID_OVERRIDE_LAYERS.has(override.layer)) addIssue(issues, `${verticalPath}.overrides[${overrideIndex}].layer`, `override layer "${override.layer}" is not approved`);
|
|
57
|
+
if (vertical.pin) {
|
|
58
|
+
const pinnedTokenPack = tokenPackMap.get(vertical.pin.tokenPack);
|
|
59
|
+
const rollbackTokenPack = tokenPackMap.get(vertical.pin.rollback.tokenPack);
|
|
60
|
+
if (pinnedTokenPack) {
|
|
61
|
+
if (pinnedTokenPack.version !== vertical.pin.version) addIssue(issues, `${verticalPath}.pin.version`, `pinned version "${vertical.pin.version}" does not match token pack "${vertical.pin.tokenPack}" version "${pinnedTokenPack.version}"`);
|
|
62
|
+
} else addIssue(issues, `${verticalPath}.pin.tokenPack`, `unknown pinned token pack "${vertical.pin.tokenPack}"`);
|
|
63
|
+
if (vertical.tokenPack && vertical.pin.tokenPack !== vertical.tokenPack) addIssue(issues, `${verticalPath}.pin.tokenPack`, `pinned token pack "${vertical.pin.tokenPack}" must match selected token pack "${vertical.tokenPack}"`);
|
|
64
|
+
if (rollbackTokenPack) {
|
|
65
|
+
if (rollbackTokenPack.version !== vertical.pin.rollback.version) addIssue(issues, `${verticalPath}.pin.rollback.version`, `rollback version "${vertical.pin.rollback.version}" does not match token pack "${vertical.pin.rollback.tokenPack}" version "${rollbackTokenPack.version}"`);
|
|
66
|
+
} else addIssue(issues, `${verticalPath}.pin.rollback.tokenPack`, `unknown rollback token pack "${vertical.pin.rollback.tokenPack}"`);
|
|
67
|
+
if (!vertical.pin.rollback.reason) addIssue(issues, `${verticalPath}.pin.rollback.reason`, 'rollback metadata must include a reason');
|
|
68
|
+
}
|
|
69
|
+
const compatibility = validateDesignSystemConsumerCompatibility(vertical, tokenPack, verticalPath);
|
|
70
|
+
issues.push(...compatibility.issues);
|
|
71
|
+
}
|
|
72
|
+
return createValidationResult(issues);
|
|
73
|
+
};
|
|
74
|
+
export { DESIGN_SYSTEM_MODES, DESIGN_SYSTEM_OVERRIDE_LAYERS, createDesignSystemTokenPackMap, validateDesignSystemConsumerCompatibility, validateDesignSystemContract };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { OUTPUT_CONFIG_FILE, ensureAbsolutePath, fs } from "@modern-js/utils";
|
|
3
|
+
import { stringify } from "flatted";
|
|
4
|
+
import * as __rspack_external_path from "path";
|
|
5
|
+
const emitResolvedConfig = async (appDirectory, resolvedConfig)=>{
|
|
6
|
+
const outputPath = ensureAbsolutePath(appDirectory, __rspack_external_path.join(resolvedConfig.output.distPath?.root || './dist', OUTPUT_CONFIG_FILE));
|
|
7
|
+
const output = stringify(resolvedConfig);
|
|
8
|
+
await fs.writeFile(outputPath, output, {
|
|
9
|
+
encoding: 'utf-8'
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export { emitResolvedConfig };
|