@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.98 → 3.8.1-ultramodern.1
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-bundle-docs.js +7 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +80 -11
- package/dist/cjs/bundleDocs.js +114 -0
- package/dist/cjs/commands/build.js +2 -1
- package/dist/cjs/commands/deploy.js +4 -2
- package/dist/cjs/commands/index.js +0 -4
- package/dist/cjs/config/default.js +2 -0
- package/dist/cjs/index.js +56 -15
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +94 -18
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +109 -57
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +70 -10
- package/dist/esm/bundleDocs.mjs +62 -0
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/deploy.mjs +4 -2
- package/dist/esm/commands/index.mjs +0 -4
- package/dist/esm/config/default.mjs +2 -0
- package/dist/esm/index.mjs +15 -1
- package/dist/esm/plugins/analyze/index.mjs +2 -2
- package/dist/esm/plugins/analyze/utils.mjs +3 -2
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm/plugins/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +70 -10
- package/dist/esm-node/bundleDocs.mjs +63 -0
- 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 -4
- package/dist/esm-node/config/default.mjs +2 -0
- package/dist/esm-node/index.mjs +15 -1
- package/dist/esm-node/plugins/analyze/index.mjs +2 -2
- package/dist/esm-node/plugins/analyze/utils.mjs +3 -2
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm-node/plugins/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +29 -0
- package/dist/types/bundleDocs.d.ts +20 -0
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +13 -0
- package/dist/types/types/config/dev.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +1 -0
- package/docs/apis/app/commands.md +231 -0
- package/docs/apis/app/hooks/api/lambda.md +9 -0
- package/docs/apis/app/hooks/config/favicon.md +24 -0
- package/docs/apis/app/hooks/config/html.md +5 -0
- package/docs/apis/app/hooks/config/icon.md +24 -0
- package/docs/apis/app/hooks/config/mock.md +6 -0
- package/docs/apis/app/hooks/config/public.md +26 -0
- package/docs/apis/app/hooks/config/upload.md +50 -0
- package/docs/apis/app/hooks/modern-config.md +5 -0
- package/docs/apis/app/hooks/server/server.md +5 -0
- package/docs/apis/app/hooks/shared.md +3 -0
- package/docs/apis/app/hooks/src/app.md +30 -0
- package/docs/apis/app/hooks/src/entry.md +34 -0
- package/docs/apis/app/hooks/src/entry.server.md +51 -0
- package/docs/apis/app/hooks/src/modern.runtime.md +5 -0
- package/docs/apis/app/hooks/src/routes.md +86 -0
- package/docs/apis/app/hooks/src/server.md +3 -0
- package/docs/apis/app/runtime/bff/use-backend-context.md +27 -0
- package/docs/apis/app/runtime/core/create-root.md +19 -0
- package/docs/apis/app/runtime/core/render.md +39 -0
- package/docs/apis/app/runtime/core/runtime-context.md +156 -0
- package/docs/apis/app/runtime/router/router.md +283 -0
- package/docs/apis/app/runtime/ssr/no-ssr.md +35 -0
- package/docs/apis/app/runtime/ssr/renderStreaming.md +67 -0
- package/docs/apis/app/runtime/ssr/renderString.md +60 -0
- package/docs/apis/app/runtime/ssr/requestHandler.md +44 -0
- package/docs/apis/app/runtime/utility/css-in-js.md +40 -0
- package/docs/apis/app/runtime/utility/head.md +35 -0
- package/docs/apis/app/runtime/utility/loadable.md +82 -0
- package/docs/community/blog/2022-0708-updates.md +91 -0
- package/docs/community/blog/2022-0910-updates.md +76 -0
- package/docs/community/blog/overview.md +63 -0
- package/docs/community/blog/v2-release-note.md +238 -0
- package/docs/community/blog/v3-release-note.md +622 -0
- package/docs/community/contributing-guide.md +252 -0
- package/docs/community/releases.md +23 -0
- package/docs/community/showcase.md +24 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/cross-project.md +20 -0
- package/docs/configure/app/bff/effect.md +313 -0
- package/docs/configure/app/bff/prefix.md +29 -0
- package/docs/configure/app/bff/runtime-framework.md +26 -0
- package/docs/configure/app/builder-plugins.md +66 -0
- package/docs/configure/app/dev/asset-prefix.md +13 -0
- package/docs/configure/app/dev/before-start-url.md +17 -0
- package/docs/configure/app/dev/client.md +41 -0
- package/docs/configure/app/dev/hmr.md +10 -0
- package/docs/configure/app/dev/host.md +18 -0
- package/docs/configure/app/dev/https.md +77 -0
- package/docs/configure/app/dev/lazy-compilation.md +39 -0
- package/docs/configure/app/dev/live-reload.md +10 -0
- package/docs/configure/app/dev/mock-dir.md +31 -0
- package/docs/configure/app/dev/progress-bar.md +19 -0
- package/docs/configure/app/dev/server.md +124 -0
- package/docs/configure/app/dev/setup-middlewares.md +32 -0
- package/docs/configure/app/dev/start-url.md +48 -0
- package/docs/configure/app/dev/watch-files.md +27 -0
- package/docs/configure/app/dev/write-to-disk.md +10 -0
- package/docs/configure/app/experiments/source-build.md +31 -0
- package/docs/configure/app/html/app-icon.md +28 -0
- package/docs/configure/app/html/crossorigin.md +10 -0
- package/docs/configure/app/html/favicon.md +16 -0
- package/docs/configure/app/html/inject.md +10 -0
- package/docs/configure/app/html/meta.md +24 -0
- package/docs/configure/app/html/mount-id.md +10 -0
- package/docs/configure/app/html/output-structure.md +10 -0
- package/docs/configure/app/html/script-loading.md +10 -0
- package/docs/configure/app/html/tags.md +15 -0
- package/docs/configure/app/html/template-parameters.md +33 -0
- package/docs/configure/app/html/template.md +10 -0
- package/docs/configure/app/html/title.md +18 -0
- package/docs/configure/app/output/asset-prefix.md +11 -0
- package/docs/configure/app/output/assets-retry.md +77 -0
- package/docs/configure/app/output/charset.md +10 -0
- package/docs/configure/app/output/clean-dist-path.md +16 -0
- package/docs/configure/app/output/convert-to-rem.md +79 -0
- package/docs/configure/app/output/copy.md +10 -0
- package/docs/configure/app/output/css-modules.md +48 -0
- package/docs/configure/app/output/data-uri-limit.md +26 -0
- package/docs/configure/app/output/disable-css-module-extension.md +55 -0
- package/docs/configure/app/output/disable-inline-runtime-chunk.md +41 -0
- package/docs/configure/app/output/disable-svgr.md +18 -0
- package/docs/configure/app/output/disable-ts-checker.md +49 -0
- package/docs/configure/app/output/dist-path.md +43 -0
- package/docs/configure/app/output/enable-asset-manifest.md +36 -0
- package/docs/configure/app/output/enable-css-module-tsdeclaration.md +28 -0
- package/docs/configure/app/output/enable-inline-route-manifests.md +16 -0
- package/docs/configure/app/output/externals.md +20 -0
- package/docs/configure/app/output/filename-hash.md +10 -0
- package/docs/configure/app/output/filename.md +55 -0
- package/docs/configure/app/output/inject-styles.md +10 -0
- package/docs/configure/app/output/inline-scripts.md +29 -0
- package/docs/configure/app/output/inline-styles.md +29 -0
- package/docs/configure/app/output/legal-comments.md +18 -0
- package/docs/configure/app/output/minify.md +22 -0
- package/docs/configure/app/output/override-browserslist.md +22 -0
- package/docs/configure/app/output/polyfill.md +12 -0
- package/docs/configure/app/output/source-map.md +30 -0
- package/docs/configure/app/output/split-route-chunks.md +16 -0
- package/docs/configure/app/output/ssg.md +81 -0
- package/docs/configure/app/output/ssgByEntries.md +90 -0
- package/docs/configure/app/output/svg-default-export.md +30 -0
- package/docs/configure/app/output/temp-dir.md +20 -0
- package/docs/configure/app/performance/build-cache.md +44 -0
- package/docs/configure/app/performance/chunk-split.md +40 -0
- package/docs/configure/app/performance/dns-prefetch.md +15 -0
- package/docs/configure/app/performance/preconnect.md +16 -0
- package/docs/configure/app/performance/prefetch.md +21 -0
- package/docs/configure/app/performance/preload.md +23 -0
- package/docs/configure/app/performance/print-file-size.md +40 -0
- package/docs/configure/app/performance/profile.md +10 -0
- package/docs/configure/app/performance/remove-console.md +10 -0
- package/docs/configure/app/performance/remove-moment-locale.md +10 -0
- package/docs/configure/app/performance/rsdoctor.md +38 -0
- package/docs/configure/app/plugins.md +59 -0
- package/docs/configure/app/resolve/alias-strategy.md +10 -0
- package/docs/configure/app/resolve/alias.md +9 -0
- package/docs/configure/app/resolve/condition-names.md +13 -0
- package/docs/configure/app/resolve/dedupe.md +9 -0
- package/docs/configure/app/resolve/extensions.md +13 -0
- package/docs/configure/app/runtime/0-intro.md +58 -0
- package/docs/configure/app/runtime/plugins.md +58 -0
- package/docs/configure/app/runtime/router.md +35 -0
- package/docs/configure/app/security/check-syntax.md +69 -0
- package/docs/configure/app/security/nonce.md +15 -0
- package/docs/configure/app/security/sri.md +20 -0
- package/docs/configure/app/server/base-url.md +26 -0
- package/docs/configure/app/server/port.md +18 -0
- package/docs/configure/app/server/public-routes.md +22 -0
- package/docs/configure/app/server/routes.md +86 -0
- package/docs/configure/app/server/rsc.md +22 -0
- package/docs/configure/app/server/ssr-by-entries.md +25 -0
- package/docs/configure/app/server/ssr.md +80 -0
- package/docs/configure/app/server/tsconfig-path.md +59 -0
- package/docs/configure/app/source/alias-strategy.md +14 -0
- package/docs/configure/app/source/alias.md +23 -0
- package/docs/configure/app/source/config-dir.md +20 -0
- package/docs/configure/app/source/decorators.md +25 -0
- package/docs/configure/app/source/define.md +16 -0
- package/docs/configure/app/source/disable-default-entries.md +28 -0
- package/docs/configure/app/source/enable-async-entry.md +54 -0
- package/docs/configure/app/source/enable-async-pre-entry.md +26 -0
- package/docs/configure/app/source/entries-dir.md +35 -0
- package/docs/configure/app/source/entries.md +179 -0
- package/docs/configure/app/source/exclude.md +10 -0
- package/docs/configure/app/source/global-vars.md +106 -0
- package/docs/configure/app/source/include.md +36 -0
- package/docs/configure/app/source/main-entry-name.md +24 -0
- package/docs/configure/app/source/pre-entry.md +10 -0
- package/docs/configure/app/source/react-compiler.md +68 -0
- package/docs/configure/app/source/transform-import.md +27 -0
- package/docs/configure/app/split-chunks.md +17 -0
- package/docs/configure/app/tools/autoprefixer.md +44 -0
- package/docs/configure/app/tools/bundler-chain.md +26 -0
- package/docs/configure/app/tools/css-extract.md +33 -0
- package/docs/configure/app/tools/css-loader.md +17 -0
- package/docs/configure/app/tools/dev-server.md +113 -0
- package/docs/configure/app/tools/html-plugin.md +41 -0
- package/docs/configure/app/tools/less.md +81 -0
- package/docs/configure/app/tools/lightningcss-loader.md +35 -0
- package/docs/configure/app/tools/minify-css.md +53 -0
- package/docs/configure/app/tools/postcss.md +34 -0
- package/docs/configure/app/tools/rspack.md +10 -0
- package/docs/configure/app/tools/sass.md +78 -0
- package/docs/configure/app/tools/style-loader.md +10 -0
- package/docs/configure/app/tools/swc.md +65 -0
- package/docs/configure/app/tools/ts-checker.md +116 -0
- package/docs/configure/app/usage.md +276 -0
- package/docs/guides/advanced-features/bff/cross-project.md +109 -0
- package/docs/guides/advanced-features/bff/data-platform.md +116 -0
- package/docs/guides/advanced-features/bff/extend-server.md +120 -0
- package/docs/guides/advanced-features/bff/frameworks.md +243 -0
- package/docs/guides/advanced-features/bff/function.md +318 -0
- package/docs/guides/advanced-features/bff/operators.md +554 -0
- package/docs/guides/advanced-features/bff/sdk.md +116 -0
- package/docs/guides/advanced-features/bff/upload.md +101 -0
- package/docs/guides/advanced-features/bff.md +18 -0
- package/docs/guides/advanced-features/build-performance.md +130 -0
- package/docs/guides/advanced-features/compatibility.md +120 -0
- package/docs/guides/advanced-features/international/advanced.md +128 -0
- package/docs/guides/advanced-features/international/api.md +267 -0
- package/docs/guides/advanced-features/international/best-practices.md +286 -0
- package/docs/guides/advanced-features/international/configuration.md +228 -0
- package/docs/guides/advanced-features/international/locale-detection.md +126 -0
- package/docs/guides/advanced-features/international/quick-start.md +128 -0
- package/docs/guides/advanced-features/international/resource-loading.md +154 -0
- package/docs/guides/advanced-features/international/routing.md +173 -0
- package/docs/guides/advanced-features/international.md +27 -0
- package/docs/guides/advanced-features/low-level.md +46 -0
- package/docs/guides/advanced-features/page-performance/code-split.md +77 -0
- package/docs/guides/advanced-features/page-performance/inline-assets.md +159 -0
- package/docs/guides/advanced-features/page-performance/optimize-bundle.md +97 -0
- package/docs/guides/advanced-features/page-performance/react-compiler.md +51 -0
- package/docs/guides/advanced-features/server-monitor/logger.md +41 -0
- package/docs/guides/advanced-features/server-monitor/metrics.md +58 -0
- package/docs/guides/advanced-features/server-monitor/monitors.md +242 -0
- package/docs/guides/advanced-features/source-build.md +164 -0
- package/docs/guides/advanced-features/web-server.md +288 -0
- package/docs/guides/basic-features/alias.md +102 -0
- package/docs/guides/basic-features/css/css-in-js.md +72 -0
- package/docs/guides/basic-features/css/css-modules.md +212 -0
- package/docs/guides/basic-features/css/css.md +27 -0
- package/docs/guides/basic-features/css/tailwindcss.md +27 -0
- package/docs/guides/basic-features/data/data-cache.md +510 -0
- package/docs/guides/basic-features/data/data-fetch.md +415 -0
- package/docs/guides/basic-features/data/data-write.md +227 -0
- package/docs/guides/basic-features/debug/mock.md +109 -0
- package/docs/guides/basic-features/debug/proxy.md +21 -0
- package/docs/guides/basic-features/debug/rsdoctor.md +47 -0
- package/docs/guides/basic-features/debug/using-storybook.md +112 -0
- package/docs/guides/basic-features/deploy.md +458 -0
- package/docs/guides/basic-features/env-vars.md +177 -0
- package/docs/guides/basic-features/html.md +255 -0
- package/docs/guides/basic-features/output-files.md +141 -0
- package/docs/guides/basic-features/render/before-render.md +108 -0
- package/docs/guides/basic-features/render/overview.md +47 -0
- package/docs/guides/basic-features/render/rsc.md +516 -0
- package/docs/guides/basic-features/render/ssg.md +228 -0
- package/docs/guides/basic-features/render/ssr-cache.md +201 -0
- package/docs/guides/basic-features/render/ssr.md +321 -0
- package/docs/guides/basic-features/render/streaming-ssr.md +264 -0
- package/docs/guides/basic-features/routes/config-routes.md +426 -0
- package/docs/guides/basic-features/routes/routes.md +524 -0
- package/docs/guides/basic-features/static-assets/json-files.md +120 -0
- package/docs/guides/basic-features/static-assets/svg-assets.md +168 -0
- package/docs/guides/basic-features/static-assets/wasm-assets.md +62 -0
- package/docs/guides/basic-features/static-assets.md +160 -0
- package/docs/guides/basic-features/testing/playwright.md +120 -0
- package/docs/guides/basic-features/testing/rstest.md +251 -0
- package/docs/guides/concept/builder.md +37 -0
- package/docs/guides/concept/entries.md +319 -0
- package/docs/guides/concept/server.md +35 -0
- package/docs/guides/get-started/ai-coding-agents.md +58 -0
- package/docs/guides/get-started/glossary.md +63 -0
- package/docs/guides/get-started/introduction.md +40 -0
- package/docs/guides/get-started/quick-start.md +269 -0
- package/docs/guides/get-started/tech-stack.md +91 -0
- package/docs/guides/get-started/ultramodern.md +440 -0
- package/docs/guides/get-started/upgrade.md +118 -0
- package/docs/guides/topic-detail/module-federation/application.md +116 -0
- package/docs/guides/topic-detail/module-federation/deploy.md +104 -0
- package/docs/guides/topic-detail/module-federation/i18n.md +670 -0
- package/docs/guides/topic-detail/module-federation/introduce.md +35 -0
- package/docs/guides/topic-detail/module-federation/ssr.md +182 -0
- package/docs/guides/topic-detail/module-federation/usage.md +219 -0
- package/docs/guides/troubleshooting/builder.md +110 -0
- package/docs/guides/troubleshooting/cli.md +35 -0
- package/docs/guides/troubleshooting/dependencies.md +119 -0
- package/docs/guides/troubleshooting/hmr.md +144 -0
- package/docs/guides/upgrade/config.md +954 -0
- package/docs/guides/upgrade/entry.md +463 -0
- package/docs/guides/upgrade/other.md +183 -0
- package/docs/guides/upgrade/overview.md +33 -0
- package/docs/guides/upgrade/tailwindcss.md +91 -0
- package/docs/guides/upgrade/web-server.md +109 -0
- package/docs/index.md +33 -0
- package/docs/llms.txt +290 -0
- package/docs/plugin/cli-plugins/api.md +573 -0
- package/docs/plugin/cli-plugins/life-cycle.md +2 -0
- package/docs/plugin/introduction.md +152 -0
- package/docs/plugin/official/cli-plugins/plugin-bff.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-ssg.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-styled-components.md +5 -0
- package/docs/plugin/official/cli-plugins.md +4 -0
- package/docs/plugin/plugin-system.md +238 -0
- package/docs/plugin/runtime-plugins/api.md +194 -0
- package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
- package/docs/plugin/server-plugins/api.md +209 -0
- package/docs/plugin/server-plugins/life-cycle.md +13 -0
- package/docs/tutorials/examples/csr-auth.md +9 -0
- package/docs/tutorials/foundations/introduction.md +16 -0
- package/package.json +63 -22
|
@@ -1,42 +1,15 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import promises from "node:fs/promises";
|
|
2
3
|
import node_path from "node:path";
|
|
3
|
-
import { parse } from "@babel/parser";
|
|
4
4
|
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, isUltramodernBuildArtifact } from "@modern-js/utils/universal";
|
|
5
5
|
import { canonicalSerializeMicroVerticalReleaseEnvelope, createMicroVerticalReleaseEnvelope, verifyMicroVerticalReleaseEnvelope } from "./index.mjs";
|
|
6
6
|
const MICROVERTICAL_RELEASE_ENVELOPE_PATH = 'release/microvertical-release-envelope.json';
|
|
7
|
+
const MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH = 'release/microvertical-release-identity-carriers.json';
|
|
8
|
+
const MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_KIND = 'ultramodern-release-identity-carriers';
|
|
9
|
+
const MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_SCHEMA_VERSION = 1;
|
|
7
10
|
const COMPILED_MODULE_PATTERN = /\.(?:c|m)?js$/u;
|
|
8
11
|
const EFFECT_BFF_WORKER_PATTERN = /^worker\/__modern_bff_effect\.(?:c|m)?js$/u;
|
|
9
12
|
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
10
|
-
const isAstNode = (value)=>isRecord(value) && 'string' == typeof value.type;
|
|
11
|
-
const visitAst = (node, visitor)=>{
|
|
12
|
-
visitor(node);
|
|
13
|
-
for (const value of Object.values(node))if (isAstNode(value)) visitAst(value, visitor);
|
|
14
|
-
else if (Array.isArray(value)) {
|
|
15
|
-
for (const item of value)if (isAstNode(item)) visitAst(item, visitor);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const compiledModuleIdentityValues = (source)=>{
|
|
19
|
-
const values = new Set();
|
|
20
|
-
const ast = parse(source, {
|
|
21
|
-
sourceType: 'unambiguous'
|
|
22
|
-
});
|
|
23
|
-
visitAst(ast.program, (node)=>{
|
|
24
|
-
if ('StringLiteral' === node.type && 'string' == typeof node.value) values.add(node.value);
|
|
25
|
-
else if ('TemplateElement' === node.type && isRecord(node.value) && 'string' == typeof node.value.cooked) values.add(node.value.cooked);
|
|
26
|
-
});
|
|
27
|
-
return values;
|
|
28
|
-
};
|
|
29
|
-
const assertEveryCompiledIdentityCarrier = async (distDirectory, logicalPaths, identity, surface)=>{
|
|
30
|
-
const compiledLogicalPaths = logicalPaths.filter((pathname)=>COMPILED_MODULE_PATTERN.test(pathname));
|
|
31
|
-
if (0 === compiledLogicalPaths.length) throw new Error(`[ultramodern-release-envelope] ${surface} has no compiled execution module carrying release identity.`);
|
|
32
|
-
for (const logicalPath of compiledLogicalPaths){
|
|
33
|
-
const source = await promises.readFile(node_path.join(distDirectory, logicalPath), {
|
|
34
|
-
encoding: 'utf8'
|
|
35
|
-
});
|
|
36
|
-
const values = compiledModuleIdentityValues(source);
|
|
37
|
-
if (!values.has(identity.buildMarker) || !values.has(identity.sourceRevision) || !values.has(identity.releaseVersion)) throw new Error(`[ultramodern-release-envelope] ${surface} execution module ${logicalPath} does not carry exact buildMarker ${identity.buildMarker}, sourceRevision ${identity.sourceRevision}, and releaseVersion ${identity.releaseVersion}.`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
13
|
const flattenStrings = (value)=>'string' == typeof value ? [
|
|
41
14
|
value
|
|
42
15
|
] : Array.isArray(value) ? value.flatMap(flattenStrings) : [];
|
|
@@ -179,6 +152,49 @@ const releaseArtifact = (logicalPath, runtime)=>({
|
|
|
179
152
|
logicalPath,
|
|
180
153
|
runtime
|
|
181
154
|
});
|
|
155
|
+
const writeReleaseIdentityCarrierMetadata = async (artifactRoot, identity, carrierPaths)=>{
|
|
156
|
+
const surfacesByPath = new Map();
|
|
157
|
+
for (const [surface, logicalPaths] of Object.entries(carrierPaths)){
|
|
158
|
+
if (0 === logicalPaths.length) throw new Error(`[ultramodern-release-envelope] ${surface} has no declared release-identity carrier artifact.`);
|
|
159
|
+
for (const logicalPath of logicalPaths){
|
|
160
|
+
const surfaces = surfacesByPath.get(logicalPath) ?? new Set();
|
|
161
|
+
surfaces.add(surface);
|
|
162
|
+
surfacesByPath.set(logicalPath, surfaces);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const carriers = await Promise.all([
|
|
166
|
+
...surfacesByPath
|
|
167
|
+
].sort(([left], [right])=>left.localeCompare(right)).map(async ([logicalPath, surfaces])=>{
|
|
168
|
+
const bytes = await promises.readFile(node_path.join(artifactRoot, logicalPath));
|
|
169
|
+
return {
|
|
170
|
+
logicalPath,
|
|
171
|
+
byteLength: bytes.byteLength,
|
|
172
|
+
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
173
|
+
surfaces: [
|
|
174
|
+
...surfaces
|
|
175
|
+
].sort((left, right)=>left.localeCompare(right))
|
|
176
|
+
};
|
|
177
|
+
}));
|
|
178
|
+
const releaseEnvelopePath = await resolveSafeReleaseEnvelopePath({
|
|
179
|
+
artifactRoot,
|
|
180
|
+
createDirectory: true
|
|
181
|
+
});
|
|
182
|
+
if (!releaseEnvelopePath) throw new Error('[ultramodern-release-envelope] could not resolve private release metadata directory.');
|
|
183
|
+
const metadataPath = node_path.join(node_path.dirname(releaseEnvelopePath), node_path.basename(MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH));
|
|
184
|
+
try {
|
|
185
|
+
const metadataStat = await promises.lstat(metadataPath);
|
|
186
|
+
if (metadataStat.isSymbolicLink() || !metadataStat.isFile()) throw new Error('[ultramodern-release-envelope] release identity carrier metadata must be a real file inside artifactRoot.');
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (!isMissingPathError(error)) throw error;
|
|
189
|
+
}
|
|
190
|
+
await promises.writeFile(metadataPath, `${JSON.stringify({
|
|
191
|
+
schemaVersion: MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_SCHEMA_VERSION,
|
|
192
|
+
kind: MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_KIND,
|
|
193
|
+
identity,
|
|
194
|
+
carriers
|
|
195
|
+
}, null, 2)}\n`);
|
|
196
|
+
return releaseArtifact(MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH, 'release-identity-metadata');
|
|
197
|
+
};
|
|
182
198
|
const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
183
199
|
const files = await collectFiles(distDirectory);
|
|
184
200
|
if ('node' === target && files.some((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath))) throw new Error('[ultramodern-release-envelope] Node target conflicts with a Cloudflare Effect API/BFF worker artifact; resolve the canonical deploy target instead of emitting a Node envelope for Cloudflare output.');
|
|
@@ -202,13 +218,7 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
202
218
|
const clientExecutionPaths = await manifestReferencedClientModules(distDirectory, files);
|
|
203
219
|
if (0 === clientExecutionPaths.length) throw new Error('[ultramodern-release-envelope] UI/client manifest references no compiled execution module.');
|
|
204
220
|
const ssrExecutionPaths = await routeReferencedSsrModules(distDirectory, files, target);
|
|
205
|
-
|
|
206
|
-
await assertEveryCompiledIdentityCarrier(distDirectory, ssrExecutionPaths, identity, 'node' === target ? 'route-referenced Node SSR' : 'route-referenced Cloudflare SSR');
|
|
207
|
-
await assertEveryCompiledIdentityCarrier(distDirectory, ssrPaths, identity, 'node' === target ? 'compiled Node SSR closure' : 'compiled Cloudflare SSR/workerd closure');
|
|
208
|
-
await assertEveryCompiledIdentityCarrier(distDirectory, 'node' === target ? nodeApiEntryPaths : apiBackendPaths, identity, 'node' === target ? 'Node API/backend' : 'Cloudflare API/backend');
|
|
209
|
-
await assertEveryCompiledIdentityCarrier(distDirectory, [
|
|
210
|
-
BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
211
|
-
], identity, 'backend Module Federation container');
|
|
221
|
+
if (0 === ssrExecutionPaths.length) throw new Error(`[ultramodern-release-envelope] route manifest references no emitted ${'node' === target ? 'Node' : 'Cloudflare'} SSR execution module.`);
|
|
212
222
|
const runtimeByPath = new Map();
|
|
213
223
|
const add = (paths, runtime)=>{
|
|
214
224
|
for (const logicalPath of paths){
|
|
@@ -244,8 +254,25 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
244
254
|
const artifacts = [
|
|
245
255
|
...runtimeByPath
|
|
246
256
|
].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)).sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath));
|
|
257
|
+
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(distDirectory, identity, {
|
|
258
|
+
apiBackend: apiBackendPaths,
|
|
259
|
+
backendFederation: [
|
|
260
|
+
BACKEND_FEDERATION_MANIFEST_FILE,
|
|
261
|
+
BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
262
|
+
],
|
|
263
|
+
ssr: [
|
|
264
|
+
...new Set([
|
|
265
|
+
...ssrExecutionPaths,
|
|
266
|
+
...ssrPaths
|
|
267
|
+
])
|
|
268
|
+
],
|
|
269
|
+
uiClient: uiClientPaths.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath))
|
|
270
|
+
});
|
|
247
271
|
return {
|
|
248
|
-
artifacts
|
|
272
|
+
artifacts: [
|
|
273
|
+
...artifacts,
|
|
274
|
+
identityCarrierMetadata
|
|
275
|
+
].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath)),
|
|
249
276
|
surfaces
|
|
250
277
|
};
|
|
251
278
|
};
|
|
@@ -367,13 +394,7 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
367
394
|
])if (0 === paths.length) throw new Error(`[ultramodern-release-envelope] final Node staging has no ${surface} artifacts.`);
|
|
368
395
|
const clientExecutionPaths = await manifestReferencedClientModules(outputDirectory, files);
|
|
369
396
|
const ssrExecutionPaths = await routeReferencedSsrModules(outputDirectory, files, 'node');
|
|
370
|
-
|
|
371
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, ssrExecutionPaths, identity, 'final route-referenced Node SSR');
|
|
372
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, ssrPaths.filter((logicalPath)=>'index.js' !== logicalPath), identity, 'final compiled Node SSR closure');
|
|
373
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, apiBackendPaths.filter((logicalPath)=>logicalPath.startsWith('api/')), identity, 'final Node API/backend');
|
|
374
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, [
|
|
375
|
-
BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
376
|
-
], identity, 'final Node backend Module Federation container');
|
|
397
|
+
if (0 === clientExecutionPaths.length || 0 === ssrExecutionPaths.length) throw new Error('[ultramodern-release-envelope] final Node manifests must reference emitted UI/client and SSR execution modules.');
|
|
377
398
|
const runtimeByPath = new Map(files.filter((logicalPath)=>!backendFederationPaths.has(logicalPath)).map((logicalPath)=>[
|
|
378
399
|
logicalPath,
|
|
379
400
|
'nodejs-deployment'
|
|
@@ -383,10 +404,27 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
383
404
|
for (const logicalPath of apiBackendPaths)runtimeByPath.set(logicalPath, 'nodejs');
|
|
384
405
|
runtimeByPath.set(BACKEND_FEDERATION_MANIFEST_FILE, 'module-federation-manifest');
|
|
385
406
|
runtimeByPath.set(BACKEND_FEDERATION_REMOTE_ENTRY_FILE, 'nodejs');
|
|
407
|
+
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(outputDirectory, identity, {
|
|
408
|
+
apiBackend: apiBackendPaths,
|
|
409
|
+
backendFederation: [
|
|
410
|
+
BACKEND_FEDERATION_MANIFEST_FILE,
|
|
411
|
+
BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
412
|
+
],
|
|
413
|
+
ssr: [
|
|
414
|
+
...new Set([
|
|
415
|
+
...ssrExecutionPaths,
|
|
416
|
+
...ssrPaths.filter((logicalPath)=>'index.js' !== logicalPath)
|
|
417
|
+
])
|
|
418
|
+
],
|
|
419
|
+
uiClient: uiClientPaths.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath))
|
|
420
|
+
});
|
|
386
421
|
return {
|
|
387
422
|
artifacts: [
|
|
388
|
-
...
|
|
389
|
-
|
|
423
|
+
...[
|
|
424
|
+
...runtimeByPath
|
|
425
|
+
].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)),
|
|
426
|
+
identityCarrierMetadata
|
|
427
|
+
].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath)),
|
|
390
428
|
surfaces: {
|
|
391
429
|
uiClient: [
|
|
392
430
|
...uiClientPaths
|
|
@@ -460,13 +498,7 @@ const createCloudflareStagedReleaseArtifactInputs = async (outputDirectory, iden
|
|
|
460
498
|
])if (!files.includes(logicalPath)) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging is missing ${logicalPath}.`);
|
|
461
499
|
const clientExecutionPaths = await manifestReferencedClientModules(outputDirectory, files, 'public/mf-manifest.json');
|
|
462
500
|
const ssrExecutionPaths = await routeReferencedSsrModules(outputDirectory, files, 'cloudflare', 'server/route.json');
|
|
463
|
-
|
|
464
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, ssrExecutionPaths, identity, 'final route-referenced Cloudflare SSR');
|
|
465
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, ssrPaths.filter((logicalPath)=>logicalPath.startsWith('worker/')), identity, 'final compiled Cloudflare SSR/workerd closure');
|
|
466
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, apiBackendPaths, identity, 'final Cloudflare API/backend');
|
|
467
|
-
await assertEveryCompiledIdentityCarrier(outputDirectory, [
|
|
468
|
-
backendContainerPath
|
|
469
|
-
], identity, 'final Cloudflare backend Module Federation container');
|
|
501
|
+
if (0 === clientExecutionPaths.length || 0 === ssrExecutionPaths.length) throw new Error('[ultramodern-release-envelope] final Cloudflare manifests must reference emitted UI/client and SSR execution modules.');
|
|
470
502
|
const runtimeByPath = new Map();
|
|
471
503
|
for (const logicalPath of files)runtimeByPath.set(logicalPath, 'cloudflare-deployment');
|
|
472
504
|
const add = (paths, runtime)=>{
|
|
@@ -481,10 +513,27 @@ const createCloudflareStagedReleaseArtifactInputs = async (outputDirectory, iden
|
|
|
481
513
|
add([
|
|
482
514
|
backendContainerPath
|
|
483
515
|
], 'commonjs-module');
|
|
516
|
+
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(outputDirectory, identity, {
|
|
517
|
+
apiBackend: apiBackendPaths,
|
|
518
|
+
backendFederation: [
|
|
519
|
+
backendManifestPath,
|
|
520
|
+
backendContainerPath
|
|
521
|
+
],
|
|
522
|
+
ssr: [
|
|
523
|
+
...new Set([
|
|
524
|
+
...ssrExecutionPaths,
|
|
525
|
+
...ssrPaths.filter((logicalPath)=>logicalPath.startsWith('worker/'))
|
|
526
|
+
])
|
|
527
|
+
],
|
|
528
|
+
uiClient: uiClientPaths.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath))
|
|
529
|
+
});
|
|
484
530
|
return {
|
|
485
531
|
artifacts: [
|
|
486
|
-
...
|
|
487
|
-
|
|
532
|
+
...[
|
|
533
|
+
...runtimeByPath
|
|
534
|
+
].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)),
|
|
535
|
+
identityCarrierMetadata
|
|
536
|
+
].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath)),
|
|
488
537
|
surfaces: {
|
|
489
538
|
uiClient: [
|
|
490
539
|
...uiClientPaths
|
|
@@ -521,4 +570,4 @@ const verifyCloudflareReleaseEnvelopeStaging = async (outputDirectory)=>readFram
|
|
|
521
570
|
expectedTarget: 'cloudflare',
|
|
522
571
|
required: true
|
|
523
572
|
});
|
|
524
|
-
export { MICROVERTICAL_RELEASE_ENVELOPE_PATH, emitCloudflareStagedReleaseEnvelope, emitFrameworkMicroVerticalReleaseEnvelope, emitNodeStagedReleaseEnvelope, readFrameworkMicroVerticalReleaseEnvelope, stageCloudflareReleaseEnvelope, verifyBuildOutputReleaseEnvelope, verifyCloudflareReleaseEnvelopeStaging, verifyNodeReleaseEnvelopeStaging };
|
|
573
|
+
export { MICROVERTICAL_RELEASE_ENVELOPE_PATH, MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH, emitCloudflareStagedReleaseEnvelope, emitFrameworkMicroVerticalReleaseEnvelope, emitNodeStagedReleaseEnvelope, readFrameworkMicroVerticalReleaseEnvelope, stageCloudflareReleaseEnvelope, verifyBuildOutputReleaseEnvelope, verifyCloudflareReleaseEnvelopeStaging, verifyNodeReleaseEnvelopeStaging };
|
|
@@ -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,
|
|
@@ -10,6 +10,8 @@ import { dirname as __rspack_dirname } from "node:path";
|
|
|
10
10
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
11
11
|
const BFF_EFFECT_WORKER_ENTRY_NAME = '__modern_bff_effect';
|
|
12
12
|
const BFF_EFFECT_WORKER_RUNTIME_QUERY = 'modern-bff-runtime';
|
|
13
|
+
const MF_SSR_DATA_FETCH_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-inject-data-fetch-function-plugin';
|
|
14
|
+
const MF_SSR_DEV_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-dev-plugin';
|
|
13
15
|
const JS_OR_TS_EXTS = [
|
|
14
16
|
'.js',
|
|
15
17
|
'.jsx',
|
|
@@ -44,6 +46,13 @@ function resolvePackageFile(packageName, filePath, paths) {
|
|
|
44
46
|
paths
|
|
45
47
|
}));
|
|
46
48
|
} catch {
|
|
49
|
+
try {
|
|
50
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`, {
|
|
51
|
+
paths
|
|
52
|
+
});
|
|
53
|
+
const packageFile = node_path.join(node_path.dirname(packageJsonPath), filePath);
|
|
54
|
+
if (node_fs.existsSync(packageFile)) return node_fs.realpathSync(packageFile);
|
|
55
|
+
} catch {}
|
|
47
56
|
const packageEntry = resolvePackageEntry(packageName, paths);
|
|
48
57
|
if (!packageEntry) return;
|
|
49
58
|
const packageRoot = findPackageRoot(packageEntry, packageName);
|
|
@@ -83,6 +92,64 @@ function getCloudflareWorkerNodeExternals() {
|
|
|
83
92
|
];
|
|
84
93
|
}));
|
|
85
94
|
}
|
|
95
|
+
const reserveWorkerChunkName = (baseName, reservedOutputNames)=>{
|
|
96
|
+
let name = baseName;
|
|
97
|
+
while(reservedOutputNames.has(normalizeWorkerOutputName(name)))name = `${name}_`;
|
|
98
|
+
return name;
|
|
99
|
+
};
|
|
100
|
+
const normalizeWorkerOutputName = (name)=>node_path.posix.normalize(name.replace(/\\/gu, '/')).toLowerCase();
|
|
101
|
+
function getCloudflareWorkerRspackConfig(workerEntryNames) {
|
|
102
|
+
const entryNames = [
|
|
103
|
+
...workerEntryNames
|
|
104
|
+
];
|
|
105
|
+
for (const entryName of entryNames){
|
|
106
|
+
const slashName = entryName.replace(/\\/gu, '/');
|
|
107
|
+
const normalizedName = node_path.posix.normalize(slashName);
|
|
108
|
+
if (entryName !== slashName || normalizedName !== slashName || '.' === normalizedName || normalizedName.startsWith('../') || node_path.posix.isAbsolute(normalizedName) || node_path.win32.isAbsolute(slashName) || /^[A-Za-z]:/u.test(slashName)) throw new Error(`Cloudflare worker entry name "${entryName}" must be a canonical relative output path without dot segments or backslashes.`);
|
|
109
|
+
}
|
|
110
|
+
const reservedNames = new Set(entryNames.map(normalizeWorkerOutputName));
|
|
111
|
+
const runtimeName = reserveWorkerChunkName('__modern_worker_runtime', reservedNames);
|
|
112
|
+
reservedNames.add(normalizeWorkerOutputName(runtimeName));
|
|
113
|
+
const sharedName = reserveWorkerChunkName('__modern_worker_shared', reservedNames);
|
|
114
|
+
return {
|
|
115
|
+
experiments: {
|
|
116
|
+
outputModule: true
|
|
117
|
+
},
|
|
118
|
+
externals: getCloudflareWorkerNodeExternals(),
|
|
119
|
+
externalsType: 'module-import',
|
|
120
|
+
module: {
|
|
121
|
+
parser: {
|
|
122
|
+
javascript: {
|
|
123
|
+
dynamicImportMode: 'eager'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
optimization: {
|
|
128
|
+
runtimeChunk: {
|
|
129
|
+
name: runtimeName
|
|
130
|
+
},
|
|
131
|
+
splitChunks: {
|
|
132
|
+
chunks: 'all',
|
|
133
|
+
minSize: 0,
|
|
134
|
+
name: sharedName
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function applyCloudflareWorkerRspackConfig(chain, workerEntryNames) {
|
|
140
|
+
const config = getCloudflareWorkerRspackConfig(workerEntryNames);
|
|
141
|
+
chain.experiments(config.experiments);
|
|
142
|
+
chain.externals(config.externals);
|
|
143
|
+
chain.externalsType(config.externalsType);
|
|
144
|
+
chain.module.parser.merge(config.module.parser);
|
|
145
|
+
chain.optimization.runtimeChunk(config.optimization.runtimeChunk);
|
|
146
|
+
chain.optimization.splitChunks(config.optimization.splitChunks);
|
|
147
|
+
}
|
|
148
|
+
function applyCloudflareWorkerMfRuntimeBoundary(chain) {
|
|
149
|
+
chain.plugins.delete('plugin-module-federation');
|
|
150
|
+
chain.resolve.alias.set(`${MF_SSR_DATA_FETCH_RUNTIME_PLUGIN}$`, getCloudflareWorkerCompatFile('cloudflare-worker-mf-ssr-runtime-plugin.mjs'));
|
|
151
|
+
chain.resolve.alias.set(`${MF_SSR_DEV_RUNTIME_PLUGIN}$`, getCloudflareWorkerCompatFile('cloudflare-worker-mf-ssr-runtime-plugin.mjs'));
|
|
152
|
+
}
|
|
86
153
|
function getEffectBffEntry(normalizedConfig, appContext) {
|
|
87
154
|
if (!normalizedConfig.bff || 'hono' === normalizedConfig.bff.runtimeFramework) return;
|
|
88
155
|
const configuredEntry = normalizedConfig.bff.effect?.entry;
|
|
@@ -241,17 +308,10 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
241
308
|
htmlPlugin: false,
|
|
242
309
|
...useCloudflareModuleWorker ? {
|
|
243
310
|
bundlerChain: (chain)=>{
|
|
244
|
-
chain.
|
|
245
|
-
experiments: {
|
|
246
|
-
outputModule: true
|
|
247
|
-
},
|
|
248
|
-
externals: getCloudflareWorkerNodeExternals(),
|
|
249
|
-
externalsType: 'module-import'
|
|
250
|
-
});
|
|
311
|
+
applyCloudflareWorkerRspackConfig(chain, Object.keys(workerEntries));
|
|
251
312
|
chain.output.module(true).library({
|
|
252
313
|
type: 'module'
|
|
253
314
|
}).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
254
|
-
chain.optimization.usedExports(false).providedExports(true).innerGraph(false).sideEffects(false);
|
|
255
315
|
for (const condition of [
|
|
256
316
|
'workerd',
|
|
257
317
|
'worker',
|
|
@@ -261,7 +321,7 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
261
321
|
'require',
|
|
262
322
|
'module'
|
|
263
323
|
])chain.resolve.conditionNames.add(condition);
|
|
264
|
-
chain
|
|
324
|
+
applyCloudflareWorkerMfRuntimeBoundary(chain);
|
|
265
325
|
if (tanstackRouterSsrServerFile) {
|
|
266
326
|
chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
|
|
267
327
|
chain.resolve.alias.set('@tanstack/router-core/ssr/server', tanstackRouterSsrServerFile);
|
|
@@ -302,4 +362,4 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
302
362
|
builderConfig: tempBuilderConfig
|
|
303
363
|
};
|
|
304
364
|
}
|
|
305
|
-
export { getBuilderEnvironments };
|
|
365
|
+
export { applyCloudflareWorkerMfRuntimeBoundary, applyCloudflareWorkerRspackConfig, getBuilderEnvironments, getCloudflareWorkerRspackConfig };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
const DEFAULT_INDEX_FILE = 'llms.txt';
|
|
5
|
+
const DEFAULT_EXCLUDED_DIRS = [
|
|
6
|
+
'zh'
|
|
7
|
+
];
|
|
8
|
+
function bundleDocs({ source, target, indexFile = DEFAULT_INDEX_FILE, excludedDirs = DEFAULT_EXCLUDED_DIRS }) {
|
|
9
|
+
if (!node_fs.existsSync(source)) {
|
|
10
|
+
console.warn(`[bundle-docs] docs build output not found: ${source}`);
|
|
11
|
+
console.warn('[bundle-docs] skipping the bundled docs — build the docs site first if you need them');
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
node_fs.rmSync(target, {
|
|
15
|
+
recursive: true,
|
|
16
|
+
force: true
|
|
17
|
+
});
|
|
18
|
+
const isBundled = (rel)=>rel === indexFile || rel.endsWith('.md') && !excludedDirs.some((dir)=>rel.startsWith(`${dir}${node_path.sep}`));
|
|
19
|
+
let count = 0;
|
|
20
|
+
for (const entry of node_fs.readdirSync(source, {
|
|
21
|
+
recursive: true,
|
|
22
|
+
withFileTypes: true
|
|
23
|
+
})){
|
|
24
|
+
if (!entry.isFile()) continue;
|
|
25
|
+
const from = node_path.join(entry.parentPath ?? entry.path, entry.name);
|
|
26
|
+
const rel = node_path.relative(source, from);
|
|
27
|
+
if (!isBundled(rel)) continue;
|
|
28
|
+
const to = node_path.join(target, rel);
|
|
29
|
+
node_fs.mkdirSync(node_path.dirname(to), {
|
|
30
|
+
recursive: true
|
|
31
|
+
});
|
|
32
|
+
node_fs.copyFileSync(from, to);
|
|
33
|
+
count++;
|
|
34
|
+
}
|
|
35
|
+
if (0 === count) throw new Error(`[bundle-docs] no files copied from ${source}`);
|
|
36
|
+
return count;
|
|
37
|
+
}
|
|
38
|
+
function parseArgs(argv) {
|
|
39
|
+
const options = {};
|
|
40
|
+
for(let i = 0; i < argv.length; i += 2){
|
|
41
|
+
const key = argv[i]?.replace(/^--/, '');
|
|
42
|
+
const value = argv[i + 1];
|
|
43
|
+
if (key && value) options[key] = value;
|
|
44
|
+
}
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
function runBundleDocsCli(pkgRoot) {
|
|
48
|
+
const args = parseArgs(process.argv.slice(2));
|
|
49
|
+
const source = args.source ? node_path.resolve(process.cwd(), args.source) : node_path.resolve(pkgRoot, '../../document/doc_build');
|
|
50
|
+
const target = args.target ? node_path.resolve(process.cwd(), args.target) : node_path.resolve(pkgRoot, 'docs');
|
|
51
|
+
try {
|
|
52
|
+
const count = bundleDocs({
|
|
53
|
+
source,
|
|
54
|
+
target,
|
|
55
|
+
indexFile: args.index
|
|
56
|
+
});
|
|
57
|
+
if (count > 0) console.log(`[bundle-docs] bundled ${count} doc files into docs`);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(error.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export { bundleDocs, runBundleDocsCli };
|
|
@@ -57,8 +57,9 @@ const build = async (api, options)=>{
|
|
|
57
57
|
logger.info('Starting production build...');
|
|
58
58
|
if (!appContext.builder) throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
59
59
|
await appContext.builder.onAfterBuild(async ()=>copyEnvFiles(appContext.appDirectory, appContext.distDirectory));
|
|
60
|
-
await appContext.builder.build({
|
|
60
|
+
const buildResult = await appContext.builder.build({
|
|
61
61
|
watch: options?.watch
|
|
62
62
|
});
|
|
63
|
+
if (!options?.watch) await buildResult?.close();
|
|
63
64
|
};
|
|
64
65
|
export { build };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { getServerPlugins } from "../utils/loadPlugins.mjs";
|
|
3
|
-
|
|
3
|
+
import { build } from "./build.mjs";
|
|
4
|
+
const deploy = async (api, options = {})=>{
|
|
4
5
|
const hooks = api.getHooks();
|
|
5
6
|
const { metaName } = api.getAppContext();
|
|
6
|
-
await getServerPlugins(api, metaName);
|
|
7
|
+
if (options.skipBuild) await getServerPlugins(api, metaName);
|
|
8
|
+
else await build(api);
|
|
7
9
|
await hooks.onBeforeDeploy.call(options);
|
|
8
10
|
await hooks.deploy.call();
|
|
9
11
|
await hooks.onAfterDeploy.call(options);
|
|
@@ -20,10 +20,6 @@ const serverCommand = (program, api)=>{
|
|
|
20
20
|
};
|
|
21
21
|
const deployCommand = (program, api)=>{
|
|
22
22
|
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
23
|
-
if (!options.skipBuild) {
|
|
24
|
-
const { build } = await import("./build.mjs");
|
|
25
|
-
await build(api);
|
|
26
|
-
}
|
|
27
23
|
const { deploy } = await import("./deploy.mjs");
|
|
28
24
|
await deploy(api, options);
|
|
29
25
|
process.exit(0);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
2
3
|
import { DEFAULT_ENTRY_NAME } from "@modern-js/utils";
|
|
3
4
|
import { getAutoInjectEnv } from "../utils/env.mjs";
|
|
4
5
|
function createDefaultConfig(appContext) {
|
|
5
6
|
const dev = {
|
|
7
|
+
mockDir: `./${AGGRED_DIR.mock}`,
|
|
6
8
|
cliShortcuts: {
|
|
7
9
|
help: false,
|
|
8
10
|
custom: (shortcuts = [])=>shortcuts.filter(({ key })=>'r' !== key && 'u' !== key && 'o' !== key)
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -87,7 +87,18 @@ const appTools = ()=>({
|
|
|
87
87
|
].some((tag)=>getArgv().includes(tag));
|
|
88
88
|
if (isSkipBuild) return;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const { command: contextCommand } = api.getAppContext();
|
|
91
|
+
const shouldClean = [
|
|
92
|
+
'dev',
|
|
93
|
+
'start',
|
|
94
|
+
'build',
|
|
95
|
+
'deploy'
|
|
96
|
+
].includes(command) || [
|
|
97
|
+
'dev',
|
|
98
|
+
'start',
|
|
99
|
+
'build'
|
|
100
|
+
].includes(contextCommand);
|
|
101
|
+
if (shouldClean) {
|
|
91
102
|
const resolvedConfig = api.getNormalizedConfig();
|
|
92
103
|
if (resolvedConfig.output.cleanDistPath) {
|
|
93
104
|
const appContext = api.getAppContext();
|
|
@@ -127,9 +138,12 @@ const appTools = ()=>({
|
|
|
127
138
|
});
|
|
128
139
|
const src = appTools;
|
|
129
140
|
export { defineConfig } from "./defineConfig.mjs";
|
|
141
|
+
export { build } from "./commands/build.mjs";
|
|
142
|
+
export { deploy } from "./commands/deploy.mjs";
|
|
130
143
|
export { dev } from "./commands/dev.mjs";
|
|
131
144
|
export { serve } from "./commands/serve.mjs";
|
|
132
145
|
export { resolveModernRsbuildConfig } from "./rsbuild.mjs";
|
|
146
|
+
export { closeServer } from "./utils/createServer.mjs";
|
|
133
147
|
export { mergeConfig } from "@modern-js/plugin/cli";
|
|
134
148
|
export default src;
|
|
135
149
|
export { appTools, generateWatchFiles, initAppContext };
|
|
@@ -24,7 +24,7 @@ const analyze = ()=>({
|
|
|
24
24
|
const resolvedConfig = api.getNormalizedConfig();
|
|
25
25
|
const hooks = api.getHooks();
|
|
26
26
|
try {
|
|
27
|
-
if (checkIsBuildCommands()) fs.emptydirSync(appContext.internalDirectory);
|
|
27
|
+
if (checkIsBuildCommands(appContext.command)) fs.emptydirSync(appContext.internalDirectory);
|
|
28
28
|
} catch {}
|
|
29
29
|
const apiOnly = await isApiOnly(appContext.appDirectory, resolvedConfig.source?.entriesDir, appContext.apiDirectory);
|
|
30
30
|
const [{ getProdEntrypoints, getProdServerRoutes }] = await Promise.all([
|
|
@@ -126,7 +126,7 @@ const analyze = ()=>({
|
|
|
126
126
|
htmlTemplates
|
|
127
127
|
};
|
|
128
128
|
api.updateAppContext(appContext);
|
|
129
|
-
if (checkIsBuildCommands()) {
|
|
129
|
+
if (checkIsBuildCommands(appContext.command)) {
|
|
130
130
|
await hooks.generateEntryCode.call({
|
|
131
131
|
entrypoints
|
|
132
132
|
});
|
|
@@ -39,7 +39,7 @@ const parseModule = async ({ source, filename })=>{
|
|
|
39
39
|
return await parse(content);
|
|
40
40
|
};
|
|
41
41
|
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
42
|
-
const checkIsBuildCommands = ()=>{
|
|
42
|
+
const checkIsBuildCommands = (contextCommand)=>{
|
|
43
43
|
const buildCommands = [
|
|
44
44
|
'dev',
|
|
45
45
|
'start',
|
|
@@ -49,7 +49,8 @@ const checkIsBuildCommands = ()=>{
|
|
|
49
49
|
'dev-worker'
|
|
50
50
|
];
|
|
51
51
|
const command = getCommand();
|
|
52
|
-
|
|
52
|
+
if (buildCommands.includes(command)) return true;
|
|
53
|
+
return 'dev' === contextCommand || 'start' === contextCommand || 'build' === contextCommand || 'deploy' === contextCommand;
|
|
53
54
|
};
|
|
54
55
|
const checkIsServeCommand = ()=>{
|
|
55
56
|
const command = getCommand();
|
|
@@ -117,7 +117,7 @@ const verifyCloudflareOutput = async (options)=>{
|
|
|
117
117
|
path: publicPath
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry);
|
|
120
|
+
if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry, manifest);
|
|
121
121
|
return {
|
|
122
122
|
ok: 0 === issues.length,
|
|
123
123
|
issues
|