@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
package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
async function loadWorkerModule(workerPath) {
|
|
2
|
-
const loader = WORKER_MODULE_LOADERS[workerPath];
|
|
3
|
-
|
|
4
|
-
if (!loader) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (!workerModulePromises.has(workerPath)) {
|
|
9
|
-
workerModulePromises.set(workerPath, loader());
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return workerModulePromises.get(workerPath);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getRuntimeModule(workerModule) {
|
|
16
|
-
const defaultExport = workerModule.default;
|
|
17
|
-
const nestedDefaultExport =
|
|
18
|
-
defaultExport && typeof defaultExport === 'object'
|
|
19
|
-
? defaultExport.default
|
|
20
|
-
: undefined;
|
|
21
|
-
|
|
22
|
-
return defaultExport && typeof defaultExport === 'object'
|
|
23
|
-
? {
|
|
24
|
-
...workerModule,
|
|
25
|
-
...defaultExport,
|
|
26
|
-
...(nestedDefaultExport && typeof nestedDefaultExport === 'object'
|
|
27
|
-
? nestedDefaultExport
|
|
28
|
-
: {}),
|
|
29
|
-
}
|
|
30
|
-
: workerModule;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getFetchHandler(workerModule) {
|
|
34
|
-
const defaultExport = workerModule.default;
|
|
35
|
-
const runtime = getRuntimeModule(workerModule);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
(typeof runtime.fetch === 'function' && runtime.fetch.bind(runtime)) ||
|
|
39
|
-
(typeof defaultExport === 'function' &&
|
|
40
|
-
defaultExport.fetch?.bind?.(defaultExport))
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function getRequestHandler(workerModule) {
|
|
45
|
-
const defaultExport = workerModule.default;
|
|
46
|
-
const runtime = getRuntimeModule(workerModule);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
(await workerModule.requestHandler) ||
|
|
50
|
-
(await runtime.requestHandler) ||
|
|
51
|
-
(typeof defaultExport === 'function' ? defaultExport : undefined)
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function dispatchRouteWorker(route, request, env, ctx) {
|
|
56
|
-
const workerPath = route.worker;
|
|
57
|
-
if (!workerPath) {
|
|
58
|
-
return new Response('Worker bundle not configured for SSR route', {
|
|
59
|
-
status: 500,
|
|
60
|
-
headers: {
|
|
61
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const workerModule = await loadWorkerModule(workerPath);
|
|
67
|
-
|
|
68
|
-
if (!workerModule) {
|
|
69
|
-
return new Response(`Worker bundle not found: ${workerPath}`, {
|
|
70
|
-
status: 500,
|
|
71
|
-
headers: {
|
|
72
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
73
|
-
'x-modern-js-route-worker': workerPath,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const fetchHandler = getFetchHandler(workerModule);
|
|
79
|
-
|
|
80
|
-
if (fetchHandler) {
|
|
81
|
-
return fetchHandler(request, env, ctx);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const requestHandler = await getRequestHandler(workerModule);
|
|
85
|
-
|
|
86
|
-
if (typeof requestHandler === 'function') {
|
|
87
|
-
const requestHandlerOptions = await getRequestHandlerOptions(
|
|
88
|
-
route,
|
|
89
|
-
request,
|
|
90
|
-
env,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
return withRouteCssLinks(
|
|
94
|
-
await requestHandler(request, requestHandlerOptions),
|
|
95
|
-
route,
|
|
96
|
-
requestHandlerOptions.resource.routeManifest,
|
|
97
|
-
request,
|
|
98
|
-
env,
|
|
99
|
-
requestHandlerOptions.locals[
|
|
100
|
-
DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY
|
|
101
|
-
]?.getStylesheetHrefs(),
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return new Response(
|
|
106
|
-
`Worker bundle has no fetch or requestHandler export: ${workerPath}`,
|
|
107
|
-
{
|
|
108
|
-
status: 500,
|
|
109
|
-
headers: {
|
|
110
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
111
|
-
'x-modern-js-route-worker': workerPath,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function matchesPrefix(pathname, prefix) {
|
|
118
|
-
if (!prefix || prefix === '/') {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const normalized = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
123
|
-
|
|
124
|
-
return pathname === normalized || pathname.startsWith(`${normalized}/`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function createRequestForMountedPrefix(request, prefix) {
|
|
128
|
-
if (!prefix || prefix === '/') {
|
|
129
|
-
return request;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const url = new URL(request.url);
|
|
133
|
-
const normalized = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
134
|
-
|
|
135
|
-
if (!matchesPrefix(url.pathname, normalized)) {
|
|
136
|
-
return request;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const nextPath = url.pathname.slice(normalized.length) || '/';
|
|
140
|
-
url.pathname = nextPath.startsWith('/') ? nextPath : `/${nextPath}`;
|
|
141
|
-
|
|
142
|
-
return new Request(url, request);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function createEffectBffDispatcherErrorResponse(bff, error) {
|
|
146
|
-
return new Response(
|
|
147
|
-
`Effect BFF dispatcher initialization failed: ${
|
|
148
|
-
error instanceof Error ? error.message : String(error)
|
|
149
|
-
}`,
|
|
150
|
-
{
|
|
151
|
-
status: 500,
|
|
152
|
-
headers: {
|
|
153
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
154
|
-
'x-modern-js-bff-dispatcher': String(bff.dispatcherExport || ''),
|
|
155
|
-
'x-modern-js-bff-worker': bff.worker,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function getEffectBffDispatcher(bff, runtime) {
|
|
162
|
-
let effectDispatcherPromise = effectBffDispatcherPromises.get(bff.worker);
|
|
163
|
-
|
|
164
|
-
if (effectDispatcherPromise) {
|
|
165
|
-
return effectDispatcherPromise;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
effectDispatcherPromise = Promise.resolve().then(async () => {
|
|
169
|
-
if (
|
|
170
|
-
typeof bff.dispatcherExport !== 'string' ||
|
|
171
|
-
bff.dispatcherExport.length === 0
|
|
172
|
-
) {
|
|
173
|
-
throw new Error('manifest does not declare dispatcherExport');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const effectDispatcherFactory = runtime[bff.dispatcherExport];
|
|
177
|
-
|
|
178
|
-
if (typeof effectDispatcherFactory !== 'function') {
|
|
179
|
-
throw new Error(`worker bundle does not export ${bff.dispatcherExport}`);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const effectDispatcher = await effectDispatcherFactory({
|
|
183
|
-
prefix: bff.prefix,
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
if (!effectDispatcher || typeof effectDispatcher.dispatch !== 'function') {
|
|
187
|
-
try {
|
|
188
|
-
await effectDispatcher?.dispose?.();
|
|
189
|
-
} catch {}
|
|
190
|
-
|
|
191
|
-
throw new Error(
|
|
192
|
-
`worker export ${bff.dispatcherExport} did not return a dispatcher with a dispatch function`,
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return effectDispatcher;
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
effectBffDispatcherPromises.set(bff.worker, effectDispatcherPromise);
|
|
200
|
-
effectDispatcherPromise.catch(() => {
|
|
201
|
-
if (
|
|
202
|
-
effectBffDispatcherPromises.get(bff.worker) === effectDispatcherPromise
|
|
203
|
-
) {
|
|
204
|
-
effectBffDispatcherPromises.delete(bff.worker);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
return effectDispatcherPromise;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async function dispatchBffRequest(request, env) {
|
|
212
|
-
const bff = MODERN_WORKER_MANIFEST.bff;
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
!bff?.worker ||
|
|
216
|
-
!matchesPrefix(new URL(request.url).pathname, bff.prefix)
|
|
217
|
-
) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const workerModule = await loadWorkerModule(bff.worker);
|
|
222
|
-
|
|
223
|
-
if (!workerModule) {
|
|
224
|
-
return new Response(`BFF worker bundle not found: ${bff.worker}`, {
|
|
225
|
-
status: 500,
|
|
226
|
-
headers: {
|
|
227
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
228
|
-
'x-modern-js-bff-worker': bff.worker,
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const mountedRequest = createRequestForMountedPrefix(request, bff.prefix);
|
|
234
|
-
const defaultExport = workerModule.default;
|
|
235
|
-
const runtime = getRuntimeModule(workerModule);
|
|
236
|
-
|
|
237
|
-
if (bff.runtimeFramework === 'effect') {
|
|
238
|
-
let effectDispatcher;
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
effectDispatcher = await getEffectBffDispatcher(bff, runtime);
|
|
242
|
-
} catch (error) {
|
|
243
|
-
return createEffectBffDispatcherErrorResponse(bff, error);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return effectDispatcher.dispatch(request, { env });
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const directHandler =
|
|
250
|
-
(typeof runtime.handler === 'function' && runtime.handler) ||
|
|
251
|
-
(typeof defaultExport === 'function' && defaultExport);
|
|
252
|
-
const createdHandler =
|
|
253
|
-
typeof runtime.createHandler === 'function'
|
|
254
|
-
? runtime.createHandler().handler
|
|
255
|
-
: undefined;
|
|
256
|
-
const handler = directHandler || createdHandler;
|
|
257
|
-
|
|
258
|
-
if (typeof handler !== 'function') {
|
|
259
|
-
return new Response(
|
|
260
|
-
`BFF worker bundle has no handler export: ${bff.worker}`,
|
|
261
|
-
{
|
|
262
|
-
status: 500,
|
|
263
|
-
headers: {
|
|
264
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
265
|
-
'x-modern-js-bff-worker': bff.worker,
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const effectContext = {
|
|
272
|
-
request: mountedRequest,
|
|
273
|
-
env: env || {},
|
|
274
|
-
path: new URL(request.url).pathname,
|
|
275
|
-
method: request.method,
|
|
276
|
-
operationContext: {
|
|
277
|
-
request: mountedRequest,
|
|
278
|
-
env: env || {},
|
|
279
|
-
path: new URL(request.url).pathname,
|
|
280
|
-
method: request.method,
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
return handler(mountedRequest, effectContext);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const MICROVERTICAL_SERVER_FALLBACK_EVENT =
|
|
288
|
-
'modernjs:microvertical-server-fallback';
|
|
289
|
-
|
|
290
|
-
// Typed degraded event for an unavailable service binding. Mirrors the shape
|
|
291
|
-
// of the runtime MF fallback telemetry payload (schemaVersion 1) under the
|
|
292
|
-
// server-side event name, so shell-level consumers see one degraded contract
|
|
293
|
-
// across platforms.
|
|
294
|
-
function createServiceBindingDegradedEvent(binding, pathname) {
|
|
295
|
-
return {
|
|
296
|
-
appName: 'modern-js-cloudflare-worker',
|
|
297
|
-
eventName: MICROVERTICAL_SERVER_FALLBACK_EVENT,
|
|
298
|
-
phase: 'discovery',
|
|
299
|
-
reason: 'remote-unavailable',
|
|
300
|
-
schemaVersion: 1,
|
|
301
|
-
metadata: {
|
|
302
|
-
classification: 'remote-unavailable',
|
|
303
|
-
pathname,
|
|
304
|
-
platform: 'cloudflare-service-binding',
|
|
305
|
-
prefix: binding.prefix,
|
|
306
|
-
remote: binding.binding,
|
|
307
|
-
serviceBinding: binding.binding,
|
|
308
|
-
status: 'degraded',
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
async function dispatchServiceBindingRequest(request, env) {
|
|
314
|
-
const serviceBindings = MODERN_WORKER_MANIFEST.serviceBindings;
|
|
315
|
-
|
|
316
|
-
if (!Array.isArray(serviceBindings) || serviceBindings.length === 0) {
|
|
317
|
-
return null;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const pathname = new URL(request.url).pathname;
|
|
321
|
-
|
|
322
|
-
for (const binding of serviceBindings) {
|
|
323
|
-
if (!binding?.binding || !binding?.prefix) {
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (!matchesPrefix(pathname, binding.prefix)) {
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const service = env?.[binding.binding];
|
|
332
|
-
|
|
333
|
-
if (!service || typeof service.fetch !== 'function') {
|
|
334
|
-
const degradedEvent = createServiceBindingDegradedEvent(
|
|
335
|
-
binding,
|
|
336
|
-
pathname,
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
// Telemetry emission: workers surface structured logs via tail/analytics.
|
|
340
|
-
// The degraded path must never fail because a log sink did.
|
|
341
|
-
try {
|
|
342
|
-
console.error(JSON.stringify(degradedEvent));
|
|
343
|
-
} catch {}
|
|
344
|
-
|
|
345
|
-
return new Response(
|
|
346
|
-
`Cloudflare service binding not available: ${binding.binding}`,
|
|
347
|
-
{
|
|
348
|
-
status: 502,
|
|
349
|
-
headers: {
|
|
350
|
-
'content-type': 'text/plain; charset=utf-8',
|
|
351
|
-
'x-modern-js-service-binding': binding.binding,
|
|
352
|
-
'x-modern-js-degraded': degradedEvent.metadata.classification,
|
|
353
|
-
'x-modern-js-telemetry-event': degradedEvent.eventName,
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return service.fetch(request);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return null;
|
|
363
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
async fetch(request, env, ctx) {
|
|
3
|
-
const corsPreflightResponse = await createCorsPreflightResponse(
|
|
4
|
-
request,
|
|
5
|
-
env,
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
if (corsPreflightResponse) {
|
|
9
|
-
return finalizeResponseForRequest(corsPreflightResponse, request);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const bffResponse = await dispatchBffRequest(request, env);
|
|
13
|
-
|
|
14
|
-
if (bffResponse) {
|
|
15
|
-
return finalizeResponseForRequest(
|
|
16
|
-
withAppCorsHeaders(bffResponse, request),
|
|
17
|
-
request,
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const serviceBindingResponse = await dispatchServiceBindingRequest(
|
|
22
|
-
request,
|
|
23
|
-
env,
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (serviceBindingResponse) {
|
|
27
|
-
return finalizeResponseForRequest(
|
|
28
|
-
withAppCorsHeaders(serviceBindingResponse, request),
|
|
29
|
-
request,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const route = findRoute(request);
|
|
34
|
-
const { pathname } = new URL(request.url);
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
isAssetLikePathname(pathname) &&
|
|
38
|
-
!routeMatchesExactly(route, pathname)
|
|
39
|
-
) {
|
|
40
|
-
const assetResponse = await fetchAsset(request, env);
|
|
41
|
-
|
|
42
|
-
if (assetResponse) {
|
|
43
|
-
return finalizeResponseForRequest(assetResponse, request);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return finalizeResponseForRequest(
|
|
47
|
-
withAppCorsHeaders(new Response('Not found', { status: 404 }), request),
|
|
48
|
-
request,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const localeRedirectResponse = createLocaleRedirectResponseForRequest(
|
|
53
|
-
route,
|
|
54
|
-
request,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
if (localeRedirectResponse) {
|
|
58
|
-
return finalizeResponseForRequest(
|
|
59
|
-
withAppCorsHeaders(localeRedirectResponse, request),
|
|
60
|
-
request,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (route?.worker) {
|
|
65
|
-
const renderableRequest = createRenderableRequest(request);
|
|
66
|
-
|
|
67
|
-
return finalizeResponseForRequest(
|
|
68
|
-
withAppCorsHeaders(
|
|
69
|
-
await dispatchRouteWorker(route, renderableRequest, env, ctx),
|
|
70
|
-
request,
|
|
71
|
-
),
|
|
72
|
-
request,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const htmlResponse = await fetchRouteHtml(route, request, env);
|
|
77
|
-
|
|
78
|
-
if (htmlResponse) {
|
|
79
|
-
return finalizeResponseForRequest(htmlResponse, request);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const assetResponse = await fetchAsset(request, env);
|
|
83
|
-
|
|
84
|
-
if (assetResponse) {
|
|
85
|
-
return finalizeResponseForRequest(assetResponse, request);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return finalizeResponseForRequest(
|
|
89
|
-
withAppCorsHeaders(new Response('Not found', { status: 404 }), request),
|
|
90
|
-
request,
|
|
91
|
-
);
|
|
92
|
-
},
|
|
93
|
-
};
|