@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/modern.js +0 -0
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -16
- package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +14 -11
- package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +72 -0
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +28 -11
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +13 -6
- package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
- package/dist/cjs/commands/index.js +0 -4
- package/dist/cjs/config/build-environment.js +268 -0
- package/dist/cjs/config/index.js +11 -4
- package/dist/cjs/config/public.js +46 -0
- package/dist/cjs/index.js +39 -62
- package/dist/cjs/plugins/analyze/getServerRoutes.js +19 -0
- package/dist/cjs/plugins/analyze/index.js +20 -12
- package/dist/cjs/plugins/backend-federation/codegen.js +255 -0
- package/dist/cjs/plugins/backend-federation/config.js +204 -0
- package/dist/cjs/plugins/backend-federation/emit.js +148 -0
- package/dist/cjs/plugins/backendFederationBuild.js +53 -0
- package/dist/cjs/plugins/deploy/index.js +4 -4
- package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +141 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +139 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +150 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +208 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +204 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +108 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +188 -0
- package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +89 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +151 -0
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +302 -0
- package/dist/cjs/plugins/deploy/platforms/node.js +20 -2
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/cjs/plugins/deploy/utils/npmAliases.js +226 -0
- package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +100 -0
- package/dist/cjs/presetUltramodern.js +33 -2
- package/dist/cjs/ultramodern-release-envelope/canonical.js +68 -0
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +597 -0
- package/dist/cjs/ultramodern-release-envelope/index.js +399 -0
- package/dist/cjs/ultramodern-release-envelope/types.js +51 -0
- package/dist/cjs/ultramodern-release-identity.js +110 -0
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -15
- package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
- package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +30 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
- package/dist/esm/builder/shared/bundlerPlugins/index.mjs +1 -0
- package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
- package/dist/esm/commands/index.mjs +0 -1
- package/dist/esm/config/build-environment.mjs +224 -0
- package/dist/esm/config/index.mjs +1 -0
- package/dist/esm/config/public.mjs +1 -0
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
- package/dist/esm/plugins/analyze/getServerRoutes.mjs +17 -1
- package/dist/esm/plugins/analyze/index.mjs +20 -12
- package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
- package/dist/esm/plugins/backend-federation/codegen.mjs +204 -0
- package/dist/esm/plugins/backend-federation/config.mjs +128 -0
- package/dist/esm/plugins/backend-federation/emit.mjs +97 -0
- package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
- package/dist/esm/plugins/deploy/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +88 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +102 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +148 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +150 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +31 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +133 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +51 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +99 -0
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +238 -0
- package/dist/esm/plugins/deploy/platforms/node.mjs +20 -2
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/esm/plugins/deploy/utils/npmAliases.mjs +174 -0
- package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +52 -0
- package/dist/esm/presetUltramodern.mjs +33 -2
- package/dist/esm/ultramodern-release-envelope/canonical.mjs +21 -0
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +524 -0
- package/dist/esm/ultramodern-release-envelope/index.mjs +335 -0
- package/dist/esm/ultramodern-release-envelope/types.mjs +7 -0
- package/dist/esm/ultramodern-release-identity.mjs +66 -0
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -15
- package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
- package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +31 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
- package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +1 -0
- package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
- package/dist/esm-node/commands/index.mjs +0 -1
- package/dist/esm-node/config/build-environment.mjs +225 -0
- package/dist/esm-node/config/index.mjs +1 -0
- package/dist/esm-node/config/public.mjs +2 -0
- package/dist/esm-node/index.mjs +5 -4
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
- package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +17 -1
- package/dist/esm-node/plugins/analyze/index.mjs +20 -12
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
- package/dist/esm-node/plugins/backend-federation/codegen.mjs +205 -0
- package/dist/esm-node/plugins/backend-federation/config.mjs +129 -0
- package/dist/esm-node/plugins/backend-federation/emit.mjs +98 -0
- package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
- package/dist/esm-node/plugins/deploy/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +35 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +89 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +103 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +149 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +151 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +32 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +134 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +52 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +100 -0
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +239 -0
- package/dist/esm-node/plugins/deploy/platforms/node.mjs +20 -2
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
- package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
- package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
- package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +175 -0
- package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +53 -0
- package/dist/esm-node/presetUltramodern.mjs +33 -2
- package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +22 -0
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +525 -0
- package/dist/esm-node/ultramodern-release-envelope/index.mjs +336 -0
- package/dist/esm-node/ultramodern-release-envelope/types.mjs +8 -0
- package/dist/esm-node/ultramodern-release-identity.mjs +67 -0
- package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
- package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +6 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -0
- package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
- package/dist/types/commands/index.d.ts +0 -1
- package/dist/types/config/build-environment.d.ts +22 -0
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/config/public.d.ts +2 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
- package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
- package/dist/types/plugins/backend-federation/config.d.ts +103 -0
- package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
- package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +24 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
- package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
- package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +122 -0
- package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +46 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +14 -0
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +20 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
- package/dist/types/plugins/deploy/utils/npmAliases.d.ts +14 -0
- package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +3 -0
- package/dist/types/presetUltramodern.d.ts +10 -0
- package/dist/types/run/index.d.ts +1 -1
- package/dist/types/types/config/cloudflareDeploy.d.ts +41 -0
- package/dist/types/types/config/deploy.d.ts +15 -2
- package/dist/types/ultramodern-release-envelope/canonical.d.ts +5 -0
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +31 -0
- package/dist/types/ultramodern-release-envelope/index.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/types.d.ts +62 -0
- package/dist/types/ultramodern-release-identity.d.ts +16 -0
- package/lib/types.d.ts +2 -3
- package/package.json +38 -23
- package/rslib.config.mts +11 -12
- package/dist/cjs/commands/runtime.js +0 -196
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/cjs/ultramodern/designSystem.js +0 -123
- package/dist/esm/baseline.mjs +0 -4
- package/dist/esm/commands/runtime.mjs +0 -146
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/esm/ultramodern/designSystem.mjs +0 -73
- package/dist/esm-node/baseline.mjs +0 -5
- package/dist/esm-node/commands/runtime.mjs +0 -147
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
- package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
- package/dist/types/baseline.d.ts +0 -16
- package/dist/types/commands/runtime.d.ts +0 -12
- package/dist/types/ultramodern/designSystem.d.ts +0 -54
- /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
|
@@ -1,540 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
-
var define = (defs, kind)=>{
|
|
15
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
[kind]: defs[key]
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
define(getters, "get");
|
|
21
|
-
define(values, "value");
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
(()=>{
|
|
25
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
-
})();
|
|
27
|
-
(()=>{
|
|
28
|
-
__webpack_require__.r = (exports1)=>{
|
|
29
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
-
value: 'Module'
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
-
value: true
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
var __webpack_exports__ = {};
|
|
38
|
-
__webpack_require__.r(__webpack_exports__);
|
|
39
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
-
createCloudflarePreset: ()=>createCloudflarePreset
|
|
41
|
-
});
|
|
42
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
43
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
44
|
-
const utils_namespaceObject = require("@modern-js/utils");
|
|
45
|
-
const index_js_namespaceObject = require("../utils/index.js");
|
|
46
|
-
const WORKER_ENTRY = 'server/index.mjs';
|
|
47
|
-
const WORKER_MANIFEST = 'server/modern-worker-manifest.json';
|
|
48
|
-
const WRANGLER_CONFIG_FILE = 'wrangler.json';
|
|
49
|
-
const OUTPUT_PACKAGE_FILE = 'package.json';
|
|
50
|
-
const ASSETS_BINDING = 'ASSETS';
|
|
51
|
-
const ROUTE_SPEC_FILE = 'route.json';
|
|
52
|
-
const ROUTE_SPEC_OUTPUT = `server/${ROUTE_SPEC_FILE}`;
|
|
53
|
-
const LOADABLE_STATS_FILE = 'loadable-stats.json';
|
|
54
|
-
const ROUTE_MANIFEST_FILE = 'routes-manifest.json';
|
|
55
|
-
const PUBLIC_ASSETS_DIRECTORY = 'public';
|
|
56
|
-
const WORKER_BUNDLE_DIRECTORY = 'worker';
|
|
57
|
-
const SERVER_BUNDLE_DIRECTORY = 'bundles';
|
|
58
|
-
const SERVER_OUTPUT_DIRECTORY = 'server';
|
|
59
|
-
const DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES = [
|
|
60
|
-
'api',
|
|
61
|
-
'shared'
|
|
62
|
-
];
|
|
63
|
-
const BFF_EFFECT_WORKER_ENTRY = `${WORKER_BUNDLE_DIRECTORY}/__modern_bff_effect.js`;
|
|
64
|
-
const EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE = 'Ensure the Effect API entry exists at api/index.ts or bff.effect.entry, and import Cloudflare edge handlers from @modern-js/plugin-bff/effect-edge instead of lambda/Hono server helpers.';
|
|
65
|
-
const DEFAULT_COMPATIBILITY_DATE = '2026-06-02';
|
|
66
|
-
const COMPATIBILITY_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
|
|
67
|
-
const REQUIRED_COMPATIBILITY_FLAGS = [
|
|
68
|
-
'nodejs_compat',
|
|
69
|
-
'global_fetch_strictly_public'
|
|
70
|
-
];
|
|
71
|
-
const RESERVED_ARTIFACT_DESTINATION_FILES = new Set([
|
|
72
|
-
WRANGLER_CONFIG_FILE,
|
|
73
|
-
OUTPUT_PACKAGE_FILE
|
|
74
|
-
]);
|
|
75
|
-
const RESERVED_ARTIFACT_DESTINATION_DIRECTORIES = new Set([
|
|
76
|
-
PUBLIC_ASSETS_DIRECTORY,
|
|
77
|
-
SERVER_OUTPUT_DIRECTORY,
|
|
78
|
-
WORKER_BUNDLE_DIRECTORY
|
|
79
|
-
]);
|
|
80
|
-
const DEFAULT_SECURITY_HEADERS = {
|
|
81
|
-
referrerPolicy: 'strict-origin-when-cross-origin',
|
|
82
|
-
contentTypeOptions: 'nosniff',
|
|
83
|
-
permissionsPolicy: 'camera=(), geolocation=(), microphone=(), payment=(), usb=()'
|
|
84
|
-
};
|
|
85
|
-
const DEFAULT_CORS_ALLOWED_METHODS = [
|
|
86
|
-
'GET',
|
|
87
|
-
'HEAD',
|
|
88
|
-
'POST',
|
|
89
|
-
'PUT',
|
|
90
|
-
'PATCH',
|
|
91
|
-
'DELETE',
|
|
92
|
-
'OPTIONS'
|
|
93
|
-
];
|
|
94
|
-
const DEFAULT_CSP_DIRECTIVES = {
|
|
95
|
-
'base-uri': [
|
|
96
|
-
"'self'"
|
|
97
|
-
],
|
|
98
|
-
'connect-src': [
|
|
99
|
-
"'self'",
|
|
100
|
-
'https:',
|
|
101
|
-
'http:',
|
|
102
|
-
'wss:',
|
|
103
|
-
'ws:'
|
|
104
|
-
],
|
|
105
|
-
'default-src': [
|
|
106
|
-
"'self'"
|
|
107
|
-
],
|
|
108
|
-
'font-src': [
|
|
109
|
-
"'self'",
|
|
110
|
-
'data:',
|
|
111
|
-
'https:',
|
|
112
|
-
'http:'
|
|
113
|
-
],
|
|
114
|
-
'form-action': [
|
|
115
|
-
"'self'"
|
|
116
|
-
],
|
|
117
|
-
'frame-ancestors': [
|
|
118
|
-
"'self'"
|
|
119
|
-
],
|
|
120
|
-
'img-src': [
|
|
121
|
-
"'self'",
|
|
122
|
-
'data:',
|
|
123
|
-
'blob:',
|
|
124
|
-
'https:',
|
|
125
|
-
'http:'
|
|
126
|
-
],
|
|
127
|
-
'manifest-src': [
|
|
128
|
-
"'self'",
|
|
129
|
-
'https:',
|
|
130
|
-
'http:'
|
|
131
|
-
],
|
|
132
|
-
'object-src': [
|
|
133
|
-
"'none'"
|
|
134
|
-
],
|
|
135
|
-
"script-src": [
|
|
136
|
-
"'self'",
|
|
137
|
-
"'unsafe-inline'",
|
|
138
|
-
"'unsafe-eval'",
|
|
139
|
-
'https:',
|
|
140
|
-
'http:',
|
|
141
|
-
'blob:'
|
|
142
|
-
],
|
|
143
|
-
'style-src': [
|
|
144
|
-
"'self'",
|
|
145
|
-
"'unsafe-inline'",
|
|
146
|
-
'https:',
|
|
147
|
-
'http:'
|
|
148
|
-
],
|
|
149
|
-
'worker-src': [
|
|
150
|
-
"'self'",
|
|
151
|
-
'blob:'
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
const getCompatibilityDate = (modernConfig)=>{
|
|
155
|
-
const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
|
|
156
|
-
const compatibilityDate = configuredDate || DEFAULT_COMPATIBILITY_DATE;
|
|
157
|
-
if (!COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
|
|
158
|
-
return compatibilityDate;
|
|
159
|
-
};
|
|
160
|
-
const getWorkerName = (appDirectory)=>{
|
|
161
|
-
const basename = external_node_path_default().basename(appDirectory);
|
|
162
|
-
return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
|
|
163
|
-
};
|
|
164
|
-
const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
|
|
165
|
-
const configuredName = modernConfig.deploy?.worker?.name?.trim();
|
|
166
|
-
return configuredName || getWorkerName(appDirectory);
|
|
167
|
-
};
|
|
168
|
-
const normalizeRelativePath = (value, label, scope = 'app output')=>{
|
|
169
|
-
if ('string' != typeof value) throw new Error(`${label} must be a relative path inside the ${scope}.`);
|
|
170
|
-
const normalized = value.trim().replace(/\\/g, '/').replace(/^\.\/+/u, '').replace(/\/+$/u, '');
|
|
171
|
-
const segments = normalized.split('/');
|
|
172
|
-
if (!normalized || external_node_path_default().isAbsolute(normalized) || '.' === normalized || segments.includes('..')) throw new Error(`${label} must be a relative path inside the ${scope}.`);
|
|
173
|
-
return normalized;
|
|
174
|
-
};
|
|
175
|
-
const normalizeDirectiveValues = (value)=>{
|
|
176
|
-
const values = Array.isArray(value) ? value : [
|
|
177
|
-
value
|
|
178
|
-
];
|
|
179
|
-
return [
|
|
180
|
-
...new Set(values.map((entry)=>entry.trim()).filter(Boolean))
|
|
181
|
-
];
|
|
182
|
-
};
|
|
183
|
-
const appendDirectiveValues = (directives, name, values)=>{
|
|
184
|
-
if (!values?.length) return;
|
|
185
|
-
directives[name] = normalizeDirectiveValues([
|
|
186
|
-
...directives[name] ?? [],
|
|
187
|
-
...values
|
|
188
|
-
]);
|
|
189
|
-
};
|
|
190
|
-
const createContentSecurityPolicy = (config)=>{
|
|
191
|
-
const mode = config?.mode ?? 'report-only';
|
|
192
|
-
if ('off' === mode) return {
|
|
193
|
-
mode,
|
|
194
|
-
directives: {},
|
|
195
|
-
reason: config?.reason
|
|
196
|
-
};
|
|
197
|
-
const directives = Object.fromEntries(Object.entries(DEFAULT_CSP_DIRECTIVES).map(([name, values])=>[
|
|
198
|
-
name,
|
|
199
|
-
[
|
|
200
|
-
...values
|
|
201
|
-
]
|
|
202
|
-
]));
|
|
203
|
-
for (const [name, value] of Object.entries(config?.directives ?? {}))if (false === value) delete directives[name];
|
|
204
|
-
else directives[name] = normalizeDirectiveValues(value);
|
|
205
|
-
if (config?.frameAncestors === false) delete directives['frame-ancestors'];
|
|
206
|
-
else if (config?.frameAncestors) directives['frame-ancestors'] = normalizeDirectiveValues(config.frameAncestors);
|
|
207
|
-
appendDirectiveValues(directives, "script-src", config?.additionalScriptSrc);
|
|
208
|
-
appendDirectiveValues(directives, 'style-src', config?.additionalStyleSrc);
|
|
209
|
-
appendDirectiveValues(directives, 'connect-src', config?.additionalConnectSrc);
|
|
210
|
-
appendDirectiveValues(directives, 'img-src', config?.additionalImgSrc);
|
|
211
|
-
if (config?.reportUri) directives['report-uri'] = [
|
|
212
|
-
config.reportUri
|
|
213
|
-
];
|
|
214
|
-
return {
|
|
215
|
-
mode,
|
|
216
|
-
directives,
|
|
217
|
-
reason: config?.reason
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
const createNoindexPolicy = (noindex)=>{
|
|
221
|
-
if (false === noindex) return {
|
|
222
|
-
workersDev: false,
|
|
223
|
-
localhost: false,
|
|
224
|
-
previewHostnames: []
|
|
225
|
-
};
|
|
226
|
-
if (true === noindex || void 0 === noindex) return {
|
|
227
|
-
workersDev: true,
|
|
228
|
-
localhost: true,
|
|
229
|
-
previewHostnames: []
|
|
230
|
-
};
|
|
231
|
-
return {
|
|
232
|
-
workersDev: noindex.workersDev ?? true,
|
|
233
|
-
localhost: noindex.localhost ?? true,
|
|
234
|
-
previewHostnames: noindex.previewHostnames ?? [],
|
|
235
|
-
reason: noindex.reason
|
|
236
|
-
};
|
|
237
|
-
};
|
|
238
|
-
const createCloudflareWorkerCorsPolicy = (cors)=>({
|
|
239
|
-
assets: cors?.assets ?? true,
|
|
240
|
-
allowedOrigins: normalizeDirectiveValues(cors?.allowedOrigins ?? []),
|
|
241
|
-
allowedMethods: cors?.allowedMethods?.length ? normalizeDirectiveValues(cors.allowedMethods.map((method)=>method.toUpperCase())) : DEFAULT_CORS_ALLOWED_METHODS,
|
|
242
|
-
allowedHeaders: cors?.allowedHeaders?.length ? normalizeDirectiveValues(cors.allowedHeaders) : [
|
|
243
|
-
'*'
|
|
244
|
-
],
|
|
245
|
-
reason: cors?.reason
|
|
246
|
-
});
|
|
247
|
-
const createCloudflareWorkerSecurityPolicy = (modernConfig)=>{
|
|
248
|
-
const security = modernConfig.deploy?.worker?.security;
|
|
249
|
-
if (security?.enabled === false) return {
|
|
250
|
-
enabled: false,
|
|
251
|
-
cors: createCloudflareWorkerCorsPolicy(security.cors),
|
|
252
|
-
reason: security.reason
|
|
253
|
-
};
|
|
254
|
-
return {
|
|
255
|
-
enabled: true,
|
|
256
|
-
headers: {
|
|
257
|
-
referrerPolicy: security?.headers?.referrerPolicy ?? DEFAULT_SECURITY_HEADERS.referrerPolicy,
|
|
258
|
-
contentTypeOptions: security?.headers?.contentTypeOptions ?? DEFAULT_SECURITY_HEADERS.contentTypeOptions,
|
|
259
|
-
permissionsPolicy: security?.headers?.permissionsPolicy ?? DEFAULT_SECURITY_HEADERS.permissionsPolicy
|
|
260
|
-
},
|
|
261
|
-
contentSecurityPolicy: createContentSecurityPolicy(security?.contentSecurityPolicy),
|
|
262
|
-
noindex: createNoindexPolicy(security?.noindex),
|
|
263
|
-
cors: createCloudflareWorkerCorsPolicy(security?.cors),
|
|
264
|
-
reason: security?.reason
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
const isJsonRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
268
|
-
const getConfiguredWrangler = (modernConfig)=>{
|
|
269
|
-
const wrangler = modernConfig.deploy?.worker?.wrangler;
|
|
270
|
-
if (void 0 === wrangler) return {};
|
|
271
|
-
if (!isJsonRecord(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
|
|
272
|
-
return wrangler;
|
|
273
|
-
};
|
|
274
|
-
const createWranglerCompatibilityFlags = (configuredFlags)=>{
|
|
275
|
-
if (void 0 === configuredFlags) return [
|
|
276
|
-
...REQUIRED_COMPATIBILITY_FLAGS
|
|
277
|
-
];
|
|
278
|
-
if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
|
|
279
|
-
return [
|
|
280
|
-
...new Set([
|
|
281
|
-
...configuredFlags,
|
|
282
|
-
...REQUIRED_COMPATIBILITY_FLAGS
|
|
283
|
-
])
|
|
284
|
-
];
|
|
285
|
-
};
|
|
286
|
-
const createWranglerAssetsConfig = (configuredAssets)=>{
|
|
287
|
-
if (void 0 !== configuredAssets && !isJsonRecord(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
|
|
288
|
-
return {
|
|
289
|
-
...isJsonRecord(configuredAssets) ? configuredAssets : {},
|
|
290
|
-
directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
|
|
291
|
-
binding: ASSETS_BINDING,
|
|
292
|
-
run_worker_first: true
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
const assertNonEmptyString = (value, label)=>{
|
|
296
|
-
if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
|
|
297
|
-
return value.trim();
|
|
298
|
-
};
|
|
299
|
-
const normalizeD1Database = (database, index)=>{
|
|
300
|
-
const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
|
|
301
|
-
const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
|
|
302
|
-
const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
|
|
303
|
-
const migrationsDir = void 0 === database.migrationsDir ? void 0 : normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
|
|
304
|
-
const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
|
|
305
|
-
return {
|
|
306
|
-
binding,
|
|
307
|
-
database_name: databaseName,
|
|
308
|
-
database_id: databaseId,
|
|
309
|
-
...void 0 === migrationsDir ? {} : {
|
|
310
|
-
migrations_dir: migrationsDir
|
|
311
|
-
},
|
|
312
|
-
...void 0 === previewDatabaseId ? {} : {
|
|
313
|
-
preview_database_id: previewDatabaseId
|
|
314
|
-
},
|
|
315
|
-
...void 0 === database.remote ? {} : {
|
|
316
|
-
remote: database.remote
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
};
|
|
320
|
-
const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
|
|
321
|
-
const d1Databases = modernConfig.deploy?.worker?.d1Databases;
|
|
322
|
-
if (void 0 === d1Databases) return configuredWranglerD1;
|
|
323
|
-
if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
|
|
324
|
-
if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
|
|
325
|
-
return d1Databases.map(normalizeD1Database);
|
|
326
|
-
};
|
|
327
|
-
const createWranglerConfig = (appDirectory, modernConfig)=>{
|
|
328
|
-
const wrangler = getConfiguredWrangler(modernConfig);
|
|
329
|
-
const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
|
|
330
|
-
return {
|
|
331
|
-
$schema: 'node_modules/wrangler/config-schema.json',
|
|
332
|
-
name: getConfiguredWorkerName(appDirectory, modernConfig),
|
|
333
|
-
compatibility_date: getCompatibilityDate(modernConfig),
|
|
334
|
-
...wrangler,
|
|
335
|
-
main: WORKER_ENTRY,
|
|
336
|
-
compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
|
|
337
|
-
assets: createWranglerAssetsConfig(wrangler.assets),
|
|
338
|
-
...void 0 === d1Databases ? {} : {
|
|
339
|
-
d1_databases: d1Databases
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
const normalizeCloudflareArtifact = (artifact, index)=>{
|
|
344
|
-
const from = normalizeRelativePath(artifact.from, `deploy.worker.artifacts[${index}].from`, 'app root');
|
|
345
|
-
const to = normalizeRelativePath(artifact.to, `deploy.worker.artifacts[${index}].to`, 'Cloudflare output');
|
|
346
|
-
const [topLevelDestination] = to.split('/');
|
|
347
|
-
const reservedDestination = RESERVED_ARTIFACT_DESTINATION_FILES.has(to) ? to : topLevelDestination;
|
|
348
|
-
if (RESERVED_ARTIFACT_DESTINATION_FILES.has(to) || RESERVED_ARTIFACT_DESTINATION_DIRECTORIES.has(topLevelDestination)) throw new Error(`deploy.worker.artifacts[${index}].to must not target generated Cloudflare output path ${JSON.stringify(reservedDestination)}.`);
|
|
349
|
-
return {
|
|
350
|
-
from,
|
|
351
|
-
to,
|
|
352
|
-
index
|
|
353
|
-
};
|
|
354
|
-
};
|
|
355
|
-
const getCloudflareArtifacts = (modernConfig)=>(modernConfig.deploy?.worker?.artifacts ?? []).map(normalizeCloudflareArtifact);
|
|
356
|
-
const copyCloudflareArtifacts = async (appDirectory, outputDirectory, artifacts)=>{
|
|
357
|
-
for (const artifact of artifacts){
|
|
358
|
-
const sourcePath = external_node_path_default().join(appDirectory, artifact.from);
|
|
359
|
-
if (!await utils_namespaceObject.fs.pathExists(sourcePath)) throw new Error(`deploy.worker.artifacts[${artifact.index}].from does not exist: ${artifact.from}`);
|
|
360
|
-
await utils_namespaceObject.fs.copy(sourcePath, external_node_path_default().join(outputDirectory, artifact.to));
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const copyCloudflareD1Migrations = async (appDirectory, outputDirectory, modernConfig)=>{
|
|
364
|
-
for (const [index, database] of (modernConfig.deploy?.worker?.d1Databases ?? []).entries()){
|
|
365
|
-
if (!database.migrationsDir) continue;
|
|
366
|
-
const migrationsDir = normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
|
|
367
|
-
const sourcePath = external_node_path_default().join(appDirectory, migrationsDir);
|
|
368
|
-
if (!await utils_namespaceObject.fs.pathExists(sourcePath)) throw new Error(`deploy.worker.d1Databases[${index}].migrationsDir does not exist: ${migrationsDir}`);
|
|
369
|
-
await utils_namespaceObject.fs.copy(sourcePath, external_node_path_default().join(outputDirectory, migrationsDir));
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
const readRouteSpec = async (outputDirectory)=>{
|
|
373
|
-
const routeSpecPath = external_node_path_default().join(outputDirectory, ROUTE_SPEC_OUTPUT);
|
|
374
|
-
if (!await utils_namespaceObject.fs.pathExists(routeSpecPath)) return {
|
|
375
|
-
routes: []
|
|
376
|
-
};
|
|
377
|
-
const routeSpec = await utils_namespaceObject.fs.readJSON(routeSpecPath);
|
|
378
|
-
return {
|
|
379
|
-
...routeSpec,
|
|
380
|
-
routes: Array.isArray(routeSpec.routes) ? routeSpec.routes : []
|
|
381
|
-
};
|
|
382
|
-
};
|
|
383
|
-
const createMissingEffectBffWorkerError = (outputDirectory, worker)=>new Error(`Cloudflare Effect API runtime is configured, but the BFF worker bundle is missing: ${external_node_path_default().join(outputDirectory, worker)}. ${EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE}`);
|
|
384
|
-
const createWorkerManifest = async (outputDirectory, modernConfig)=>{
|
|
385
|
-
const routeSpec = await readRouteSpec(outputDirectory);
|
|
386
|
-
const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
|
|
387
|
-
const worker = 'string' == typeof route.worker ? route.worker : void 0;
|
|
388
|
-
return {
|
|
389
|
-
urlPath: route.urlPath,
|
|
390
|
-
entryName: route.entryName,
|
|
391
|
-
entryPath: route.entryPath,
|
|
392
|
-
isSSR: Boolean(route.isSSR),
|
|
393
|
-
worker,
|
|
394
|
-
workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false
|
|
395
|
-
};
|
|
396
|
-
}));
|
|
397
|
-
const bffPrefix = modernConfig.bff?.prefix;
|
|
398
|
-
const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
|
|
399
|
-
const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
|
|
400
|
-
const effectApiWorkerExists = await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
|
|
401
|
-
if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, BFF_EFFECT_WORKER_ENTRY);
|
|
402
|
-
return {
|
|
403
|
-
version: 1,
|
|
404
|
-
runtime: {
|
|
405
|
-
type: 'cloudflare-module-worker',
|
|
406
|
-
entry: WORKER_ENTRY,
|
|
407
|
-
fetchExport: true,
|
|
408
|
-
nodeListen: false
|
|
409
|
-
},
|
|
410
|
-
assets: {
|
|
411
|
-
binding: ASSETS_BINDING,
|
|
412
|
-
directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
|
|
413
|
-
runWorkerFirst: true
|
|
414
|
-
},
|
|
415
|
-
routeSpec: {
|
|
416
|
-
file: ROUTE_SPEC_OUTPUT,
|
|
417
|
-
routes
|
|
418
|
-
},
|
|
419
|
-
workerBundles: {
|
|
420
|
-
directory: WORKER_BUNDLE_DIRECTORY,
|
|
421
|
-
format: 'commonjs',
|
|
422
|
-
importableFromModuleWorker: true,
|
|
423
|
-
requestHandlerExport: 'requestHandler'
|
|
424
|
-
},
|
|
425
|
-
resources: {
|
|
426
|
-
loadableStats: LOADABLE_STATS_FILE,
|
|
427
|
-
routeManifest: ROUTE_MANIFEST_FILE
|
|
428
|
-
},
|
|
429
|
-
security: createCloudflareWorkerSecurityPolicy(modernConfig),
|
|
430
|
-
bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
|
|
431
|
-
runtimeFramework: 'effect',
|
|
432
|
-
prefix: primaryBffPrefix,
|
|
433
|
-
worker: BFF_EFFECT_WORKER_ENTRY
|
|
434
|
-
} : void 0
|
|
435
|
-
};
|
|
436
|
-
};
|
|
437
|
-
const createWorkerModuleLoaders = (manifest)=>{
|
|
438
|
-
const imports = new Map();
|
|
439
|
-
for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
|
|
440
|
-
const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
|
|
441
|
-
imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
|
|
442
|
-
}
|
|
443
|
-
if (manifest.bff?.worker) {
|
|
444
|
-
const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
|
|
445
|
-
imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
|
|
446
|
-
}
|
|
447
|
-
if (0 === imports.size) return '{}';
|
|
448
|
-
const loaders = [
|
|
449
|
-
...imports.entries()
|
|
450
|
-
].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
|
|
451
|
-
return `{\n${loaders.join(',\n')}\n}`;
|
|
452
|
-
};
|
|
453
|
-
const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
|
|
454
|
-
...DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
|
|
455
|
-
try {
|
|
456
|
-
return utils_namespaceObject.fs.statSync(external_node_path_default().join(appDirectory, directory)).isDirectory();
|
|
457
|
-
} catch {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
}),
|
|
461
|
-
...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
|
|
462
|
-
].map((entry)=>normalizeRelativePath(entry, 'deploy.worker.publicAssetExcludes'));
|
|
463
|
-
const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
|
|
464
|
-
const relativePath = external_node_path_default().relative(distDirectory, src);
|
|
465
|
-
if (!relativePath) return true;
|
|
466
|
-
const normalizedRelativePath = relativePath.replace(/\\/g, '/');
|
|
467
|
-
const [topLevelDirectory] = normalizedRelativePath.split('/');
|
|
468
|
-
return normalizedRelativePath !== ROUTE_SPEC_FILE && topLevelDirectory !== WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== SERVER_BUNDLE_DIRECTORY && !publicAssetExcludes.some((exclude)=>normalizedRelativePath === exclude || normalizedRelativePath.startsWith(`${exclude}/`));
|
|
469
|
-
};
|
|
470
|
-
const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
|
|
471
|
-
const relativePath = external_node_path_default().relative(workerBundleDirectory, src);
|
|
472
|
-
if (!relativePath) return true;
|
|
473
|
-
const normalizedRelativePath = relativePath.replace(/\\/g, '/');
|
|
474
|
-
const basename = external_node_path_default().basename(normalizedRelativePath);
|
|
475
|
-
if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
|
|
476
|
-
if (utils_namespaceObject.fs.statSync(src).isDirectory()) return true;
|
|
477
|
-
return [
|
|
478
|
-
'.cjs',
|
|
479
|
-
'.js',
|
|
480
|
-
'.mjs'
|
|
481
|
-
].includes(external_node_path_default().extname(normalizedRelativePath));
|
|
482
|
-
};
|
|
483
|
-
const createCloudflarePreset = ({ appContext, modernConfig })=>{
|
|
484
|
-
const { appDirectory, distDirectory } = appContext;
|
|
485
|
-
const outputDirectory = external_node_path_default().join(appDirectory, '.output');
|
|
486
|
-
const publicDirectory = external_node_path_default().join(outputDirectory, PUBLIC_ASSETS_DIRECTORY);
|
|
487
|
-
const workerEntryPath = external_node_path_default().join(outputDirectory, WORKER_ENTRY);
|
|
488
|
-
const workerManifestPath = external_node_path_default().join(outputDirectory, WORKER_MANIFEST);
|
|
489
|
-
const routeSpecOutputPath = external_node_path_default().join(outputDirectory, ROUTE_SPEC_OUTPUT);
|
|
490
|
-
const wranglerConfigPath = external_node_path_default().join(outputDirectory, WRANGLER_CONFIG_FILE);
|
|
491
|
-
const cloudflareArtifacts = getCloudflareArtifacts(modernConfig);
|
|
492
|
-
const publicAssetExcludes = getPublicAssetExcludes(appDirectory, modernConfig);
|
|
493
|
-
return {
|
|
494
|
-
async prepare () {
|
|
495
|
-
await utils_namespaceObject.fs.remove(outputDirectory);
|
|
496
|
-
},
|
|
497
|
-
async writeOutput () {
|
|
498
|
-
await utils_namespaceObject.fs.copy(distDirectory, publicDirectory, {
|
|
499
|
-
filter: (src)=>shouldCopyToPublicAssets(src, distDirectory, publicAssetExcludes)
|
|
500
|
-
});
|
|
501
|
-
await utils_namespaceObject.fs.ensureDir(external_node_path_default().dirname(workerEntryPath));
|
|
502
|
-
await utils_namespaceObject.fs.ensureDir(external_node_path_default().dirname(workerManifestPath));
|
|
503
|
-
const routeSpecSourcePath = external_node_path_default().join(distDirectory, ROUTE_SPEC_FILE);
|
|
504
|
-
if (await utils_namespaceObject.fs.pathExists(routeSpecSourcePath)) await utils_namespaceObject.fs.copy(routeSpecSourcePath, routeSpecOutputPath);
|
|
505
|
-
const workerBundleSourceDirectory = external_node_path_default().join(distDirectory, WORKER_BUNDLE_DIRECTORY);
|
|
506
|
-
const workerBundleOutputDirectory = external_node_path_default().join(outputDirectory, WORKER_BUNDLE_DIRECTORY);
|
|
507
|
-
if (await utils_namespaceObject.fs.pathExists(workerBundleSourceDirectory)) {
|
|
508
|
-
await utils_namespaceObject.fs.copy(workerBundleSourceDirectory, workerBundleOutputDirectory, {
|
|
509
|
-
filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
|
|
510
|
-
});
|
|
511
|
-
await utils_namespaceObject.fs.writeJSON(external_node_path_default().join(workerBundleOutputDirectory, 'package.json'), {
|
|
512
|
-
type: 'commonjs'
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
|
|
516
|
-
await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
|
|
517
|
-
await utils_namespaceObject.fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
|
|
518
|
-
spaces: 2
|
|
519
|
-
});
|
|
520
|
-
await utils_namespaceObject.fs.writeJSON(workerManifestPath, await createWorkerManifest(outputDirectory, modernConfig), {
|
|
521
|
-
spaces: 2
|
|
522
|
-
});
|
|
523
|
-
await utils_namespaceObject.fs.writeJSON(external_node_path_default().join(outputDirectory, OUTPUT_PACKAGE_FILE), {
|
|
524
|
-
type: 'module'
|
|
525
|
-
});
|
|
526
|
-
},
|
|
527
|
-
async genEntry () {
|
|
528
|
-
const template = await (0, index_js_namespaceObject.readTemplate)('cloudflare-entry.mjs');
|
|
529
|
-
const manifest = await utils_namespaceObject.fs.readJSON(workerManifestPath);
|
|
530
|
-
await utils_namespaceObject.fs.writeFile(workerEntryPath, template.replace('p_workerManifest', JSON.stringify(manifest, null, 2)).replace('p_workerModuleLoaders', createWorkerModuleLoaders(manifest)));
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
};
|
|
534
|
-
exports.createCloudflarePreset = __webpack_exports__.createCloudflarePreset;
|
|
535
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
536
|
-
"createCloudflarePreset"
|
|
537
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
538
|
-
Object.defineProperty(exports, '__esModule', {
|
|
539
|
-
value: true
|
|
540
|
-
});
|