@bleedingdev/modern-js-app-tools 3.8.3-ultramodern.1 → 3.8.3-ultramodern.2
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 +11 -0
- package/bin/modern.js +11 -0
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -241
- package/dist/cjs/builder/generator/index.js +0 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +37 -9
- package/dist/cjs/builder/shared/builderPlugins/index.js +6 -13
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +6 -13
- package/dist/cjs/builder/shared/lazyCompilation.js +9 -9
- package/dist/cjs/bundleDocs.js +1 -1
- package/dist/cjs/index.js +59 -60
- package/dist/cjs/plugins/analyze/getServerRoutes.js +1 -1
- package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +1 -9
- package/dist/cjs/plugins/backend-federation/codegen.js +2 -1
- package/dist/cjs/plugins/backend-federation/config.js +2 -2
- package/dist/cjs/plugins/backend-federation/emit.js +6 -4
- package/dist/cjs/plugins/deploy/index.js +4 -4
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +23 -149
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
- package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +3 -59
- package/dist/cjs/presetUltramodern.js +9 -4
- package/dist/cjs/run/index.js +9 -9
- package/dist/cjs/utils/register.js +6 -3
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -231
- package/dist/esm/builder/generator/index.mjs +1 -2
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +34 -9
- package/dist/esm/builder/shared/builderPlugins/index.mjs +0 -1
- package/dist/esm/builder/shared/bundlerPlugins/index.mjs +0 -1
- package/dist/esm/builder/shared/lazyCompilation.mjs +4 -4
- package/dist/esm/bundleDocs.mjs +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/plugins/analyze/getServerRoutes.mjs +1 -1
- package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +1 -9
- package/dist/esm/plugins/backend-federation/codegen.mjs +2 -1
- package/dist/esm/plugins/backend-federation/config.mjs +1 -1
- package/dist/esm/plugins/backend-federation/emit.mjs +5 -3
- package/dist/esm/plugins/deploy/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -133
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
- package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +3 -49
- package/dist/esm/presetUltramodern.mjs +2 -1
- package/dist/esm/run/index.mjs +9 -9
- package/dist/esm/utils/register.mjs +6 -3
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -234
- package/dist/esm-node/builder/generator/index.mjs +1 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +34 -9
- package/dist/esm-node/builder/shared/builderPlugins/index.mjs +0 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +0 -1
- package/dist/esm-node/builder/shared/lazyCompilation.mjs +4 -4
- package/dist/esm-node/bundleDocs.mjs +1 -1
- package/dist/esm-node/index.mjs +3 -3
- package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +1 -1
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +1 -9
- package/dist/esm-node/plugins/backend-federation/codegen.mjs +2 -1
- package/dist/esm-node/plugins/backend-federation/config.mjs +1 -1
- package/dist/esm-node/plugins/backend-federation/emit.mjs +5 -3
- package/dist/esm-node/plugins/deploy/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -133
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +41 -62
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +41 -63
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +35 -52
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +35 -53
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +41 -61
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +40 -61
- package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +3 -49
- package/dist/esm-node/presetUltramodern.mjs +2 -1
- package/dist/esm-node/run/index.mjs +9 -9
- package/dist/esm-node/utils/register.mjs +6 -3
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +0 -29
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +11 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -1
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +0 -1
- package/dist/types/builder/shared/lazyCompilation.d.ts +7 -7
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -1
- package/dist/types/plugins/backend-federation/codegen.d.ts +4 -1
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +1 -18
- package/dist/types/presetUltramodern.d.ts +1 -0
- package/dist/types/types/config/deploy.d.ts +2 -2
- package/docs/community/showcase.md +3 -5
- package/docs/guides/advanced-features/bff/frameworks.md +1 -1
- package/docs/guides/basic-features/deploy.md +2 -2
- package/docs/guides/get-started/quick-start.md +9 -8
- package/docs/guides/get-started/tech-stack.md +1 -1
- package/docs/guides/get-started/ultramodern.md +18 -18
- package/docs/guides/troubleshooting/cli.md +1 -1
- package/docs/llms.txt +2 -2
- package/docs/tutorials/examples/csr-auth.md +1 -1
- package/package.json +15 -27
- package/rslib.config.mts +4 -7
- package/dist/cjs/builder/shared/builderPlugins/adapterLazyCompilation.js +0 -74
- package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +0 -72
- package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +0 -127
- package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +0 -141
- package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +0 -139
- package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +0 -135
- package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +0 -150
- package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +0 -205
- package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +0 -18
- package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +0 -66
- package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +0 -208
- package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +0 -204
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +0 -108
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +0 -93
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +0 -83
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/issues.js +0 -54
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +0 -89
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +0 -151
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +0 -378
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/cjs/types/config/cloudflareDeploy.js +0 -18
- package/dist/cjs/ultramodern-release-envelope/canonical.js +0 -68
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +0 -649
- package/dist/cjs/ultramodern-release-envelope/index.js +0 -399
- package/dist/cjs/ultramodern-release-envelope/types.js +0 -51
- package/dist/cjs/ultramodern-release-identity.js +0 -110
- package/dist/esm/builder/shared/builderPlugins/adapterLazyCompilation.mjs +0 -36
- package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +0 -30
- package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +0 -64
- package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +0 -34
- package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +0 -88
- package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +0 -97
- package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +0 -102
- package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +0 -167
- package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +0 -12
- package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +0 -148
- package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +0 -150
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +0 -31
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +0 -45
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +0 -45
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +0 -10
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +0 -51
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +0 -99
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +0 -313
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm/types/config/cloudflareDeploy.mjs +0 -0
- package/dist/esm/ultramodern-release-envelope/canonical.mjs +0 -21
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +0 -573
- package/dist/esm/ultramodern-release-envelope/index.mjs +0 -335
- package/dist/esm/ultramodern-release-envelope/types.mjs +0 -7
- package/dist/esm/ultramodern-release-identity.mjs +0 -66
- package/dist/esm-node/builder/shared/builderPlugins/adapterLazyCompilation.mjs +0 -37
- package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +0 -31
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +0 -65
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +0 -35
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +0 -89
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +0 -98
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +0 -103
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +0 -168
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +0 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +0 -13
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +0 -149
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +0 -151
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +0 -32
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +0 -46
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +0 -46
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +0 -11
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +0 -52
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +0 -100
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +0 -314
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +0 -251
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -191
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -514
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -1012
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -363
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +0 -93
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm-node/types/config/cloudflareDeploy.mjs +0 -1
- package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +0 -22
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +0 -574
- package/dist/esm-node/ultramodern-release-envelope/index.mjs +0 -336
- package/dist/esm-node/ultramodern-release-envelope/types.mjs +0 -8
- package/dist/esm-node/ultramodern-release-identity.mjs +0 -67
- package/dist/types/builder/shared/builderPlugins/adapterLazyCompilation.d.ts +0 -3
- package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +0 -6
- package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +0 -15
- package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +0 -24
- package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +0 -23
- package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +0 -22
- package/dist/types/plugins/deploy/platforms/cloudflare/index.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +0 -51
- package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +0 -5
- package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +0 -6
- package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +0 -122
- package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +0 -46
- package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +0 -14
- package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +0 -34
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +0 -4
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +0 -14
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +0 -14
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +0 -20
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +0 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.d.mts +0 -4
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.d.mts +0 -5
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.d.mts +0 -48
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +0 -13
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-path.d.mts +0 -21
- package/dist/types/types/config/cloudflareDeploy.d.ts +0 -161
- package/dist/types/ultramodern-release-envelope/canonical.d.ts +0 -5
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +0 -32
- package/dist/types/ultramodern-release-envelope/index.d.ts +0 -6
- package/dist/types/ultramodern-release-envelope/types.d.ts +0 -62
- package/dist/types/ultramodern-release-identity.d.ts +0 -16
|
@@ -4,33 +4,6 @@ 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";
|
|
8
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
9
|
-
import { dirname as __rspack_dirname } from "node:path";
|
|
10
|
-
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
11
|
-
const BFF_EFFECT_WORKER_ENTRY_NAME = '__modern_bff_effect';
|
|
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';
|
|
15
|
-
const JS_OR_TS_EXTS = [
|
|
16
|
-
'.js',
|
|
17
|
-
'.jsx',
|
|
18
|
-
'.ts',
|
|
19
|
-
'.tsx',
|
|
20
|
-
'.mjs',
|
|
21
|
-
'.mts',
|
|
22
|
-
'.cjs',
|
|
23
|
-
'.cts'
|
|
24
|
-
];
|
|
25
|
-
const CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR = node_path.resolve(__rspack_import_meta_dirname__, '../../plugins/deploy/platforms/templates');
|
|
26
|
-
function findExistingFile(candidates) {
|
|
27
|
-
return candidates.find((candidate)=>node_fs.existsSync(candidate));
|
|
28
|
-
}
|
|
29
|
-
function resolveJsOrTsEntry(entryWithoutOrWithExt) {
|
|
30
|
-
const extension = node_path.extname(entryWithoutOrWithExt);
|
|
31
|
-
if (JS_OR_TS_EXTS.includes(extension)) return node_fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
|
|
32
|
-
return findExistingFile(JS_OR_TS_EXTS.map((extension)=>`${entryWithoutOrWithExt}${extension}`));
|
|
33
|
-
}
|
|
34
7
|
function resolvePackageEntry(packageName, paths) {
|
|
35
8
|
try {
|
|
36
9
|
return node_fs.realpathSync(require.resolve(packageName, {
|
|
@@ -74,94 +47,6 @@ function findPackageRoot(entryFile, packageName) {
|
|
|
74
47
|
function setAliasIfPresent(alias, name, value) {
|
|
75
48
|
if (value) alias.set(name, value);
|
|
76
49
|
}
|
|
77
|
-
function getCloudflareWorkerCompatFile(file) {
|
|
78
|
-
return node_path.join(CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR, file);
|
|
79
|
-
}
|
|
80
|
-
function getCloudflareWorkerNodeExternals() {
|
|
81
|
-
return Object.fromEntries(CLOUDFLARE_WORKER_NODE_BUILTINS.flatMap((builtin)=>{
|
|
82
|
-
const nodeBuiltin = `node:${builtin}`;
|
|
83
|
-
return [
|
|
84
|
-
[
|
|
85
|
-
builtin,
|
|
86
|
-
`module-import ${nodeBuiltin}`
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
nodeBuiltin,
|
|
90
|
-
`module-import ${nodeBuiltin}`
|
|
91
|
-
]
|
|
92
|
-
];
|
|
93
|
-
}));
|
|
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
|
-
}
|
|
153
|
-
function getEffectBffEntry(normalizedConfig, appContext) {
|
|
154
|
-
if (!normalizedConfig.bff || 'hono' === normalizedConfig.bff.runtimeFramework) return;
|
|
155
|
-
const configuredEntry = normalizedConfig.bff.effect?.entry;
|
|
156
|
-
if (configuredEntry) {
|
|
157
|
-
const entryWithoutOrWithExtension = node_path.isAbsolute(configuredEntry) ? configuredEntry : node_path.resolve(appContext.appDirectory, configuredEntry);
|
|
158
|
-
return resolveJsOrTsEntry(entryWithoutOrWithExtension);
|
|
159
|
-
}
|
|
160
|
-
return resolveJsOrTsEntry(node_path.resolve(appContext.apiDirectory, 'index'));
|
|
161
|
-
}
|
|
162
|
-
function isCloudflareWorkerDeploy(normalizedConfig) {
|
|
163
|
-
return normalizedConfig.deploy?.target === 'cloudflare' || 'cloudflare' === process.env.MODERNJS_DEPLOY;
|
|
164
|
-
}
|
|
165
50
|
function getConsumingReactRuntimeAliases(appContext) {
|
|
166
51
|
const resolvePaths = [
|
|
167
52
|
appContext.appDirectory,
|
|
@@ -215,11 +100,6 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
215
100
|
const v = entries[entry];
|
|
216
101
|
serverEntries[entry] = v.map((entry)=>entry.replace('index.jsx', 'index.server.jsx')).map((entry)=>entry.replace('bootstrap.jsx', 'bootstrap.server.jsx'));
|
|
217
102
|
}
|
|
218
|
-
const cloudflareWorkerServerEntries = {};
|
|
219
|
-
for(const entry in entries){
|
|
220
|
-
const v = entries[entry];
|
|
221
|
-
cloudflareWorkerServerEntries[entry] = v.map((entry)=>entry.replace('index.jsx', 'index.server.jsx')).map((entry)=>entry.replace('bootstrap.jsx', 'index.server.jsx'));
|
|
222
|
-
}
|
|
223
103
|
const environments = {
|
|
224
104
|
client: {
|
|
225
105
|
output: {
|
|
@@ -244,122 +124,20 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
244
124
|
}
|
|
245
125
|
};
|
|
246
126
|
const useWorkerTarget = isServiceWorker(normalizedConfig);
|
|
247
|
-
if (useWorkerTarget) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const renderRscWorkerFile = useCloudflareModuleWorker ? resolvePackageFile('@modern-js/render', 'dist/esm/rscWorker.mjs', [
|
|
259
|
-
appContext.appDirectory,
|
|
260
|
-
process.cwd()
|
|
261
|
-
]) : void 0;
|
|
262
|
-
const reactFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'index.js', [
|
|
263
|
-
appContext.appDirectory,
|
|
264
|
-
process.cwd()
|
|
265
|
-
]) : void 0;
|
|
266
|
-
const reactJsxRuntimeFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'jsx-runtime.js', [
|
|
267
|
-
appContext.appDirectory,
|
|
268
|
-
process.cwd()
|
|
269
|
-
]) : void 0;
|
|
270
|
-
const reactJsxDevRuntimeFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'jsx-dev-runtime.js', [
|
|
271
|
-
appContext.appDirectory,
|
|
272
|
-
process.cwd()
|
|
273
|
-
]) : void 0;
|
|
274
|
-
const reactDomFile = useCloudflareModuleWorker ? resolvePackageFile('react-dom', 'index.js', [
|
|
275
|
-
appContext.appDirectory,
|
|
276
|
-
process.cwd()
|
|
277
|
-
]) : void 0;
|
|
278
|
-
const reactDomServerEdgeFile = useCloudflareModuleWorker ? resolvePackageFile('react-dom', 'server.edge.js', [
|
|
279
|
-
appContext.appDirectory,
|
|
280
|
-
process.cwd()
|
|
281
|
-
]) : void 0;
|
|
282
|
-
const loadableComponentFile = useCloudflareModuleWorker ? resolvePackageFile('@loadable/component', 'dist/esm/loadable.esm.mjs', [
|
|
283
|
-
appContext.appDirectory,
|
|
284
|
-
process.cwd(),
|
|
285
|
-
CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR
|
|
286
|
-
]) : void 0;
|
|
287
|
-
const loadableServerWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-loadable-server.mjs') : void 0;
|
|
288
|
-
const fsPromisesWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-fs-promises.mjs') : void 0;
|
|
289
|
-
const pathWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-path.mjs') : void 0;
|
|
290
|
-
const baseWorkerEntries = useCloudflareModuleWorker ? cloudflareWorkerServerEntries : serverEntries;
|
|
291
|
-
const workerEntries = effectApiEntry ? {
|
|
292
|
-
...baseWorkerEntries,
|
|
293
|
-
[BFF_EFFECT_WORKER_ENTRY_NAME]: [
|
|
294
|
-
`${effectApiEntry}?${BFF_EFFECT_WORKER_RUNTIME_QUERY}`
|
|
295
|
-
]
|
|
296
|
-
} : baseWorkerEntries;
|
|
297
|
-
environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
298
|
-
output: {
|
|
299
|
-
target: useCloudflareModuleWorker ? 'web' : 'web-worker',
|
|
300
|
-
...useCloudflareModuleWorker ? {
|
|
301
|
-
module: true
|
|
302
|
-
} : {}
|
|
303
|
-
},
|
|
304
|
-
source: {
|
|
305
|
-
entry: workerEntries
|
|
306
|
-
},
|
|
307
|
-
tools: {
|
|
308
|
-
htmlPlugin: false,
|
|
309
|
-
...useCloudflareModuleWorker ? {
|
|
310
|
-
bundlerChain: (chain)=>{
|
|
311
|
-
applyCloudflareWorkerRspackConfig(chain, Object.keys(workerEntries));
|
|
312
|
-
chain.output.module(true).library({
|
|
313
|
-
type: 'module'
|
|
314
|
-
}).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
315
|
-
for (const condition of [
|
|
316
|
-
'workerd',
|
|
317
|
-
'worker',
|
|
318
|
-
'webpack',
|
|
319
|
-
isProd() ? 'production' : 'development',
|
|
320
|
-
'import',
|
|
321
|
-
'require',
|
|
322
|
-
'module'
|
|
323
|
-
])chain.resolve.conditionNames.add(condition);
|
|
324
|
-
applyCloudflareWorkerMfRuntimeBoundary(chain);
|
|
325
|
-
if (tanstackRouterSsrServerFile) {
|
|
326
|
-
chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
|
|
327
|
-
chain.resolve.alias.set('@tanstack/router-core/ssr/server', tanstackRouterSsrServerFile);
|
|
328
|
-
}
|
|
329
|
-
if (runtimeRscWorkerFile) {
|
|
330
|
-
chain.resolve.alias.set('@modern-js/runtime/rsc/server$', runtimeRscWorkerFile);
|
|
331
|
-
chain.resolve.alias.set('@modern-js/runtime/rsc/server', runtimeRscWorkerFile);
|
|
332
|
-
}
|
|
333
|
-
if (renderRscWorkerFile) {
|
|
334
|
-
chain.resolve.alias.set('@modern-js/render/rsc$', renderRscWorkerFile);
|
|
335
|
-
chain.resolve.alias.set('@modern-js/render/rsc', renderRscWorkerFile);
|
|
336
|
-
chain.resolve.alias.set('@modern-js/render/rsc-worker$', renderRscWorkerFile);
|
|
337
|
-
}
|
|
338
|
-
setAliasIfPresent(chain.resolve.alias, 'react$', reactFile);
|
|
339
|
-
setAliasIfPresent(chain.resolve.alias, 'react/jsx-runtime$', reactJsxRuntimeFile);
|
|
340
|
-
setAliasIfPresent(chain.resolve.alias, 'react/jsx-dev-runtime$', reactJsxDevRuntimeFile);
|
|
341
|
-
setAliasIfPresent(chain.resolve.alias, 'react-dom$', reactDomFile);
|
|
342
|
-
setAliasIfPresent(chain.resolve.alias, 'react-dom/server.edge$', reactDomServerEdgeFile);
|
|
343
|
-
setAliasIfPresent(chain.resolve.alias, '@loadable/component$', loadableComponentFile);
|
|
344
|
-
setAliasIfPresent(chain.resolve.alias, '@loadable/server$', loadableServerWorkerFile);
|
|
345
|
-
setAliasIfPresent(chain.resolve.alias, 'fs/promises$', fsPromisesWorkerFile);
|
|
346
|
-
setAliasIfPresent(chain.resolve.alias, 'node:fs/promises$', fsPromisesWorkerFile);
|
|
347
|
-
setAliasIfPresent(chain.resolve.alias, 'path$', pathWorkerFile);
|
|
348
|
-
setAliasIfPresent(chain.resolve.alias, 'node:path$', pathWorkerFile);
|
|
349
|
-
chain.resolve.alias.set('react-server-dom-rspack/server.node$', 'react-server-dom-rspack/server.edge');
|
|
350
|
-
chain.resolve.alias.set('react-server-dom-rspack/server.node', 'react-server-dom-rspack/server.edge');
|
|
351
|
-
chain.resolve.alias.set('react-server-dom-rspack/client.node$', 'react-server-dom-rspack/client.edge');
|
|
352
|
-
chain.resolve.alias.set('react-server-dom-rspack/client.node', 'react-server-dom-rspack/client.edge');
|
|
353
|
-
chain.resolve.fallback.set('fs', false);
|
|
354
|
-
chain.resolve.fallback.set('node:fs', false);
|
|
355
|
-
}
|
|
356
|
-
} : {}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}
|
|
127
|
+
if (useWorkerTarget) environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
128
|
+
output: {
|
|
129
|
+
target: 'web-worker'
|
|
130
|
+
},
|
|
131
|
+
source: {
|
|
132
|
+
entry: serverEntries
|
|
133
|
+
},
|
|
134
|
+
tools: {
|
|
135
|
+
htmlPlugin: false
|
|
136
|
+
}
|
|
137
|
+
};
|
|
360
138
|
return {
|
|
361
139
|
environments,
|
|
362
140
|
builderConfig: tempBuilderConfig
|
|
363
141
|
};
|
|
364
142
|
}
|
|
365
|
-
export {
|
|
143
|
+
export { getBuilderEnvironments };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { createBuilder } from "@modern-js/builder";
|
|
3
3
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
4
|
-
import { builderPluginAdapterBasic, builderPluginAdapterHooks, builderPluginAdapterHtml,
|
|
4
|
+
import { builderPluginAdapterBasic, builderPluginAdapterHooks, builderPluginAdapterHtml, builderPluginAdapterPrecompress, builderPluginAdapterSSR } from "../shared/builderPlugins/index.mjs";
|
|
5
5
|
import { builderPluginAdapterCopy } from "./adapterCopy.mjs";
|
|
6
6
|
import { createBuilderProviderConfig } from "./createBuilderProviderConfig.mjs";
|
|
7
7
|
import { getBuilderEnvironments } from "./getBuilderEnvironments.mjs";
|
|
@@ -39,7 +39,6 @@ async function generateBuilder(options, bundlerType) {
|
|
|
39
39
|
async function applyBuilderPlugins(builder, options) {
|
|
40
40
|
builder.addPlugins([
|
|
41
41
|
builderPluginAdapterBasic(options),
|
|
42
|
-
builderPluginAdapterLazyCompilation(options),
|
|
43
42
|
builderPluginAdapterSSR(options),
|
|
44
43
|
builderPluginAdapterHtml(options),
|
|
45
44
|
builderPluginAdapterPrecompress(options),
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import __rslib_shim_module__ from "node:module";
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { CssExtractRuntimePlugin } from "@modern-js/app-tools-extensions";
|
|
3
4
|
import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/builder";
|
|
4
|
-
import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
|
|
5
|
+
import { fs, isUseRsc, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
5
6
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
6
7
|
import { getServerCombinedModuleFile } from "../../../plugins/analyze/utils.mjs";
|
|
7
|
-
import {
|
|
8
|
+
import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
|
|
9
|
+
import { aggregateEagerRouteComponentFiles, planSSRLazyCompilation } from "../lazyCompilation.mjs";
|
|
8
10
|
import * as __rspack_external_path from "path";
|
|
9
11
|
const builderPluginAdapterSSR = (options)=>({
|
|
10
12
|
name: 'builder-plugin-adapter-modern-ssr',
|
|
11
13
|
setup (api) {
|
|
12
|
-
const { normalizedConfig, appContext } = options;
|
|
13
|
-
api.modifyRsbuildConfig((config)=>
|
|
14
|
+
const { normalizedConfig, appContext, eagerRouteComponentFilesByEntry } = options;
|
|
15
|
+
api.modifyRsbuildConfig((config)=>{
|
|
16
|
+
const merged = mergeRsbuildConfig(config, {
|
|
14
17
|
html: {
|
|
15
18
|
inject: isStreamingSSR(normalizedConfig) ? 'head' : void 0
|
|
16
19
|
},
|
|
17
20
|
server: {
|
|
18
21
|
compress: isStreamingSSR(normalizedConfig) || isUseRsc(normalizedConfig) ? false : void 0
|
|
19
22
|
}
|
|
20
|
-
})
|
|
23
|
+
});
|
|
24
|
+
const lazyCompilation = getSSRLazyCompilation(merged.dev?.lazyCompilation, normalizedConfig, appContext, eagerRouteComponentFilesByEntry);
|
|
25
|
+
if (void 0 !== lazyCompilation) merged.dev = {
|
|
26
|
+
...merged.dev,
|
|
27
|
+
lazyCompilation
|
|
28
|
+
};
|
|
29
|
+
return merged;
|
|
30
|
+
});
|
|
21
31
|
api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer, environment })=>{
|
|
22
32
|
const builderConfig = environment.config;
|
|
23
33
|
const { normalizedConfig } = options;
|
|
@@ -53,6 +63,22 @@ const isStreamingSSR = (userConfig)=>{
|
|
|
53
63
|
}
|
|
54
64
|
return false;
|
|
55
65
|
};
|
|
66
|
+
function getSSRLazyCompilation(current, normalizedConfig, appContext, eagerRouteComponentFilesByEntry) {
|
|
67
|
+
if (!current || isUseRsc(normalizedConfig) || !isStreamingSSR(normalizedConfig)) return;
|
|
68
|
+
const plan = planSSRLazyCompilation(current, aggregateEagerRouteComponentFiles(eagerRouteComponentFilesByEntry));
|
|
69
|
+
if (!plan.apply) {
|
|
70
|
+
if (plan.unresolvedByEntry) warnUnresolvedRouteComponents(appContext.appDirectory, plan.unresolvedByEntry);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return plan.lazyCompilation;
|
|
74
|
+
}
|
|
75
|
+
const warnedLazyApps = new Set();
|
|
76
|
+
function warnUnresolvedRouteComponents(appDirectory, unresolvedByEntry) {
|
|
77
|
+
if (warnedLazyApps.has(appDirectory)) return;
|
|
78
|
+
warnedLazyApps.add(appDirectory);
|
|
79
|
+
const detail = Array.from(unresolvedByEntry).map(([entry, comps])=>`${entry}: ${comps.join(', ')}`).join('; ');
|
|
80
|
+
logger.warn(`[lazyCompilation] Skipped stream SSR route-eager optimization because some route components could not be resolved to a file (${detail}). Lazy compilation may break first-screen CSS/JS for these routes.`);
|
|
81
|
+
}
|
|
56
82
|
function applyAsyncChunkHtmlPlugin({ chain, modernConfig, HtmlBundlerPlugin }) {
|
|
57
83
|
if (isStreamingSSR(modernConfig) || isUseRsc(modernConfig)) chain.plugin('html-async-chunk').use(HtmlAsyncChunkPlugin, [
|
|
58
84
|
HtmlBundlerPlugin
|
|
@@ -100,10 +126,9 @@ function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
|
|
|
100
126
|
});
|
|
101
127
|
}
|
|
102
128
|
async function applySSRLoaderEntry(chain, optinos, isServer) {
|
|
103
|
-
const { appContext
|
|
129
|
+
const { appContext } = optinos;
|
|
104
130
|
const { internalDirectory } = appContext;
|
|
105
131
|
const { entrypoints } = appContext;
|
|
106
|
-
const isRsc = isUseRsc(normalizedConfig);
|
|
107
132
|
await Promise.all(entrypoints.map(async (entrypoint)=>{
|
|
108
133
|
const { entryName } = entrypoint;
|
|
109
134
|
const serverLoadersFile = getServerCombinedModuleFile(internalDirectory, entryName);
|
|
@@ -111,7 +136,7 @@ async function applySSRLoaderEntry(chain, optinos, isServer) {
|
|
|
111
136
|
await fs.access(serverLoadersFile, fs.constants.F_OK);
|
|
112
137
|
chain.entry(`${entryName}-server-loaders`).add(serverLoadersFile);
|
|
113
138
|
} catch (err) {}
|
|
114
|
-
else if (
|
|
139
|
+
else if (isUseRsc(optinos.normalizedConfig)) chain.entry(`${entryName}-server-loaders`).add("data:text/javascript,export%20{};");
|
|
115
140
|
}));
|
|
116
141
|
}
|
|
117
142
|
function applySSRDataLoader(chain, options) {
|
|
@@ -122,4 +147,4 @@ function applySSRDataLoader(chain, options) {
|
|
|
122
147
|
const reg = new RegExp(`${absolutePath}.*\\.(loader|data|data.client)\\.[t|j]sx?$`);
|
|
123
148
|
chain.module.rule('ssr-data-loader').test(reg).use('data-loader').loader(require.resolve('@modern-js/plugin-data-loader/loader')).end();
|
|
124
149
|
}
|
|
125
|
-
export { builderPluginAdapterSSR };
|
|
150
|
+
export { builderPluginAdapterSSR, getSSRLazyCompilation };
|
|
@@ -12,7 +12,7 @@ function aggregateEagerRouteComponentFiles(byEntry) {
|
|
|
12
12
|
unresolvedByEntry
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function buildSSRLazyCompilationTest(eagerRouteFiles, userTest) {
|
|
16
16
|
const userTestFn = 'function' == typeof userTest ? userTest : userTest instanceof RegExp ? (m)=>userTest.test(m.resource || '') : ()=>true;
|
|
17
17
|
return (m)=>{
|
|
18
18
|
const resource = m.resource;
|
|
@@ -21,7 +21,7 @@ function buildRouteEagerLazyCompilationTest(eagerRouteFiles, userTest) {
|
|
|
21
21
|
return userTestFn(m);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function planSSRLazyCompilation(current, info) {
|
|
25
25
|
if (!current) return {
|
|
26
26
|
apply: false
|
|
27
27
|
};
|
|
@@ -38,8 +38,8 @@ function planRouteEagerLazyCompilation(current, info) {
|
|
|
38
38
|
apply: true,
|
|
39
39
|
lazyCompilation: {
|
|
40
40
|
...base,
|
|
41
|
-
test:
|
|
41
|
+
test: buildSSRLazyCompilationTest(info.files, userTest)
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
export { aggregateEagerRouteComponentFiles,
|
|
45
|
+
export { aggregateEagerRouteComponentFiles, buildSSRLazyCompilationTest, collectRouteComponentFiles, normalizeModulePath, planSSRLazyCompilation };
|
|
@@ -22,7 +22,7 @@ function bundleDocs({ source, target, indexFile = DEFAULT_INDEX_FILE, excludedDi
|
|
|
22
22
|
withFileTypes: true
|
|
23
23
|
})){
|
|
24
24
|
if (!entry.isFile()) continue;
|
|
25
|
-
const from = node_path.join(entry.parentPath
|
|
25
|
+
const from = node_path.join(entry.parentPath, entry.name);
|
|
26
26
|
const rel = node_path.relative(source, from);
|
|
27
27
|
if (!isBundled(rel)) continue;
|
|
28
28
|
const to = node_path.join(target, rel);
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import __rslib_shim_module__ from "node:module";
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { createCloudflareBuilderPlugin } from "@modern-js/app-tools-extensions/cloudflare-builder";
|
|
3
4
|
import { castArray } from "@modern-js/builder";
|
|
4
5
|
import { getLocaleLanguage } from "@modern-js/i18n-utils/language-detector";
|
|
5
6
|
import { createAsyncHook } from "@modern-js/plugin";
|
|
@@ -15,7 +16,6 @@ import deploy from "./plugins/deploy/index.mjs";
|
|
|
15
16
|
import initialize from "./plugins/initialize/index.mjs";
|
|
16
17
|
import serverBuild from "./plugins/serverBuild.mjs";
|
|
17
18
|
import serverRuntime from "./plugins/serverRuntime.mjs";
|
|
18
|
-
import ultramodernReleaseEnvelope from "./plugins/ultramodernReleaseEnvelope.mjs";
|
|
19
19
|
import { generateWatchFiles } from "./utils/generateWatchFiles.mjs";
|
|
20
20
|
import { initAppContext } from "./utils/initAppContext.mjs";
|
|
21
21
|
import { restart } from "./utils/restart.mjs";
|
|
@@ -31,8 +31,8 @@ const appTools = ()=>({
|
|
|
31
31
|
analyze(),
|
|
32
32
|
serverBuild(),
|
|
33
33
|
backendFederationBuild(),
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
deploy(),
|
|
35
|
+
createCloudflareBuilderPlugin()
|
|
36
36
|
],
|
|
37
37
|
post: [
|
|
38
38
|
'@modern-js/plugin-initialize',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, fs, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
|
|
2
|
+
import { MAIN_ENTRY_NAME, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_WORKER_BUNDLE_DIRECTORY, fs, getEntryOptions, isPlainObject, removeLeadingSlash, removeTailSlash, urlJoin } from "@modern-js/utils";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { isMainEntry } from "../../utils/routes.mjs";
|
|
5
5
|
import { walkDirectory } from "./utils.mjs";
|
|
@@ -11,23 +11,15 @@ const isDefaultExportFunction = (file)=>{
|
|
|
11
11
|
plugins: [
|
|
12
12
|
'jsx',
|
|
13
13
|
"typescript",
|
|
14
|
-
'classProperties',
|
|
15
|
-
'dynamicImport',
|
|
16
14
|
'exportDefaultFrom',
|
|
17
|
-
'exportNamespaceFrom',
|
|
18
15
|
'decorators-legacy',
|
|
19
16
|
'functionBind',
|
|
20
|
-
'classPrivateMethods',
|
|
21
17
|
[
|
|
22
18
|
'pipelineOperator',
|
|
23
19
|
{
|
|
24
20
|
proposal: 'fsharp'
|
|
25
21
|
}
|
|
26
|
-
]
|
|
27
|
-
'optionalChaining',
|
|
28
|
-
'optionalCatchBinding',
|
|
29
|
-
'objectRestSpread',
|
|
30
|
-
'numericSeparator'
|
|
22
|
+
]
|
|
31
23
|
]
|
|
32
24
|
});
|
|
33
25
|
let isExportFunction = false;
|
|
@@ -99,7 +99,7 @@ module.exports = { __modernjsBackendFederation, get, init };
|
|
|
99
99
|
if (!output) throw new Error('[backend-federation-build] CommonJS backend federation container emitted no output.');
|
|
100
100
|
return output.text;
|
|
101
101
|
};
|
|
102
|
-
const createBackendManifest = (workspaceRoot, distDirectory, app)=>{
|
|
102
|
+
const createBackendManifest = (workspaceRoot, distDirectory, app, entryIntegrity)=>{
|
|
103
103
|
const sourceModule = `${app.directory}/api/effect-api.ts`;
|
|
104
104
|
const publicPath = createPublicPath(app.containerEntry, app.port);
|
|
105
105
|
const manifest = {
|
|
@@ -130,6 +130,7 @@ const createBackendManifest = (workspaceRoot, distDirectory, app)=>{
|
|
|
130
130
|
ssrPublicPath: publicPath
|
|
131
131
|
},
|
|
132
132
|
entry: {
|
|
133
|
+
...entryIntegrity,
|
|
133
134
|
file: BACKEND_FEDERATION_REMOTE_ENTRY_FILE,
|
|
134
135
|
path: normalizeRelativePath(node_path.relative(workspaceRoot, node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE))),
|
|
135
136
|
type: app.remoteType,
|
|
@@ -2,8 +2,8 @@ import "node:module";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import promises from "node:fs/promises";
|
|
4
4
|
import node_path from "node:path";
|
|
5
|
+
import { resolveUltramodernSourceRevision } from "@modern-js/app-tools-extensions/release-identity";
|
|
5
6
|
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, DELIVERY_UNIT_DEPLOY_PROFILE, DELIVERY_UNIT_KIND, DELIVERY_UNIT_SCHEMA_VERSION, ULTRAMODERN_BUILD_ARTIFACT_FILE, ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_PATH, deliveryUnitContractBlock, isUltramodernBuildArtifact, validateDeliveryUnitRecord, validateUltramodernBuildArtifact } from "@modern-js/utils/universal";
|
|
6
|
-
import { resolveUltramodernSourceRevision } from "../../ultramodern-release-identity.mjs";
|
|
7
7
|
const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
|
|
8
8
|
const normalizeRelativePath = (value)=>value.replace(/\\/gu, '/').replace(/^\.\/+/u, '');
|
|
9
9
|
const isRecord = (value)=>'object' == typeof value && null !== value;
|
|
@@ -2,8 +2,9 @@ import "node:module";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import promises from "node:fs/promises";
|
|
4
4
|
import node_path from "node:path";
|
|
5
|
+
import { resolveUltramodernReleaseIdentity } from "@modern-js/app-tools-extensions/release-identity";
|
|
6
|
+
import { createBackendFederationEntryIntegrity } from "@modern-js/server-runtime-extensions/backend-federation-security/node";
|
|
5
7
|
import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, stampUltramodernBuildArtifactIdentity } from "@modern-js/utils/universal";
|
|
6
|
-
import { resolveUltramodernReleaseIdentity } from "../../ultramodern-release-identity.mjs";
|
|
7
8
|
import { createBackendManifest, createBackendRemoteEntrySource } from "./codegen.mjs";
|
|
8
9
|
import { COMPACT_CONFIG_PATH, buildArtifactPathFor, buildModulePathFor, createStampedDeliveryUnit, findBackendFederationApp, findWorkspaceRoot, readBuildIdentity, resolveWorkspaceSourceRevision } from "./config.mjs";
|
|
9
10
|
const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
@@ -68,11 +69,12 @@ const emitBackendFederationArtifacts = async (appDirectory, distDirectory)=>{
|
|
|
68
69
|
const manifestPath = node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE);
|
|
69
70
|
const entryPath = node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
|
|
70
71
|
const deliveryUnitArtifactPath = stampedBuildArtifact ? node_path.join(distDirectory, ULTRAMODERN_BUILD_ARTIFACT_FILE) : void 0;
|
|
72
|
+
const entrySource = await createBackendRemoteEntrySource(workspaceRoot, resolvedApp, effectApiPath, entryPath);
|
|
71
73
|
await promises.mkdir(distDirectory, {
|
|
72
74
|
recursive: true
|
|
73
75
|
});
|
|
74
|
-
await promises.writeFile(entryPath,
|
|
75
|
-
await promises.writeFile(manifestPath, `${JSON.stringify(createBackendManifest(workspaceRoot, distDirectory, resolvedApp), null, 2)}\n`);
|
|
76
|
+
await promises.writeFile(entryPath, entrySource);
|
|
77
|
+
await promises.writeFile(manifestPath, `${JSON.stringify(createBackendManifest(workspaceRoot, distDirectory, resolvedApp, createBackendFederationEntryIntegrity(entrySource)), null, 2)}\n`);
|
|
76
78
|
if (stampedBuildArtifact && deliveryUnitArtifactPath) await promises.writeFile(deliveryUnitArtifactPath, `${JSON.stringify(stampedBuildArtifact, null, 2)}\n`);
|
|
77
79
|
return {
|
|
78
80
|
appId: resolvedApp.id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { createCloudflarePreset } from "@modern-js/app-tools-extensions/cloudflare";
|
|
2
3
|
import { provider } from "std-env";
|
|
3
|
-
import { createCloudflarePreset } from "./platforms/cloudflare/index.mjs";
|
|
4
4
|
import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
|
|
5
5
|
import { createNetlifyPreset } from "./platforms/netlify.mjs";
|
|
6
6
|
import { createNodePreset } from "./platforms/node.mjs";
|