@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.1 → 3.5.0-ultramodern.100
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 +0 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +20 -16
- package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +14 -11
- package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +72 -0
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +28 -11
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +13 -6
- package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
- package/dist/cjs/commands/build.js +2 -1
- package/dist/cjs/commands/deploy.js +4 -2
- package/dist/cjs/commands/index.js +0 -8
- package/dist/cjs/config/build-environment.js +268 -0
- package/dist/cjs/config/default.js +2 -0
- package/dist/cjs/config/index.js +11 -4
- package/dist/cjs/config/public.js +46 -0
- package/dist/cjs/index.js +93 -75
- package/dist/cjs/plugins/analyze/getServerRoutes.js +19 -0
- package/dist/cjs/plugins/analyze/index.js +22 -14
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/backend-federation/codegen.js +255 -0
- package/dist/cjs/plugins/backend-federation/config.js +204 -0
- package/dist/cjs/plugins/backend-federation/emit.js +148 -0
- package/dist/cjs/plugins/backendFederationBuild.js +53 -0
- package/dist/cjs/plugins/deploy/index.js +4 -4
- package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +141 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +139 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +150 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +208 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +204 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +108 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +188 -0
- package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +89 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +151 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +302 -0
- package/dist/cjs/plugins/deploy/platforms/node.js +20 -2
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/cjs/plugins/deploy/utils/npmAliases.js +226 -0
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +100 -0
- package/dist/cjs/presetUltramodern.js +33 -2
- package/dist/cjs/ultramodern-release-envelope/canonical.js +68 -0
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +597 -0
- package/dist/cjs/ultramodern-release-envelope/index.js +399 -0
- package/dist/cjs/ultramodern-release-envelope/types.js +51 -0
- package/dist/cjs/ultramodern-release-identity.js +110 -0
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +19 -15
- package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
- package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +30 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
- package/dist/esm/builder/shared/bundlerPlugins/index.mjs +1 -0
- package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/deploy.mjs +4 -2
- package/dist/esm/commands/index.mjs +0 -5
- package/dist/esm/config/build-environment.mjs +224 -0
- package/dist/esm/config/default.mjs +2 -0
- package/dist/esm/config/index.mjs +1 -0
- package/dist/esm/config/public.mjs +1 -0
- package/dist/esm/index.mjs +20 -5
- package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
- package/dist/esm/plugins/analyze/getServerRoutes.mjs +17 -1
- package/dist/esm/plugins/analyze/index.mjs +22 -14
- package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
- package/dist/esm/plugins/analyze/utils.mjs +3 -2
- package/dist/esm/plugins/backend-federation/codegen.mjs +204 -0
- package/dist/esm/plugins/backend-federation/config.mjs +128 -0
- package/dist/esm/plugins/backend-federation/emit.mjs +97 -0
- package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
- package/dist/esm/plugins/deploy/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +88 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +102 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +148 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +150 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +31 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +133 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +51 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +99 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +238 -0
- package/dist/esm/plugins/deploy/platforms/node.mjs +20 -2
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/esm/plugins/deploy/utils/npmAliases.mjs +174 -0
- package/dist/esm/plugins/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +52 -0
- package/dist/esm/presetUltramodern.mjs +33 -2
- package/dist/esm/ultramodern-release-envelope/canonical.mjs +21 -0
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +524 -0
- package/dist/esm/ultramodern-release-envelope/index.mjs +335 -0
- package/dist/esm/ultramodern-release-envelope/types.mjs +7 -0
- package/dist/esm/ultramodern-release-identity.mjs +66 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +21 -17
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +2 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
- package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +31 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
- package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +1 -0
- package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
- package/dist/esm-node/commands/build.mjs +2 -1
- package/dist/esm-node/commands/deploy.mjs +4 -2
- package/dist/esm-node/commands/index.mjs +0 -5
- package/dist/esm-node/config/build-environment.mjs +225 -0
- package/dist/esm-node/config/default.mjs +2 -0
- package/dist/esm-node/config/index.mjs +1 -0
- package/dist/esm-node/config/public.mjs +2 -0
- package/dist/esm-node/index.mjs +20 -5
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
- package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +17 -1
- package/dist/esm-node/plugins/analyze/index.mjs +22 -14
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
- package/dist/esm-node/plugins/analyze/utils.mjs +3 -2
- package/dist/esm-node/plugins/backend-federation/codegen.mjs +205 -0
- package/dist/esm-node/plugins/backend-federation/config.mjs +129 -0
- package/dist/esm-node/plugins/backend-federation/emit.mjs +98 -0
- package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
- package/dist/esm-node/plugins/deploy/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +35 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +89 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +103 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +149 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +151 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +32 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +134 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +52 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +100 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +239 -0
- package/dist/esm-node/plugins/deploy/platforms/node.mjs +20 -2
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/esm-node/plugins/deploy/utils/index.mjs +5 -5
- package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +175 -0
- package/dist/esm-node/plugins/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +53 -0
- package/dist/esm-node/presetUltramodern.mjs +33 -2
- package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +22 -0
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +525 -0
- package/dist/esm-node/ultramodern-release-envelope/index.mjs +336 -0
- package/dist/esm-node/ultramodern-release-envelope/types.mjs +8 -0
- package/dist/esm-node/ultramodern-release-identity.mjs +67 -0
- package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
- package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +6 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -0
- package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/index.d.ts +0 -1
- package/dist/types/config/build-environment.d.ts +22 -0
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/public.d.ts +2 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
- package/dist/types/plugins/backend-federation/config.d.ts +103 -0
- package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
- package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +24 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
- package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
- package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +122 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +46 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +20 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
- package/dist/types/plugins/deploy/utils/npmAliases.d.ts +14 -0
- package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +3 -0
- package/dist/types/presetUltramodern.d.ts +10 -0
- package/dist/types/run/index.d.ts +1 -1
- package/dist/types/types/config/cloudflareDeploy.d.ts +41 -0
- package/dist/types/types/config/deploy.d.ts +15 -2
- package/dist/types/types/config/dev.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/canonical.d.ts +5 -0
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +31 -0
- package/dist/types/ultramodern-release-envelope/index.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/types.d.ts +62 -0
- package/dist/types/ultramodern-release-identity.d.ts +16 -0
- package/docs/_nav.json +36 -0
- package/docs/apis/_meta.json +13 -0
- package/docs/apis/app/commands.mdx +205 -0
- package/docs/apis/app/hooks/_meta.json +28 -0
- package/docs/apis/app/hooks/api/lambda.mdx +13 -0
- package/docs/apis/app/hooks/config/_meta.json +1 -0
- package/docs/apis/app/hooks/config/favicon.mdx +29 -0
- package/docs/apis/app/hooks/config/html.mdx +9 -0
- package/docs/apis/app/hooks/config/icon.mdx +29 -0
- package/docs/apis/app/hooks/config/mock.mdx +10 -0
- package/docs/apis/app/hooks/config/public.mdx +30 -0
- package/docs/apis/app/hooks/config/upload.mdx +54 -0
- package/docs/apis/app/hooks/modern-config.mdx +9 -0
- package/docs/apis/app/hooks/server/server.mdx +10 -0
- package/docs/apis/app/hooks/shared.mdx +7 -0
- package/docs/apis/app/hooks/src/app.mdx +30 -0
- package/docs/apis/app/hooks/src/entry.mdx +39 -0
- package/docs/apis/app/hooks/src/entry.server.mdx +56 -0
- package/docs/apis/app/hooks/src/modern.runtime.mdx +9 -0
- package/docs/apis/app/hooks/src/routes.mdx +90 -0
- package/docs/apis/app/hooks/src/server.mdx +7 -0
- package/docs/apis/app/runtime/_meta.json +32 -0
- package/docs/apis/app/runtime/bff/use-backend-context.mdx +30 -0
- package/docs/apis/app/runtime/core/create-root.mdx +22 -0
- package/docs/apis/app/runtime/core/render.mdx +42 -0
- package/docs/apis/app/runtime/core/runtime-context.mdx +160 -0
- package/docs/apis/app/runtime/router/router.mdx +288 -0
- package/docs/apis/app/runtime/ssr/no-ssr.mdx +38 -0
- package/docs/apis/app/runtime/ssr/renderStreaming.mdx +71 -0
- package/docs/apis/app/runtime/ssr/renderString.mdx +64 -0
- package/docs/apis/app/runtime/ssr/requestHandler.mdx +48 -0
- package/docs/apis/app/runtime/utility/css-in-js.mdx +44 -0
- package/docs/apis/app/runtime/utility/head.mdx +38 -0
- package/docs/apis/app/runtime/utility/loadable.mdx +85 -0
- package/docs/components/auto-upgrade.mdx +0 -0
- package/docs/components/bff-upload.mdx +97 -0
- package/docs/components/build-output.mdx +45 -0
- package/docs/components/bundler.mdx +3 -0
- package/docs/components/convention-routing-motivation.mdx +0 -0
- package/docs/components/debug-app.mdx +15 -0
- package/docs/components/default-browserslist.mdx +7 -0
- package/docs/components/deploy-command.mdx +14 -0
- package/docs/components/deploy.mdx +1 -0
- package/docs/components/enable-bff-caution.mdx +3 -0
- package/docs/components/enable-bff.mdx +56 -0
- package/docs/components/enable-ssg.mdx +49 -0
- package/docs/components/entry-mode.mdx +0 -0
- package/docs/components/entry-scan-logic.mdx +7 -0
- package/docs/components/extend-bff-function.mdx +3 -0
- package/docs/components/hono.mdx +120 -0
- package/docs/components/init-app.mdx +93 -0
- package/docs/components/init-rspack-app.mdx +5 -0
- package/docs/components/internal-logger.mdx +25 -0
- package/docs/components/internal-metrics.mdx +20 -0
- package/docs/components/international/custom-instance-code.mdx +16 -0
- package/docs/components/international/init-options-desc.mdx +1 -0
- package/docs/components/international/install-command.mdx +10 -0
- package/docs/components/international/instance-code.mdx +16 -0
- package/docs/components/international/introduce.mdx +5 -0
- package/docs/components/international/platform-support.mdx +0 -0
- package/docs/components/language-config.mdx +9 -0
- package/docs/components/micro-frontend.mdx +6 -0
- package/docs/components/micro-master-manifest-config.mdx +15 -0
- package/docs/components/micro-runtime-config.mdx +17 -0
- package/docs/components/module-federation.mdx +7 -0
- package/docs/components/new-entry-tooltip.mdx +0 -0
- package/docs/components/nodeVersion.mdx +28 -0
- package/docs/components/other-plugins.mdx +0 -0
- package/docs/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/components/output-distpath-warning.mdx +0 -0
- package/docs/components/output-polyfill-extend.mdx +1 -0
- package/docs/components/prerequisites.mdx +18 -0
- package/docs/components/release-note.mdx +1 -0
- package/docs/components/routes-practice.mdx +0 -0
- package/docs/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/components/rsbuild.mdx +3 -0
- package/docs/components/rsc-deploy-tip.mdx +1 -0
- package/docs/components/rspack.mdx +3 -0
- package/docs/components/rspackTip.mdx +7 -0
- package/docs/components/runtime-cli-config.mdx +0 -0
- package/docs/components/serve-command.mdx +22 -0
- package/docs/components/ssr-monitor.mdx +3 -0
- package/docs/components/stream-ssr-performance.mdx +0 -0
- package/docs/components/swc.mdx +3 -0
- package/docs/components/tech-stack-node-framework.mdx +1 -0
- package/docs/components/turtorials-example-list.mdx +2 -0
- package/docs/components/ua-polyfill.mdx +44 -0
- package/docs/components/upgrade-browserslist.mdx +0 -0
- package/docs/components/upgrade-config-deploy.mdx +0 -0
- package/docs/components/upgrade-faq.mdx +0 -0
- package/docs/configure/_meta.json +78 -0
- package/docs/configure/app/bff/cross-project.mdx +24 -0
- package/docs/configure/app/bff/effect.mdx +319 -0
- package/docs/configure/app/bff/prefix.mdx +33 -0
- package/docs/configure/app/bff/runtime-framework.mdx +30 -0
- package/docs/configure/app/builder-plugins.mdx +70 -0
- package/docs/configure/app/dev/asset-prefix.mdx +18 -0
- package/docs/configure/app/dev/before-start-url.mdx +21 -0
- package/docs/configure/app/dev/client.mdx +45 -0
- package/docs/configure/app/dev/hmr.mdx +14 -0
- package/docs/configure/app/dev/host.mdx +22 -0
- package/docs/configure/app/dev/https.mdx +81 -0
- package/docs/configure/app/dev/lazy-compilation.mdx +45 -0
- package/docs/configure/app/dev/live-reload.mdx +14 -0
- package/docs/configure/app/dev/mock-dir.mdx +35 -0
- package/docs/configure/app/dev/progress-bar.mdx +23 -0
- package/docs/configure/app/dev/server.mdx +128 -0
- package/docs/configure/app/dev/setup-middlewares.mdx +36 -0
- package/docs/configure/app/dev/start-url.mdx +53 -0
- package/docs/configure/app/dev/watch-files.mdx +31 -0
- package/docs/configure/app/dev/write-to-disk.mdx +14 -0
- package/docs/configure/app/experiments/source-build.mdx +33 -0
- package/docs/configure/app/html/app-icon.mdx +32 -0
- package/docs/configure/app/html/crossorigin.mdx +14 -0
- package/docs/configure/app/html/favicon.mdx +20 -0
- package/docs/configure/app/html/inject.mdx +14 -0
- package/docs/configure/app/html/meta.mdx +28 -0
- package/docs/configure/app/html/mount-id.mdx +14 -0
- package/docs/configure/app/html/output-structure.mdx +14 -0
- package/docs/configure/app/html/script-loading.mdx +14 -0
- package/docs/configure/app/html/tags.mdx +19 -0
- package/docs/configure/app/html/template-parameters.mdx +37 -0
- package/docs/configure/app/html/template.mdx +14 -0
- package/docs/configure/app/html/title.mdx +22 -0
- package/docs/configure/app/output/asset-prefix.mdx +18 -0
- package/docs/configure/app/output/assets-retry.mdx +81 -0
- package/docs/configure/app/output/charset.mdx +14 -0
- package/docs/configure/app/output/clean-dist-path.mdx +20 -0
- package/docs/configure/app/output/convert-to-rem.mdx +83 -0
- package/docs/configure/app/output/copy.mdx +14 -0
- package/docs/configure/app/output/css-modules.mdx +52 -0
- package/docs/configure/app/output/data-uri-limit.mdx +30 -0
- package/docs/configure/app/output/disable-css-module-extension.mdx +59 -0
- package/docs/configure/app/output/disable-inline-runtime-chunk.mdx +45 -0
- package/docs/configure/app/output/disable-svgr.mdx +22 -0
- package/docs/configure/app/output/disable-ts-checker.mdx +53 -0
- package/docs/configure/app/output/dist-path.mdx +51 -0
- package/docs/configure/app/output/enable-asset-manifest.mdx +40 -0
- package/docs/configure/app/output/enable-css-module-tsdeclaration.mdx +32 -0
- package/docs/configure/app/output/enable-inline-route-manifests.mdx +20 -0
- package/docs/configure/app/output/externals.mdx +24 -0
- package/docs/configure/app/output/filename-hash.mdx +14 -0
- package/docs/configure/app/output/filename.mdx +59 -0
- package/docs/configure/app/output/inject-styles.mdx +14 -0
- package/docs/configure/app/output/inline-scripts.mdx +33 -0
- package/docs/configure/app/output/inline-styles.mdx +33 -0
- package/docs/configure/app/output/legal-comments.mdx +22 -0
- package/docs/configure/app/output/minify.mdx +26 -0
- package/docs/configure/app/output/override-browserslist.mdx +26 -0
- package/docs/configure/app/output/polyfill.mdx +18 -0
- package/docs/configure/app/output/source-map.mdx +34 -0
- package/docs/configure/app/output/split-route-chunks.mdx +20 -0
- package/docs/configure/app/output/ssg.mdx +85 -0
- package/docs/configure/app/output/ssgByEntries.mdx +93 -0
- package/docs/configure/app/output/svg-default-export.mdx +34 -0
- package/docs/configure/app/output/temp-dir.mdx +24 -0
- package/docs/configure/app/performance/build-cache.mdx +48 -0
- package/docs/configure/app/performance/chunk-split.mdx +44 -0
- package/docs/configure/app/performance/dns-prefetch.mdx +19 -0
- package/docs/configure/app/performance/preconnect.mdx +20 -0
- package/docs/configure/app/performance/prefetch.mdx +25 -0
- package/docs/configure/app/performance/preload.mdx +27 -0
- package/docs/configure/app/performance/print-file-size.mdx +44 -0
- package/docs/configure/app/performance/profile.mdx +14 -0
- package/docs/configure/app/performance/remove-console.mdx +14 -0
- package/docs/configure/app/performance/remove-moment-locale.mdx +14 -0
- package/docs/configure/app/performance/rsdoctor.mdx +42 -0
- package/docs/configure/app/plugins.mdx +59 -0
- package/docs/configure/app/resolve/alias-strategy.mdx +14 -0
- package/docs/configure/app/resolve/alias.mdx +13 -0
- package/docs/configure/app/resolve/condition-names.mdx +18 -0
- package/docs/configure/app/resolve/dedupe.mdx +13 -0
- package/docs/configure/app/resolve/extensions.mdx +18 -0
- package/docs/configure/app/runtime/0-intro.mdx +61 -0
- package/docs/configure/app/runtime/plugins.mdx +58 -0
- package/docs/configure/app/runtime/router.mdx +39 -0
- package/docs/configure/app/security/check-syntax.mdx +73 -0
- package/docs/configure/app/security/nonce.mdx +19 -0
- package/docs/configure/app/security/sri.mdx +24 -0
- package/docs/configure/app/server/base-url.mdx +30 -0
- package/docs/configure/app/server/port.mdx +22 -0
- package/docs/configure/app/server/public-routes.mdx +26 -0
- package/docs/configure/app/server/routes.mdx +90 -0
- package/docs/configure/app/server/rsc.mdx +30 -0
- package/docs/configure/app/server/ssr-by-entries.mdx +29 -0
- package/docs/configure/app/server/ssr.mdx +85 -0
- package/docs/configure/app/server/tsconfig-path.mdx +63 -0
- package/docs/configure/app/source/alias-strategy.mdx +18 -0
- package/docs/configure/app/source/alias.mdx +27 -0
- package/docs/configure/app/source/config-dir.mdx +24 -0
- package/docs/configure/app/source/decorators.mdx +29 -0
- package/docs/configure/app/source/define.mdx +20 -0
- package/docs/configure/app/source/disable-default-entries.mdx +32 -0
- package/docs/configure/app/source/enable-async-entry.mdx +54 -0
- package/docs/configure/app/source/enable-async-pre-entry.mdx +30 -0
- package/docs/configure/app/source/entries-dir.mdx +39 -0
- package/docs/configure/app/source/entries.mdx +183 -0
- package/docs/configure/app/source/exclude.mdx +14 -0
- package/docs/configure/app/source/global-vars.mdx +110 -0
- package/docs/configure/app/source/include.mdx +40 -0
- package/docs/configure/app/source/main-entry-name.mdx +28 -0
- package/docs/configure/app/source/pre-entry.mdx +14 -0
- package/docs/configure/app/source/react-compiler.mdx +72 -0
- package/docs/configure/app/source/transform-import.mdx +31 -0
- package/docs/configure/app/split-chunks.mdx +17 -0
- package/docs/configure/app/tools/autoprefixer.mdx +48 -0
- package/docs/configure/app/tools/bundler-chain.mdx +30 -0
- package/docs/configure/app/tools/css-extract.mdx +37 -0
- package/docs/configure/app/tools/css-loader.mdx +21 -0
- package/docs/configure/app/tools/dev-server.mdx +117 -0
- package/docs/configure/app/tools/html-plugin.mdx +45 -0
- package/docs/configure/app/tools/less.mdx +85 -0
- package/docs/configure/app/tools/lightningcss-loader.mdx +39 -0
- package/docs/configure/app/tools/minify-css.mdx +57 -0
- package/docs/configure/app/tools/postcss.mdx +38 -0
- package/docs/configure/app/tools/rspack.mdx +14 -0
- package/docs/configure/app/tools/sass.mdx +82 -0
- package/docs/configure/app/tools/style-loader.mdx +14 -0
- package/docs/configure/app/tools/swc.mdx +69 -0
- package/docs/configure/app/tools/ts-checker.mdx +103 -0
- package/docs/configure/app/usage.mdx +276 -0
- package/docs/guides/_meta.json +37 -0
- package/docs/guides/advanced-features/_meta.json +32 -0
- package/docs/guides/advanced-features/bff/_meta.json +10 -0
- package/docs/guides/advanced-features/bff/cross-project.mdx +110 -0
- package/docs/guides/advanced-features/bff/data-platform.mdx +120 -0
- package/docs/guides/advanced-features/bff/extend-server.mdx +120 -0
- package/docs/guides/advanced-features/bff/frameworks.mdx +131 -0
- package/docs/guides/advanced-features/bff/function.mdx +265 -0
- package/docs/guides/advanced-features/bff/operators.mdx +629 -0
- package/docs/guides/advanced-features/bff/sdk.mdx +116 -0
- package/docs/guides/advanced-features/bff/upload.mdx +7 -0
- package/docs/guides/advanced-features/bff.mdx +22 -0
- package/docs/guides/advanced-features/build-performance.mdx +134 -0
- package/docs/guides/advanced-features/compatibility.mdx +81 -0
- package/docs/guides/advanced-features/international/_meta.json +10 -0
- package/docs/guides/advanced-features/international/advanced.mdx +132 -0
- package/docs/guides/advanced-features/international/api.mdx +271 -0
- package/docs/guides/advanced-features/international/best-practices.mdx +290 -0
- package/docs/guides/advanced-features/international/configuration.mdx +222 -0
- package/docs/guides/advanced-features/international/locale-detection.mdx +130 -0
- package/docs/guides/advanced-features/international/quick-start.mdx +112 -0
- package/docs/guides/advanced-features/international/resource-loading.mdx +158 -0
- package/docs/guides/advanced-features/international/routing.mdx +177 -0
- package/docs/guides/advanced-features/international.mdx +29 -0
- package/docs/guides/advanced-features/low-level.mdx +50 -0
- package/docs/guides/advanced-features/page-performance/_meta.json +1 -0
- package/docs/guides/advanced-features/page-performance/code-split.mdx +81 -0
- package/docs/guides/advanced-features/page-performance/inline-assets.mdx +163 -0
- package/docs/guides/advanced-features/page-performance/optimize-bundle.mdx +101 -0
- package/docs/guides/advanced-features/page-performance/react-compiler.mdx +51 -0
- package/docs/guides/advanced-features/server-monitor/_meta.json +1 -0
- package/docs/guides/advanced-features/server-monitor/logger.mdx +19 -0
- package/docs/guides/advanced-features/server-monitor/metrics.mdx +41 -0
- package/docs/guides/advanced-features/server-monitor/monitors.mdx +242 -0
- package/docs/guides/advanced-features/source-build.mdx +168 -0
- package/docs/guides/advanced-features/web-server.mdx +296 -0
- package/docs/guides/basic-features/_meta.json +49 -0
- package/docs/guides/basic-features/alias.mdx +106 -0
- package/docs/guides/basic-features/css/_meta.json +1 -0
- package/docs/guides/basic-features/css/css-in-js.mdx +69 -0
- package/docs/guides/basic-features/css/css-modules.mdx +212 -0
- package/docs/guides/basic-features/css/css.mdx +31 -0
- package/docs/guides/basic-features/css/tailwindcss.mdx +27 -0
- package/docs/guides/basic-features/data/_meta.json +1 -0
- package/docs/guides/basic-features/data/data-cache.mdx +515 -0
- package/docs/guides/basic-features/data/data-fetch.mdx +419 -0
- package/docs/guides/basic-features/data/data-write.mdx +230 -0
- package/docs/guides/basic-features/debug/_meta.json +1 -0
- package/docs/guides/basic-features/debug/mock.mdx +113 -0
- package/docs/guides/basic-features/debug/proxy.mdx +25 -0
- package/docs/guides/basic-features/debug/rsdoctor.mdx +47 -0
- package/docs/guides/basic-features/debug/using-storybook.mdx +100 -0
- package/docs/guides/basic-features/deploy.mdx +448 -0
- package/docs/guides/basic-features/env-vars.mdx +181 -0
- package/docs/guides/basic-features/html.mdx +259 -0
- package/docs/guides/basic-features/output-files.mdx +145 -0
- package/docs/guides/basic-features/render/_meta.json +1 -0
- package/docs/guides/basic-features/render/before-render.mdx +108 -0
- package/docs/guides/basic-features/render/overview.mdx +51 -0
- package/docs/guides/basic-features/render/rsc.mdx +533 -0
- package/docs/guides/basic-features/render/ssg.mdx +167 -0
- package/docs/guides/basic-features/render/ssr-cache.mdx +201 -0
- package/docs/guides/basic-features/render/ssr.mdx +323 -0
- package/docs/guides/basic-features/render/streaming-ssr.mdx +267 -0
- package/docs/guides/basic-features/routes/_meta.json +1 -0
- package/docs/guides/basic-features/routes/config-routes.mdx +427 -0
- package/docs/guides/basic-features/routes/routes.mdx +532 -0
- package/docs/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/guides/basic-features/static-assets/json-files.mdx +124 -0
- package/docs/guides/basic-features/static-assets/svg-assets.mdx +172 -0
- package/docs/guides/basic-features/static-assets/wasm-assets.mdx +66 -0
- package/docs/guides/basic-features/static-assets.mdx +164 -0
- package/docs/guides/basic-features/testing/_meta.json +1 -0
- package/docs/guides/basic-features/testing/playwright.mdx +111 -0
- package/docs/guides/basic-features/testing/rstest.mdx +192 -0
- package/docs/guides/concept/_meta.json +1 -0
- package/docs/guides/concept/builder.mdx +60 -0
- package/docs/guides/concept/entries.mdx +325 -0
- package/docs/guides/concept/server.mdx +35 -0
- package/docs/guides/get-started/_meta.json +9 -0
- package/docs/guides/get-started/ai-coding-agents.mdx +63 -0
- package/docs/guides/get-started/glossary.mdx +63 -0
- package/docs/guides/get-started/introduction.mdx +45 -0
- package/docs/guides/get-started/quick-start.mdx +92 -0
- package/docs/guides/get-started/tech-stack.mdx +97 -0
- package/docs/guides/get-started/ultramodern.mdx +433 -0
- package/docs/guides/get-started/upgrade.mdx +114 -0
- package/docs/guides/topic-detail/_meta.json +8 -0
- package/docs/guides/topic-detail/module-federation/_meta.json +1 -0
- package/docs/guides/topic-detail/module-federation/application.mdx +116 -0
- package/docs/guides/topic-detail/module-federation/deploy.mdx +104 -0
- package/docs/guides/topic-detail/module-federation/i18n.mdx +670 -0
- package/docs/guides/topic-detail/module-federation/introduce.mdx +36 -0
- package/docs/guides/topic-detail/module-federation/ssr.mdx +177 -0
- package/docs/guides/topic-detail/module-federation/usage.mdx +202 -0
- package/docs/guides/troubleshooting/_meta.json +1 -0
- package/docs/guides/troubleshooting/builder.mdx +114 -0
- package/docs/guides/troubleshooting/cli.mdx +39 -0
- package/docs/guides/troubleshooting/dependencies.mdx +123 -0
- package/docs/guides/troubleshooting/hmr.mdx +148 -0
- package/docs/guides/upgrade/_meta.json +1 -0
- package/docs/guides/upgrade/config.mdx +951 -0
- package/docs/guides/upgrade/entry.mdx +463 -0
- package/docs/guides/upgrade/other.mdx +183 -0
- package/docs/guides/upgrade/overview.mdx +33 -0
- package/docs/guides/upgrade/tailwindcss.mdx +92 -0
- package/docs/guides/upgrade/web-server.md +109 -0
- package/docs/index.md +4 -0
- package/lib/types.d.ts +2 -3
- package/package.json +69 -31
- package/rslib.config.mts +11 -12
- package/scripts/copy-main-doc.mjs +50 -0
- package/dist/cjs/commands/runtime.js +0 -196
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/cjs/ultramodern/designSystem.js +0 -123
- package/dist/esm/baseline.mjs +0 -4
- package/dist/esm/commands/runtime.mjs +0 -146
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/esm/ultramodern/designSystem.mjs +0 -73
- package/dist/esm-node/baseline.mjs +0 -5
- package/dist/esm-node/commands/runtime.mjs +0 -147
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
- package/dist/types/baseline.d.ts +0 -16
- package/dist/types/commands/runtime.d.ts +0 -12
- package/dist/types/ultramodern/designSystem.d.ts +0 -54
- /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import promises from "node:fs/promises";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { canonicalSerializeMicroVerticalReleaseEnvelope, digestMicroVerticalReleaseEnvelopePayload, releaseEnvelopePayload } from "./canonical.mjs";
|
|
5
|
+
import { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS } from "./types.mjs";
|
|
6
|
+
const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
|
|
7
|
+
const SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
|
|
8
|
+
const TARGETS = new Set(MICROVERTICAL_RELEASE_TARGETS);
|
|
9
|
+
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
10
|
+
const assertRecord = (value, location)=>{
|
|
11
|
+
if (!isRecord(value)) throw new Error(`${location} must be an object.`);
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
const assertExactKeys = (value, expected, location)=>{
|
|
15
|
+
const expectedKeys = new Set(expected);
|
|
16
|
+
for (const key of Object.keys(value))if (!expectedKeys.has(key)) throw new Error(`${location} contains unknown field "${key}".`);
|
|
17
|
+
for (const key of expected)if (!(key in value)) throw new Error(`${location}.${key} is required.`);
|
|
18
|
+
};
|
|
19
|
+
const assertNonEmptyString = (value, location)=>{
|
|
20
|
+
if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${location} must be a non-empty string.`);
|
|
21
|
+
if (value !== value.trim()) throw new Error(`${location} must not contain surrounding whitespace.`);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
24
|
+
const assertTarget = (value, location = 'target')=>{
|
|
25
|
+
const target = assertNonEmptyString(value, location);
|
|
26
|
+
if (!TARGETS.has(target)) throw new Error(`${location} must be one of: ${MICROVERTICAL_RELEASE_TARGETS.join(', ')}.`);
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
const assertReleaseIdentity = (value, location = 'identity')=>{
|
|
30
|
+
const identity = assertRecord(value, location);
|
|
31
|
+
assertExactKeys(identity, [
|
|
32
|
+
'unitId',
|
|
33
|
+
'buildMarker',
|
|
34
|
+
'sourceRevision',
|
|
35
|
+
'releaseVersion'
|
|
36
|
+
], location);
|
|
37
|
+
const sourceRevision = assertNonEmptyString(identity.sourceRevision, `${location}.sourceRevision`);
|
|
38
|
+
if (!SOURCE_REVISION_PATTERN.test(sourceRevision)) throw new Error(`${location}.sourceRevision must be an exact lowercase 40- or 64-character Git object ID; "${sourceRevision}" is not promotable.`);
|
|
39
|
+
return {
|
|
40
|
+
unitId: assertNonEmptyString(identity.unitId, `${location}.unitId`),
|
|
41
|
+
buildMarker: assertNonEmptyString(identity.buildMarker, `${location}.buildMarker`),
|
|
42
|
+
sourceRevision,
|
|
43
|
+
releaseVersion: assertNonEmptyString(identity.releaseVersion, `${location}.releaseVersion`)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const assertNormalizedLogicalPath = (value, location)=>{
|
|
47
|
+
const logicalPath = assertNonEmptyString(value, location);
|
|
48
|
+
if (logicalPath.includes('\\') || node_path.posix.isAbsolute(logicalPath) || node_path.posix.normalize(logicalPath) !== logicalPath || '.' === logicalPath || logicalPath.split('/').some((segment)=>'..' === segment || '.' === segment)) throw new Error(`${location} must be a normalized relative POSIX path.`);
|
|
49
|
+
return logicalPath;
|
|
50
|
+
};
|
|
51
|
+
const isPathInside = (root, candidate)=>{
|
|
52
|
+
const relative = node_path.relative(root, candidate);
|
|
53
|
+
return '' === relative || !relative.startsWith(`..${node_path.sep}`) && '..' !== relative && !node_path.isAbsolute(relative);
|
|
54
|
+
};
|
|
55
|
+
const assertArtifactInput = (value, location)=>{
|
|
56
|
+
const artifact = assertRecord(value, location);
|
|
57
|
+
assertExactKeys(artifact, [
|
|
58
|
+
'logicalPath',
|
|
59
|
+
'runtime'
|
|
60
|
+
], location);
|
|
61
|
+
return {
|
|
62
|
+
logicalPath: assertNormalizedLogicalPath(artifact.logicalPath, `${location}.logicalPath`),
|
|
63
|
+
runtime: assertNonEmptyString(artifact.runtime, `${location}.runtime`)
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const readFinalArtifact = async (artifactRoot, input, resolvedLogicalPath = input.logicalPath)=>{
|
|
67
|
+
const artifactInput = {
|
|
68
|
+
logicalPath: input.logicalPath,
|
|
69
|
+
runtime: input.runtime
|
|
70
|
+
};
|
|
71
|
+
const logicalPath = assertNormalizedLogicalPath(resolvedLogicalPath, `staged path for ${input.logicalPath}`);
|
|
72
|
+
const resolvedRoot = node_path.resolve(artifactRoot);
|
|
73
|
+
const logicalSegments = logicalPath.split('/');
|
|
74
|
+
const lexicalPath = node_path.resolve(resolvedRoot, ...logicalSegments);
|
|
75
|
+
if (!isPathInside(resolvedRoot, lexicalPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
|
|
76
|
+
const realRoot = await promises.realpath(resolvedRoot);
|
|
77
|
+
for(let index = 0; index < logicalSegments.length - 1; index++){
|
|
78
|
+
const linkLogicalPath = logicalSegments.slice(0, index + 1).join('/');
|
|
79
|
+
const candidate = node_path.join(resolvedRoot, ...logicalSegments.slice(0, index + 1));
|
|
80
|
+
let candidateStat;
|
|
81
|
+
try {
|
|
82
|
+
candidateStat = await promises.lstat(candidate);
|
|
83
|
+
} catch {
|
|
84
|
+
throw new Error(`Artifact "${logicalPath}" does not exist.`);
|
|
85
|
+
}
|
|
86
|
+
if (candidateStat.isSymbolicLink()) throw new Error(`Artifact "${logicalPath}" traverses symbolic-link ancestor "${linkLogicalPath}"; bind the symbolic link itself.`);
|
|
87
|
+
}
|
|
88
|
+
let lexicalStat;
|
|
89
|
+
try {
|
|
90
|
+
lexicalStat = await promises.lstat(lexicalPath);
|
|
91
|
+
} catch {
|
|
92
|
+
throw new Error(`Artifact "${logicalPath}" does not exist.`);
|
|
93
|
+
}
|
|
94
|
+
if (lexicalStat.isSymbolicLink()) {
|
|
95
|
+
let realTarget;
|
|
96
|
+
try {
|
|
97
|
+
realTarget = await promises.realpath(lexicalPath);
|
|
98
|
+
} catch {
|
|
99
|
+
throw new Error(`Artifact symbolic link "${logicalPath}" cannot be resolved.`);
|
|
100
|
+
}
|
|
101
|
+
if (!isPathInside(realRoot, realTarget)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
|
|
102
|
+
const targetStat = await promises.stat(realTarget);
|
|
103
|
+
const targetKind = targetStat.isFile() ? 'file' : targetStat.isDirectory() ? 'directory' : void 0;
|
|
104
|
+
if (!targetKind) throw new Error(`Artifact symbolic link "${logicalPath}" must resolve to a file or directory.`);
|
|
105
|
+
const targetLogicalPath = node_path.relative(realRoot, realTarget).split(node_path.sep).join('/');
|
|
106
|
+
if ('release' === targetLogicalPath || targetLogicalPath.startsWith('release/')) throw new Error(`Artifact symbolic link "${logicalPath}" targets private release metadata.`);
|
|
107
|
+
if ('directory' === targetKind && isPathInside(realTarget, await promises.realpath(node_path.dirname(lexicalPath)))) throw new Error(`Artifact symbolic link "${logicalPath}" targets an ancestor directory.`);
|
|
108
|
+
return {
|
|
109
|
+
...artifactInput,
|
|
110
|
+
kind: 'symbolic-link',
|
|
111
|
+
linkTarget: await promises.readlink(lexicalPath),
|
|
112
|
+
targetKind,
|
|
113
|
+
targetLogicalPath
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!lexicalStat.isFile()) throw new Error(`Artifact "${logicalPath}" must be a file or symlink.`);
|
|
117
|
+
const realPath = await promises.realpath(lexicalPath);
|
|
118
|
+
if (!isPathInside(realRoot, realPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
|
|
119
|
+
const bytes = await promises.readFile(realPath);
|
|
120
|
+
return {
|
|
121
|
+
...artifactInput,
|
|
122
|
+
kind: 'file',
|
|
123
|
+
byteLength: bytes.byteLength,
|
|
124
|
+
sha256: createHash('sha256').update(bytes).digest('hex')
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const assertReleaseArtifact = (value, location)=>{
|
|
128
|
+
const artifact = assertRecord(value, location);
|
|
129
|
+
const kind = assertNonEmptyString(artifact.kind, `${location}.kind`);
|
|
130
|
+
const input = {
|
|
131
|
+
logicalPath: artifact.logicalPath,
|
|
132
|
+
runtime: artifact.runtime
|
|
133
|
+
};
|
|
134
|
+
if ('file' === kind) {
|
|
135
|
+
assertExactKeys(artifact, [
|
|
136
|
+
'kind',
|
|
137
|
+
'logicalPath',
|
|
138
|
+
'runtime',
|
|
139
|
+
'byteLength',
|
|
140
|
+
'sha256'
|
|
141
|
+
], location);
|
|
142
|
+
const byteLength = artifact.byteLength;
|
|
143
|
+
if ('number' != typeof byteLength || !Number.isSafeInteger(byteLength) || byteLength < 0) throw new Error(`${location}.byteLength must be a non-negative integer.`);
|
|
144
|
+
const sha256 = assertNonEmptyString(artifact.sha256, `${location}.sha256`);
|
|
145
|
+
if (!SHA256_PATTERN.test(sha256)) throw new Error(`${location}.sha256 must be a lowercase SHA-256 digest.`);
|
|
146
|
+
return {
|
|
147
|
+
...assertArtifactInput(input, location),
|
|
148
|
+
kind,
|
|
149
|
+
byteLength,
|
|
150
|
+
sha256
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if ('symbolic-link' === kind) {
|
|
154
|
+
assertExactKeys(artifact, [
|
|
155
|
+
'kind',
|
|
156
|
+
'logicalPath',
|
|
157
|
+
'runtime',
|
|
158
|
+
'linkTarget',
|
|
159
|
+
'targetKind',
|
|
160
|
+
'targetLogicalPath'
|
|
161
|
+
], location);
|
|
162
|
+
const targetKind = assertNonEmptyString(artifact.targetKind, `${location}.targetKind`);
|
|
163
|
+
if ('directory' !== targetKind && 'file' !== targetKind) throw new Error(`${location}.targetKind must be "directory" or "file".`);
|
|
164
|
+
return {
|
|
165
|
+
...assertArtifactInput(input, location),
|
|
166
|
+
kind,
|
|
167
|
+
linkTarget: assertNonEmptyString(artifact.linkTarget, `${location}.linkTarget`),
|
|
168
|
+
targetKind,
|
|
169
|
+
targetLogicalPath: assertNormalizedLogicalPath(artifact.targetLogicalPath, `${location}.targetLogicalPath`)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
throw new Error(`${location}.kind must be "file" or "symbolic-link".`);
|
|
173
|
+
};
|
|
174
|
+
const assertUniqueSortedArtifacts = (artifacts, location)=>{
|
|
175
|
+
const paths = artifacts.map((artifact)=>artifact.logicalPath);
|
|
176
|
+
const unique = new Set(paths);
|
|
177
|
+
if (unique.size !== paths.length) {
|
|
178
|
+
const duplicate = paths.find((logicalPath, index)=>paths.indexOf(logicalPath) !== index);
|
|
179
|
+
throw new Error(`Duplicate artifact logicalPath "${duplicate}".`);
|
|
180
|
+
}
|
|
181
|
+
const sorted = [
|
|
182
|
+
...paths
|
|
183
|
+
].sort((left, right)=>left.localeCompare(right));
|
|
184
|
+
if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
|
|
185
|
+
};
|
|
186
|
+
const assertSurfacePaths = (value, location)=>{
|
|
187
|
+
if (!Array.isArray(value) || 0 === value.length) throw new Error(`${location} must contain at least one artifact path.`);
|
|
188
|
+
const paths = value.map((item, index)=>assertNormalizedLogicalPath(item, `${location}[${index}]`));
|
|
189
|
+
const sorted = [
|
|
190
|
+
...paths
|
|
191
|
+
].sort((left, right)=>left.localeCompare(right));
|
|
192
|
+
if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
|
|
193
|
+
if (new Set(paths).size !== paths.length) throw new Error(`${location} must not contain duplicate artifact paths.`);
|
|
194
|
+
return paths;
|
|
195
|
+
};
|
|
196
|
+
const assertSurfaces = (value)=>{
|
|
197
|
+
const surfaces = assertRecord(value, 'surfaces');
|
|
198
|
+
assertExactKeys(surfaces, [
|
|
199
|
+
'uiClient',
|
|
200
|
+
'ssr',
|
|
201
|
+
'apiBackend',
|
|
202
|
+
'backendFederation'
|
|
203
|
+
], 'surfaces');
|
|
204
|
+
const backendFederation = assertRecord(surfaces.backendFederation, 'surfaces.backendFederation');
|
|
205
|
+
assertExactKeys(backendFederation, [
|
|
206
|
+
'manifest',
|
|
207
|
+
'container'
|
|
208
|
+
], 'surfaces.backendFederation');
|
|
209
|
+
return {
|
|
210
|
+
uiClient: assertSurfacePaths(surfaces.uiClient, 'surfaces.uiClient'),
|
|
211
|
+
ssr: assertSurfacePaths(surfaces.ssr, 'surfaces.ssr'),
|
|
212
|
+
apiBackend: assertSurfacePaths(surfaces.apiBackend, 'surfaces.apiBackend'),
|
|
213
|
+
backendFederation: {
|
|
214
|
+
manifest: assertNormalizedLogicalPath(backendFederation.manifest, 'surfaces.backendFederation.manifest'),
|
|
215
|
+
container: assertNormalizedLogicalPath(backendFederation.container, 'surfaces.backendFederation.container')
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
const assertSurfaceReferences = (artifacts, surfaces)=>{
|
|
220
|
+
const artifactPaths = new Set(artifacts.map((artifact)=>artifact.logicalPath));
|
|
221
|
+
for (const [surface, paths] of Object.entries({
|
|
222
|
+
uiClient: surfaces.uiClient,
|
|
223
|
+
ssr: surfaces.ssr,
|
|
224
|
+
apiBackend: surfaces.apiBackend,
|
|
225
|
+
'backendFederation.manifest': [
|
|
226
|
+
surfaces.backendFederation.manifest
|
|
227
|
+
],
|
|
228
|
+
'backendFederation.container': [
|
|
229
|
+
surfaces.backendFederation.container
|
|
230
|
+
]
|
|
231
|
+
}))for (const logicalPath of paths)if (!artifactPaths.has(logicalPath)) throw new Error(`surfaces.${surface} references unbound artifact "${logicalPath}".`);
|
|
232
|
+
};
|
|
233
|
+
const assertTargetSurfaceContract = (target, artifacts, surfaces)=>{
|
|
234
|
+
const byPath = new Map(artifacts.map((artifact)=>[
|
|
235
|
+
artifact.logicalPath,
|
|
236
|
+
artifact
|
|
237
|
+
]));
|
|
238
|
+
const assertRuntime = (paths, expected, surface)=>{
|
|
239
|
+
for (const logicalPath of paths){
|
|
240
|
+
const artifact = byPath.get(logicalPath);
|
|
241
|
+
if (artifact?.runtime !== expected) throw new Error(`${target} ${surface} artifact "${logicalPath}" must use runtime "${expected}"; received "${String(artifact?.runtime)}".`);
|
|
242
|
+
if ('kind' in artifact && 'file' !== artifact.kind) throw new Error(`${target} ${surface} artifact "${logicalPath}" must be a file.`);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
assertRuntime(surfaces.uiClient, 'browser', 'UI/client');
|
|
246
|
+
assertRuntime(surfaces.ssr, 'node' === target ? 'nodejs' : 'workerd', 'SSR');
|
|
247
|
+
assertRuntime(surfaces.apiBackend, 'node' === target ? 'nodejs' : 'workerd-effect', 'API/backend');
|
|
248
|
+
assertRuntime([
|
|
249
|
+
surfaces.backendFederation.manifest
|
|
250
|
+
], 'module-federation-manifest', 'backend federation manifest');
|
|
251
|
+
assertRuntime([
|
|
252
|
+
surfaces.backendFederation.container
|
|
253
|
+
], 'node' === target ? 'nodejs' : 'commonjs-module', 'backend federation container');
|
|
254
|
+
};
|
|
255
|
+
const deepFreeze = (value)=>{
|
|
256
|
+
if (null !== value && 'object' == typeof value && !Object.isFrozen(value)) {
|
|
257
|
+
Object.freeze(value);
|
|
258
|
+
for (const child of Object.values(value))deepFreeze(child);
|
|
259
|
+
}
|
|
260
|
+
return value;
|
|
261
|
+
};
|
|
262
|
+
const assertEnvelope = (value)=>{
|
|
263
|
+
const envelope = assertRecord(value, 'envelope');
|
|
264
|
+
assertExactKeys(envelope, [
|
|
265
|
+
'schemaVersion',
|
|
266
|
+
'kind',
|
|
267
|
+
'target',
|
|
268
|
+
'identity',
|
|
269
|
+
'artifacts',
|
|
270
|
+
'surfaces',
|
|
271
|
+
'envelopeDigest'
|
|
272
|
+
], 'envelope');
|
|
273
|
+
if (envelope.schemaVersion !== MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION) throw new Error(`envelope.schemaVersion must be ${MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION}.`);
|
|
274
|
+
if (envelope.kind !== MICROVERTICAL_RELEASE_ENVELOPE_KIND) throw new Error(`envelope.kind must be "${MICROVERTICAL_RELEASE_ENVELOPE_KIND}".`);
|
|
275
|
+
if (!Array.isArray(envelope.artifacts) || 0 === envelope.artifacts.length) throw new Error('envelope.artifacts must contain at least one artifact.');
|
|
276
|
+
const artifacts = envelope.artifacts.map((artifact, index)=>assertReleaseArtifact(artifact, `envelope.artifacts[${index}]`));
|
|
277
|
+
assertUniqueSortedArtifacts(artifacts, 'envelope.artifacts');
|
|
278
|
+
const target = assertTarget(envelope.target, 'envelope.target');
|
|
279
|
+
const surfaces = assertSurfaces(envelope.surfaces);
|
|
280
|
+
assertSurfaceReferences(artifacts, surfaces);
|
|
281
|
+
assertTargetSurfaceContract(target, artifacts, surfaces);
|
|
282
|
+
const parsed = {
|
|
283
|
+
schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
|
|
284
|
+
kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
|
|
285
|
+
target,
|
|
286
|
+
identity: assertReleaseIdentity(envelope.identity, 'envelope.identity'),
|
|
287
|
+
artifacts,
|
|
288
|
+
surfaces,
|
|
289
|
+
envelopeDigest: assertNonEmptyString(envelope.envelopeDigest, 'envelope.envelopeDigest')
|
|
290
|
+
};
|
|
291
|
+
if (!SHA256_PATTERN.test(parsed.envelopeDigest)) throw new Error('envelope.envelopeDigest must be a lowercase SHA-256 digest.');
|
|
292
|
+
const expectedDigest = digestMicroVerticalReleaseEnvelopePayload(releaseEnvelopePayload(parsed));
|
|
293
|
+
if (parsed.envelopeDigest !== expectedDigest) throw new Error('envelope.envelopeDigest does not match canonical payload.');
|
|
294
|
+
return parsed;
|
|
295
|
+
};
|
|
296
|
+
const createMicroVerticalReleaseEnvelope = async (input)=>{
|
|
297
|
+
const artifactRoot = await promises.realpath(node_path.resolve(input.artifactRoot));
|
|
298
|
+
const target = assertTarget(input.target);
|
|
299
|
+
const identity = assertReleaseIdentity(input.identity);
|
|
300
|
+
if (!Array.isArray(input.artifacts) || 0 === input.artifacts.length) throw new Error('artifacts must contain at least one artifact.');
|
|
301
|
+
const inputs = input.artifacts.map((artifact, index)=>assertArtifactInput(artifact, `artifacts[${index}]`));
|
|
302
|
+
const sortedInputs = [
|
|
303
|
+
...inputs
|
|
304
|
+
].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath));
|
|
305
|
+
assertUniqueSortedArtifacts(sortedInputs, 'artifacts');
|
|
306
|
+
const surfaces = assertSurfaces(input.surfaces);
|
|
307
|
+
assertSurfaceReferences(sortedInputs, surfaces);
|
|
308
|
+
assertTargetSurfaceContract(target, sortedInputs, surfaces);
|
|
309
|
+
const artifacts = await Promise.all(sortedInputs.map((artifact)=>readFinalArtifact(artifactRoot, artifact)));
|
|
310
|
+
assertTargetSurfaceContract(target, artifacts, surfaces);
|
|
311
|
+
const payload = {
|
|
312
|
+
schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
|
|
313
|
+
kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
|
|
314
|
+
target,
|
|
315
|
+
identity,
|
|
316
|
+
artifacts,
|
|
317
|
+
surfaces
|
|
318
|
+
};
|
|
319
|
+
return deepFreeze({
|
|
320
|
+
...payload,
|
|
321
|
+
envelopeDigest: digestMicroVerticalReleaseEnvelopePayload(payload)
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
const verifyMicroVerticalReleaseEnvelope = async (value, options)=>{
|
|
325
|
+
const envelope = assertEnvelope(value);
|
|
326
|
+
if (void 0 !== options.expectedTarget && envelope.target !== options.expectedTarget) throw new Error(`envelope.target must be "${options.expectedTarget}" for this staging target; received "${envelope.target}".`);
|
|
327
|
+
const artifactRoot = await promises.realpath(node_path.resolve(options.artifactRoot));
|
|
328
|
+
for (const artifact of envelope.artifacts){
|
|
329
|
+
const finalArtifact = await readFinalArtifact(artifactRoot, artifact, options.logicalPathForArtifact?.(artifact) ?? artifact.logicalPath);
|
|
330
|
+
const matches = finalArtifact.kind === artifact.kind && ('file' === artifact.kind && 'file' === finalArtifact.kind ? finalArtifact.byteLength === artifact.byteLength && finalArtifact.sha256 === artifact.sha256 : 'symbolic-link' === artifact.kind && 'symbolic-link' === finalArtifact.kind && finalArtifact.linkTarget === artifact.linkTarget && finalArtifact.targetKind === artifact.targetKind && finalArtifact.targetLogicalPath === artifact.targetLogicalPath);
|
|
331
|
+
if (!matches) throw new Error('file' === artifact.kind && 'file' === finalArtifact.kind ? `Artifact "${artifact.logicalPath}" digest does not match final artifact bytes.` : `Artifact "${artifact.logicalPath}" does not match its final filesystem binding.`);
|
|
332
|
+
}
|
|
333
|
+
return deepFreeze(envelope);
|
|
334
|
+
};
|
|
335
|
+
export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS, canonicalSerializeMicroVerticalReleaseEnvelope, createMicroVerticalReleaseEnvelope, verifyMicroVerticalReleaseEnvelope };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION = 3;
|
|
2
|
+
const MICROVERTICAL_RELEASE_ENVELOPE_KIND = 'ultramodern-target-microvertical-release-envelope';
|
|
3
|
+
const MICROVERTICAL_RELEASE_TARGETS = [
|
|
4
|
+
'node',
|
|
5
|
+
'cloudflare'
|
|
6
|
+
];
|
|
7
|
+
export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
const BUILD_MARKER_NAMESPACE = 'ultramodern-delivery-unit-release-build-marker:v1';
|
|
4
|
+
const PROMOTABLE_SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
|
|
5
|
+
const gitOutput = (workspaceRoot, args)=>{
|
|
6
|
+
try {
|
|
7
|
+
return execFileSync('git', [
|
|
8
|
+
'-C',
|
|
9
|
+
workspaceRoot,
|
|
10
|
+
...args
|
|
11
|
+
], {
|
|
12
|
+
encoding: 'utf8',
|
|
13
|
+
stdio: [
|
|
14
|
+
'ignore',
|
|
15
|
+
'pipe',
|
|
16
|
+
'ignore'
|
|
17
|
+
]
|
|
18
|
+
}).trim();
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const createUltramodernReleaseBuildMarker = ({ generationBuildMarker, sourceRevision, unitId })=>createHash('sha256').update(`${BUILD_MARKER_NAMESPACE}:${unitId}:${generationBuildMarker}:${sourceRevision}`).digest('hex').slice(0, 16);
|
|
24
|
+
const resolveUltramodernSourceRevision = (workspaceRoot = process.cwd(), configuredSourceRevision)=>{
|
|
25
|
+
const configuredArgumentValue = configuredSourceRevision?.trim();
|
|
26
|
+
const configuredEnvironmentValue = process.env.ULTRAMODERN_SOURCE_REVISION?.trim();
|
|
27
|
+
const configuredArgument = configuredArgumentValue && 'workspace' !== configuredArgumentValue ? configuredArgumentValue : void 0;
|
|
28
|
+
const configuredEnvironment = configuredEnvironmentValue && 'workspace' !== configuredEnvironmentValue ? configuredEnvironmentValue : void 0;
|
|
29
|
+
if (configuredArgument && configuredEnvironment && configuredArgument !== configuredEnvironment) throw new Error(`Configured source revision ${configuredArgument} does not match environment source revision ${configuredEnvironment}.`);
|
|
30
|
+
const configured = configuredArgument ?? configuredEnvironment;
|
|
31
|
+
const gitRoot = gitOutput(workspaceRoot, [
|
|
32
|
+
'rev-parse',
|
|
33
|
+
'--show-toplevel'
|
|
34
|
+
]);
|
|
35
|
+
if (!gitRoot) {
|
|
36
|
+
if (!configured) return 'workspace';
|
|
37
|
+
if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(configured)) throw new Error(`Configured source revision ${configured} must be an exact lowercase 40- or 64-character Git object ID.`);
|
|
38
|
+
return configured;
|
|
39
|
+
}
|
|
40
|
+
const revision = gitOutput(gitRoot, [
|
|
41
|
+
'rev-parse',
|
|
42
|
+
'HEAD'
|
|
43
|
+
]);
|
|
44
|
+
const status = gitOutput(gitRoot, [
|
|
45
|
+
'status',
|
|
46
|
+
'--porcelain=v1',
|
|
47
|
+
'--untracked-files=all'
|
|
48
|
+
]);
|
|
49
|
+
if (!revision || void 0 === status || status.length > 0) return 'workspace';
|
|
50
|
+
if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(revision)) return 'workspace';
|
|
51
|
+
if (configured && configured !== revision) throw new Error(`Configured source revision ${configured} does not match clean Git HEAD ${revision}.`);
|
|
52
|
+
return revision;
|
|
53
|
+
};
|
|
54
|
+
const resolveUltramodernReleaseIdentity = ({ generationBuildMarker, sourceRevision: configuredSourceRevision, unitId, workspaceRoot })=>{
|
|
55
|
+
const explicitSourceRevision = configuredSourceRevision?.trim();
|
|
56
|
+
const sourceRevision = resolveUltramodernSourceRevision(workspaceRoot, explicitSourceRevision);
|
|
57
|
+
return {
|
|
58
|
+
buildMarker: 'workspace' === sourceRevision ? generationBuildMarker : createUltramodernReleaseBuildMarker({
|
|
59
|
+
generationBuildMarker,
|
|
60
|
+
sourceRevision,
|
|
61
|
+
unitId
|
|
62
|
+
}),
|
|
63
|
+
sourceRevision
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export { createUltramodernReleaseBuildMarker, resolveUltramodernReleaseIdentity, resolveUltramodernSourceRevision };
|
|
@@ -15,6 +15,10 @@ function modifyOutputConfig(config, appContext) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
18
|
+
const builderDevConfig = {
|
|
19
|
+
...resolveConfig.dev
|
|
20
|
+
};
|
|
21
|
+
delete builderDevConfig.mockDir;
|
|
18
22
|
const htmlConfig = {
|
|
19
23
|
...resolveConfig.html
|
|
20
24
|
};
|
|
@@ -33,7 +37,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
33
37
|
...resolveConfig.source
|
|
34
38
|
},
|
|
35
39
|
dev: {
|
|
36
|
-
...
|
|
40
|
+
...builderDevConfig,
|
|
37
41
|
port: appContext.port
|
|
38
42
|
},
|
|
39
43
|
server: serverConfig,
|
|
@@ -4,9 +4,10 @@ import node_fs from "node:fs";
|
|
|
4
4
|
import node_path from "node:path";
|
|
5
5
|
import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/builder";
|
|
6
6
|
import { isProd, isSSR, isServiceWorker, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
|
|
7
|
+
import { CLOUDFLARE_WORKER_NODE_BUILTINS } from "../../plugins/deploy/platforms/cloudflare-output-contract.mjs";
|
|
7
8
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
8
9
|
import { dirname as __rspack_dirname } from "node:path";
|
|
9
|
-
var
|
|
10
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
10
11
|
const BFF_EFFECT_WORKER_ENTRY_NAME = '__modern_bff_effect';
|
|
11
12
|
const BFF_EFFECT_WORKER_RUNTIME_QUERY = 'modern-bff-runtime';
|
|
12
13
|
const JS_OR_TS_EXTS = [
|
|
@@ -19,21 +20,7 @@ const JS_OR_TS_EXTS = [
|
|
|
19
20
|
'.cjs',
|
|
20
21
|
'.cts'
|
|
21
22
|
];
|
|
22
|
-
const
|
|
23
|
-
'async_hooks',
|
|
24
|
-
'buffer',
|
|
25
|
-
'crypto',
|
|
26
|
-
'events',
|
|
27
|
-
'fs/promises',
|
|
28
|
-
'module',
|
|
29
|
-
'path',
|
|
30
|
-
'process',
|
|
31
|
-
'stream',
|
|
32
|
-
'string_decoder',
|
|
33
|
-
'url',
|
|
34
|
-
'util'
|
|
35
|
-
];
|
|
36
|
-
const CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR = node_path.resolve(getBuilderEnvironments_dirname, '../../plugins/deploy/platforms/templates');
|
|
23
|
+
const CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR = node_path.resolve(__rspack_import_meta_dirname__, '../../plugins/deploy/platforms/templates');
|
|
37
24
|
function findExistingFile(candidates) {
|
|
38
25
|
return candidates.find((candidate)=>node_fs.existsSync(candidate));
|
|
39
26
|
}
|
|
@@ -57,6 +44,13 @@ function resolvePackageFile(packageName, filePath, paths) {
|
|
|
57
44
|
paths
|
|
58
45
|
}));
|
|
59
46
|
} catch {
|
|
47
|
+
try {
|
|
48
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`, {
|
|
49
|
+
paths
|
|
50
|
+
});
|
|
51
|
+
const packageFile = node_path.join(node_path.dirname(packageJsonPath), filePath);
|
|
52
|
+
if (node_fs.existsSync(packageFile)) return node_fs.realpathSync(packageFile);
|
|
53
|
+
} catch {}
|
|
60
54
|
const packageEntry = resolvePackageEntry(packageName, paths);
|
|
61
55
|
if (!packageEntry) return;
|
|
62
56
|
const packageRoot = findPackageRoot(packageEntry, packageName);
|
|
@@ -263,7 +257,17 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
263
257
|
});
|
|
264
258
|
chain.output.module(true).library({
|
|
265
259
|
type: 'module'
|
|
266
|
-
}).chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
260
|
+
}).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
261
|
+
chain.optimization.usedExports(false).providedExports(true).innerGraph(false).sideEffects(false);
|
|
262
|
+
for (const condition of [
|
|
263
|
+
'workerd',
|
|
264
|
+
'worker',
|
|
265
|
+
'webpack',
|
|
266
|
+
isProd() ? 'production' : 'development',
|
|
267
|
+
'import',
|
|
268
|
+
'require',
|
|
269
|
+
'module'
|
|
270
|
+
])chain.resolve.conditionNames.add(condition);
|
|
267
271
|
chain.plugins.delete('plugin-module-federation');
|
|
268
272
|
if (tanstackRouterSsrServerFile) {
|
|
269
273
|
chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
|
|
@@ -3,7 +3,7 @@ import node_path from "node:path";
|
|
|
3
3
|
import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/builder";
|
|
4
4
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
5
|
import { dirname as __rspack_dirname } from "node:path";
|
|
6
|
-
var
|
|
6
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
7
7
|
const builderPluginAdapterBasic = (options)=>({
|
|
8
8
|
name: 'builder-plugin-adapter-modern-basic',
|
|
9
9
|
setup (api) {
|
|
@@ -17,7 +17,7 @@ const builderPluginAdapterBasic = (options)=>({
|
|
|
17
17
|
const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
18
18
|
const depExt = 'mjs';
|
|
19
19
|
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
20
|
-
chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(
|
|
20
|
+
chain.module.rule('bare-server-module').test(bareServerModuleReg).use('server-module-loader').loader(node_path.join(__rspack_import_meta_dirname__, `../loaders/serverModuleLoader.${depExt}`));
|
|
21
21
|
}
|
|
22
22
|
const { appContext } = options;
|
|
23
23
|
const { metaName } = appContext;
|
|
@@ -31,10 +31,19 @@ const mergeCompressionOptions = (base, next)=>{
|
|
|
31
31
|
...base,
|
|
32
32
|
...next
|
|
33
33
|
};
|
|
34
|
-
if (base.compressionOptions || next.compressionOptions)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (base.compressionOptions || next.compressionOptions) {
|
|
35
|
+
const baseCompressionOptions = base.compressionOptions;
|
|
36
|
+
const nextCompressionOptions = next.compressionOptions;
|
|
37
|
+
const mergedCompressionOptions = {
|
|
38
|
+
...baseCompressionOptions,
|
|
39
|
+
...nextCompressionOptions
|
|
40
|
+
};
|
|
41
|
+
if (baseCompressionOptions?.params || nextCompressionOptions?.params) mergedCompressionOptions.params = {
|
|
42
|
+
...baseCompressionOptions?.params,
|
|
43
|
+
...nextCompressionOptions?.params
|
|
44
|
+
};
|
|
45
|
+
merged.compressionOptions = mergedCompressionOptions;
|
|
46
|
+
}
|
|
38
47
|
return merged;
|
|
39
48
|
};
|
|
40
49
|
const resolveCodecOptions = (codecConfig, createDefaultOptions)=>{
|
|
@@ -4,7 +4,7 @@ import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/buil
|
|
|
4
4
|
import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
|
|
5
5
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
6
6
|
import { getServerCombinedModuleFile } from "../../../plugins/analyze/utils.mjs";
|
|
7
|
-
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
|
|
7
|
+
import { CssExtractRuntimePlugin, HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
|
|
8
8
|
import * as __rspack_external_path from "path";
|
|
9
9
|
const builderPluginAdapterSSR = (options)=>({
|
|
10
10
|
name: 'builder-plugin-adapter-modern-ssr',
|
|
@@ -65,17 +65,20 @@ function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
|
|
|
65
65
|
const workerSSR = Boolean(normalizedConfig.deploy.worker?.ssr);
|
|
66
66
|
const { enableInlineRouteManifests, disableInlineRouteManifests } = normalizedConfig.output;
|
|
67
67
|
const inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
|
|
68
|
-
if (existNestedRoutes || workerSSR)
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
if (existNestedRoutes || workerSSR) {
|
|
69
|
+
chain.plugin(`${pluginName}-css-extract-runtime`).use(CssExtractRuntimePlugin);
|
|
70
|
+
chain.plugin(pluginName).use(RouterPlugin, [
|
|
71
|
+
{
|
|
72
|
+
HtmlBundlerPlugin,
|
|
73
|
+
enableInlineRouteManifests: inlineRouteManifests,
|
|
74
|
+
staticJsDir: normalizedConfig.output?.distPath?.js,
|
|
75
|
+
disableFilenameHash: normalizedConfig.output?.filenameHash === false,
|
|
76
|
+
scriptLoading: normalizedConfig.html?.scriptLoading,
|
|
77
|
+
nonce: normalizedConfig.security?.nonce,
|
|
78
|
+
useRsc: isUseRsc(normalizedConfig)
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
79
82
|
}
|
|
80
83
|
function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|
|
81
84
|
const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const PLUGIN_NAME = 'ModernjsCssExtractRuntimePlugin';
|
|
3
|
+
const CSS_LOADING_RUNTIME_MODULE = 'webpack/runtime/css loading';
|
|
4
|
+
const CSS_EXTRACT_STYLESHEET_MATCH = '\t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return tag;';
|
|
5
|
+
const CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL = `\t\tvar absoluteHref = tag.href;
|
|
6
|
+
\t\tvar absoluteFullHref = new URL(fullhref, document.baseURI).href;
|
|
7
|
+
\t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref || absoluteHref === absoluteFullHref)) return tag;`;
|
|
8
|
+
const isAutomaticPublicPath = (publicPath)=>'auto' === publicPath || 'auto/' === publicPath;
|
|
9
|
+
const normalizeCssExtractRuntimeStylesheetLookup = (source)=>{
|
|
10
|
+
if (!source.includes('__webpack_require__.miniCssF')) return source;
|
|
11
|
+
const occurrences = source.split(CSS_EXTRACT_STYLESHEET_MATCH).length - 1;
|
|
12
|
+
if (1 !== occurrences) throw new Error(`Unsupported CssExtractRspackPlugin runtime shape: expected one stylesheet lookup, found ${occurrences}.`);
|
|
13
|
+
return source.replace(CSS_EXTRACT_STYLESHEET_MATCH, CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL);
|
|
14
|
+
};
|
|
15
|
+
class CssExtractRuntimePlugin {
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
if (!isAutomaticPublicPath(compiler.options.output.publicPath)) return;
|
|
18
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
19
|
+
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (runtimeModule)=>{
|
|
20
|
+
if (runtimeModule.identifier() !== CSS_LOADING_RUNTIME_MODULE) return;
|
|
21
|
+
const runtimeSource = runtimeModule.source?.source;
|
|
22
|
+
if ('string' != typeof runtimeSource) return;
|
|
23
|
+
runtimeModule.source.source = normalizeCssExtractRuntimeStylesheetLookup(runtimeSource);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
constructor(){
|
|
28
|
+
this.name = PLUGIN_NAME;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { CssExtractRuntimePlugin, normalizeCssExtractRuntimeStylesheetLookup };
|