@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
|
@@ -2,78 +2,57 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { createProdServer } from '@modern-js/prod-server';
|
|
5
|
-
|
|
6
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
6
|
p_genPluginImportsCode;
|
|
9
|
-
|
|
10
|
-
if (!process.env.NODE_ENV) {
|
|
11
|
-
process.env.NODE_ENV = 'production';
|
|
12
|
-
}
|
|
13
|
-
|
|
7
|
+
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
|
|
14
8
|
let requestHandler = null;
|
|
15
9
|
let handlerCreationPromise = null;
|
|
16
|
-
|
|
17
10
|
async function loadRoutes(routeFilepath) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
11
|
+
try {
|
|
12
|
+
await fs.access(routeFilepath);
|
|
13
|
+
const content = await fs.readFile(routeFilepath, 'utf-8');
|
|
14
|
+
const routeSpec = JSON.parse(content);
|
|
15
|
+
return routeSpec.routes || [];
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.warn('route.json not found or invalid, continuing with empty routes.');
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
async function initServer() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const app = await createProdServer(prodServerOptions);
|
|
51
|
-
|
|
52
|
-
return app.getRequestListener();
|
|
22
|
+
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
23
|
+
const routes = await loadRoutes(routeFilepath);
|
|
24
|
+
const dynamicProdOptions = p_dynamicProdOptions;
|
|
25
|
+
const prodServerOptions = {
|
|
26
|
+
pwd: __dirname,
|
|
27
|
+
routes,
|
|
28
|
+
disableCustomHook: true,
|
|
29
|
+
appContext: {
|
|
30
|
+
sharedDirectory: p_sharedDirectory,
|
|
31
|
+
apiDirectory: p_apiDirectory,
|
|
32
|
+
lambdaDirectory: p_lambdaDirectory
|
|
33
|
+
},
|
|
34
|
+
plugins: p_plugins,
|
|
35
|
+
serverConfigPath: p_serverDirectory,
|
|
36
|
+
...dynamicProdOptions
|
|
37
|
+
};
|
|
38
|
+
const app = await createProdServer(prodServerOptions);
|
|
39
|
+
return app.getRequestListener();
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
async function createHandler() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
42
|
+
if (!handlerCreationPromise) handlerCreationPromise = (async ()=>{
|
|
43
|
+
try {
|
|
44
|
+
requestHandler = await initServer();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error creating server:', error);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
64
49
|
})();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return requestHandler;
|
|
50
|
+
await handlerCreationPromise;
|
|
51
|
+
return requestHandler;
|
|
68
52
|
}
|
|
69
|
-
|
|
70
53
|
createHandler();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await createHandler();
|
|
75
|
-
}
|
|
76
|
-
return requestHandler(req, res);
|
|
54
|
+
const handler = async (req, res)=>{
|
|
55
|
+
if (!requestHandler) await createHandler();
|
|
56
|
+
return requestHandler(req, res);
|
|
77
57
|
};
|
|
78
|
-
|
|
79
58
|
export default handler;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
(()=>{
|
|
13
4
|
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
5
|
var define = (defs, kind)=>{
|
|
@@ -39,57 +30,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
39
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
31
|
default: ()=>ultramodernReleaseEnvelope
|
|
41
32
|
});
|
|
42
|
-
const
|
|
43
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
44
|
-
const framework_output_js_namespaceObject = require("../ultramodern-release-envelope/framework-output.js");
|
|
33
|
+
const plugin_namespaceObject = require("@modern-js/app-tools-extensions/release-envelope/plugin");
|
|
45
34
|
const index_js_namespaceObject = require("./deploy/index.js");
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const config = api.getNormalizedConfig();
|
|
49
|
-
if ('modern-js' !== metaName && !config.deploy?.target && !process.env.MODERNJS_DEPLOY) return;
|
|
50
|
-
return (0, index_js_namespaceObject.resolveDeployTarget)(config);
|
|
51
|
-
};
|
|
52
|
-
const ultramodernReleaseEnvelope = ()=>({
|
|
53
|
-
name: '@modern-js/ultramodern-release-envelope',
|
|
54
|
-
pre: [
|
|
55
|
-
'@modern-js/backend-federation-build',
|
|
56
|
-
'@modern-js/plugin-bff'
|
|
57
|
-
],
|
|
58
|
-
setup (api) {
|
|
59
|
-
const emitBuildEnvelope = async (target)=>{
|
|
60
|
-
const { apiOnly, distDirectory } = api.getAppContext();
|
|
61
|
-
await (0, framework_output_js_namespaceObject.emitFrameworkMicroVerticalReleaseEnvelope)({
|
|
62
|
-
apiOnly,
|
|
63
|
-
distDirectory,
|
|
64
|
-
target
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
api.onAfterBuild(async ()=>{
|
|
68
|
-
const configuredTarget = (0, index_js_namespaceObject.resolveDeployTarget)(api.getNormalizedConfig());
|
|
69
|
-
if ('node' !== configuredTarget && 'cloudflare' !== configuredTarget) return;
|
|
70
|
-
await emitBuildEnvelope(configuredTarget);
|
|
71
|
-
});
|
|
72
|
-
api.onBeforeDeploy(async ()=>{
|
|
73
|
-
const configuredTarget = resolveActiveDeployTarget(api);
|
|
74
|
-
if ('node' !== configuredTarget) return;
|
|
75
|
-
await emitBuildEnvelope(configuredTarget);
|
|
76
|
-
const { distDirectory } = api.getAppContext();
|
|
77
|
-
await (0, framework_output_js_namespaceObject.verifyBuildOutputReleaseEnvelope)(distDirectory, configuredTarget);
|
|
78
|
-
});
|
|
79
|
-
api.onAfterDeploy(async ()=>{
|
|
80
|
-
const configuredTarget = resolveActiveDeployTarget(api);
|
|
81
|
-
if ('node' !== configuredTarget) return;
|
|
82
|
-
const { appDirectory, distDirectory } = api.getAppContext();
|
|
83
|
-
const outputDirectory = external_node_path_default().join(appDirectory, '.output');
|
|
84
|
-
const releaseEnvelope = await (0, framework_output_js_namespaceObject.emitNodeStagedReleaseEnvelope)({
|
|
85
|
-
distDirectory,
|
|
86
|
-
outputDirectory
|
|
87
|
-
});
|
|
88
|
-
if (releaseEnvelope) await (0, framework_output_js_namespaceObject.verifyNodeReleaseEnvelopeStaging)({
|
|
89
|
-
outputDirectory
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
35
|
+
const ultramodernReleaseEnvelope = ()=>(0, plugin_namespaceObject.createUltramodernReleaseEnvelopePlugin)({
|
|
36
|
+
resolveDeployTarget: index_js_namespaceObject.resolveDeployTarget
|
|
93
37
|
});
|
|
94
38
|
exports["default"] = __webpack_exports__["default"];
|
|
95
39
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -38,15 +38,18 @@ var __webpack_exports__ = {};
|
|
|
38
38
|
__webpack_require__.r(__webpack_exports__);
|
|
39
39
|
__webpack_require__.d(__webpack_exports__, {
|
|
40
40
|
createPresetUltramodernConfig: ()=>createPresetUltramodernConfig,
|
|
41
|
-
presetUltramodern: ()=>presetUltramodern
|
|
41
|
+
presetUltramodern: ()=>presetUltramodern,
|
|
42
|
+
ultramodernReleaseEnvelopePlugin: ()=>ultramodernReleaseEnvelope_js_default()
|
|
42
43
|
});
|
|
43
44
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
44
45
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
45
46
|
const external_node_path_namespaceObject = require("node:path");
|
|
46
47
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
48
|
+
const release_identity_namespaceObject = require("@modern-js/app-tools-extensions/release-identity");
|
|
47
49
|
const cli_namespaceObject = require("@modern-js/plugin/cli");
|
|
48
50
|
const core_namespaceObject = require("@rsbuild/core");
|
|
49
|
-
const
|
|
51
|
+
const ultramodernReleaseEnvelope_js_namespaceObject = require("./plugins/ultramodernReleaseEnvelope.js");
|
|
52
|
+
var ultramodernReleaseEnvelope_js_default = /*#__PURE__*/ __webpack_require__.n(ultramodernReleaseEnvelope_js_namespaceObject);
|
|
50
53
|
const DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318/v1/logs';
|
|
51
54
|
const DEFAULT_VICTORIA_METRICS_ENDPOINT = 'http://127.0.0.1:8428/api/v1/import/prometheus';
|
|
52
55
|
const resolveReactRouterPackageDir = (appDirectory)=>{
|
|
@@ -81,7 +84,7 @@ const setReactRouterBridgeSafeAliases = (chain, { isProd })=>{
|
|
|
81
84
|
const createPresetUltramodernConfig = (options = {})=>{
|
|
82
85
|
const { appId = 'app', deliveryUnit, enableBffRequestId = true, enableTelemetry = true, enableTelemetryExporters, otlpEndpoint = process.env.MODERN_TELEMETRY_OTLP_ENDPOINT, victoriaMetricsEndpoint = process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT, telemetryFailLoudStartup = false, enableModuleFederationSSR = true } = options;
|
|
83
86
|
const server = {};
|
|
84
|
-
const releaseIdentity = deliveryUnit ? (0,
|
|
87
|
+
const releaseIdentity = deliveryUnit ? (0, release_identity_namespaceObject.resolveUltramodernReleaseIdentity)({
|
|
85
88
|
generationBuildMarker: deliveryUnit.buildMarker,
|
|
86
89
|
unitId: deliveryUnit.unitId
|
|
87
90
|
}) : void 0;
|
|
@@ -154,9 +157,11 @@ const presetUltramodern = (config, options = {})=>(0, cli_namespaceObject.mergeC
|
|
|
154
157
|
]);
|
|
155
158
|
exports.createPresetUltramodernConfig = __webpack_exports__.createPresetUltramodernConfig;
|
|
156
159
|
exports.presetUltramodern = __webpack_exports__.presetUltramodern;
|
|
160
|
+
exports.ultramodernReleaseEnvelopePlugin = __webpack_exports__.ultramodernReleaseEnvelopePlugin;
|
|
157
161
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
158
162
|
"createPresetUltramodernConfig",
|
|
159
|
-
"presetUltramodern"
|
|
163
|
+
"presetUltramodern",
|
|
164
|
+
"ultramodernReleaseEnvelopePlugin"
|
|
160
165
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
161
166
|
Object.defineProperty(exports, '__esModule', {
|
|
162
167
|
value: true
|
package/dist/cjs/run/index.js
CHANGED
|
@@ -40,25 +40,25 @@ const loadPlugins_js_namespaceObject = require("../utils/loadPlugins.js");
|
|
|
40
40
|
async function createRunOptions({ cwd, initialLog, metaName = 'modern-js', version, internalPlugins, configFile }) {
|
|
41
41
|
const nodeVersion = process.versions.node;
|
|
42
42
|
const versionArr = nodeVersion.split('.').map(Number);
|
|
43
|
-
if (versionArr[0]
|
|
44
|
-
${utils_namespaceObject.chalk.bgRed.white.bold('
|
|
43
|
+
if (versionArr[0] < 26 || 26 === versionArr[0] && versionArr[1] < 7) throw new Error(`
|
|
44
|
+
${utils_namespaceObject.chalk.bgRed.white.bold(' UNSUPPORTED NODE.JS RUNTIME ')}
|
|
45
45
|
|
|
46
|
-
${utils_namespaceObject.chalk.red.bold(
|
|
47
|
-
${utils_namespaceObject.chalk.red('-
|
|
46
|
+
${utils_namespaceObject.chalk.red.bold(`UltraModern.js requires Node.js >=26.7.0; detected v${nodeVersion}.`)}
|
|
47
|
+
${utils_namespaceObject.chalk.red('- Legacy Node runtimes and TypeScript transpiler fallbacks are unsupported.')}
|
|
48
48
|
|
|
49
49
|
${utils_namespaceObject.chalk.yellow('▸ Detected Runtime:')} ${utils_namespaceObject.chalk.yellow.bold(`Node.js v${nodeVersion}`)}
|
|
50
|
-
${utils_namespaceObject.chalk.green('▸ Required Minimum:')} ${utils_namespaceObject.chalk.green.bold('Node.js
|
|
51
|
-
${utils_namespaceObject.chalk.green('▸
|
|
50
|
+
${utils_namespaceObject.chalk.green('▸ Required Minimum:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.7.0 or higher')}
|
|
51
|
+
${utils_namespaceObject.chalk.green('▸ Pinned Runtime:')} ${utils_namespaceObject.chalk.green.bold('Node.js v26.7.0')}
|
|
52
52
|
|
|
53
53
|
${utils_namespaceObject.chalk.cyan('Immediate Action Required:')}
|
|
54
54
|
${utils_namespaceObject.chalk.gray('├──')} ${utils_namespaceObject.chalk.yellow('Recommended Upgrade')}
|
|
55
|
-
${utils_namespaceObject.chalk.bold('
|
|
55
|
+
${utils_namespaceObject.chalk.bold('mise install && mise exec -- node --version')}
|
|
56
56
|
${utils_namespaceObject.chalk.gray('├──')} ${utils_namespaceObject.chalk.yellow('Manual Installation')}
|
|
57
|
-
${utils_namespaceObject.chalk.underline('https://nodejs.org/download/release/
|
|
57
|
+
${utils_namespaceObject.chalk.underline('https://nodejs.org/download/release/v26.7.0/')}
|
|
58
58
|
${utils_namespaceObject.chalk.gray('└──')} ${utils_namespaceObject.chalk.yellow('Environment Verification')}
|
|
59
59
|
${utils_namespaceObject.chalk.bold('node -v && npm -v')}
|
|
60
60
|
|
|
61
|
-
${utils_namespaceObject.chalk.hex('#AAAAAA').italic('[
|
|
61
|
+
${utils_namespaceObject.chalk.hex('#AAAAAA').italic('[Runtime Policy] Upgrade Node; UltraModern.js intentionally carries no legacy transpiler fallback.')}
|
|
62
62
|
`);
|
|
63
63
|
const command = process.argv[2];
|
|
64
64
|
const cliParams = (0, utils_namespaceObject.minimist)(process.argv.slice(2));
|
|
@@ -91,12 +91,16 @@ const createRuntimePaths = ({ alias, paths, absoluteBaseUrl })=>{
|
|
|
91
91
|
};
|
|
92
92
|
const resolveTsRuntimeRegisterMode = ()=>{
|
|
93
93
|
const hasNativeTypeScriptSupport = process.features?.typescript;
|
|
94
|
-
const
|
|
95
|
-
const supportsNativeTypeScript =
|
|
94
|
+
const nodeVersion = process.versions.node.split('.').map(Number);
|
|
95
|
+
const supportsNativeTypeScript = (nodeVersion[0] > 26 || 26 === nodeVersion[0] && nodeVersion[1] >= 7) && [
|
|
96
|
+
true,
|
|
97
|
+
'strip'
|
|
98
|
+
].includes(hasNativeTypeScriptSupport);
|
|
96
99
|
if (supportsNativeTypeScript) return 'node-loader';
|
|
97
100
|
return 'unsupported';
|
|
98
101
|
};
|
|
99
102
|
const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
|
|
103
|
+
if ('unsupported' === resolveTsRuntimeRegisterMode()) throw new Error(`UltraModern.js requires Node.js >=26.7.0 with native TypeScript support; detected v${process.versions.node}. Legacy TypeScript runtime transpilers are unsupported.`);
|
|
100
104
|
const tsconfigPath = (0, utils_namespaceObject.resolveServerTsconfig)(appDir, options.tsconfigPath);
|
|
101
105
|
const isTsProject = await utils_namespaceObject.fs.pathExists(tsconfigPath);
|
|
102
106
|
if (!isTsProject) return;
|
|
@@ -111,7 +115,6 @@ const setupTsRuntime = async (appDir, distDir, alias, options = {})=>{
|
|
|
111
115
|
paths,
|
|
112
116
|
absoluteBaseUrl
|
|
113
117
|
});
|
|
114
|
-
if ('unsupported' === registerMode) return;
|
|
115
118
|
if ('node-loader' === registerMode) {
|
|
116
119
|
const { registerPathsLoader } = await import("../esm/register-esm.js");
|
|
117
120
|
await registerPathsLoader({
|
|
@@ -2,30 +2,6 @@ import node_fs from "node:fs";
|
|
|
2
2
|
import node_path from "node:path";
|
|
3
3
|
import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/builder";
|
|
4
4
|
import { isProd, isSSR, isServiceWorker, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
|
|
5
|
-
import { CLOUDFLARE_WORKER_NODE_BUILTINS } from "../../plugins/deploy/platforms/cloudflare-output-contract.mjs";
|
|
6
|
-
const BFF_EFFECT_WORKER_ENTRY_NAME = '__modern_bff_effect';
|
|
7
|
-
const BFF_EFFECT_WORKER_RUNTIME_QUERY = 'modern-bff-runtime';
|
|
8
|
-
const MF_SSR_DATA_FETCH_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-inject-data-fetch-function-plugin';
|
|
9
|
-
const MF_SSR_DEV_RUNTIME_PLUGIN = '@module-federation/modern-js-v3/ssr-dev-plugin';
|
|
10
|
-
const JS_OR_TS_EXTS = [
|
|
11
|
-
'.js',
|
|
12
|
-
'.jsx',
|
|
13
|
-
'.ts',
|
|
14
|
-
'.tsx',
|
|
15
|
-
'.mjs',
|
|
16
|
-
'.mts',
|
|
17
|
-
'.cjs',
|
|
18
|
-
'.cts'
|
|
19
|
-
];
|
|
20
|
-
const CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR = node_path.resolve(__dirname, '../../plugins/deploy/platforms/templates');
|
|
21
|
-
function findExistingFile(candidates) {
|
|
22
|
-
return candidates.find((candidate)=>node_fs.existsSync(candidate));
|
|
23
|
-
}
|
|
24
|
-
function resolveJsOrTsEntry(entryWithoutOrWithExt) {
|
|
25
|
-
const extension = node_path.extname(entryWithoutOrWithExt);
|
|
26
|
-
if (JS_OR_TS_EXTS.includes(extension)) return node_fs.existsSync(entryWithoutOrWithExt) ? entryWithoutOrWithExt : void 0;
|
|
27
|
-
return findExistingFile(JS_OR_TS_EXTS.map((extension)=>`${entryWithoutOrWithExt}${extension}`));
|
|
28
|
-
}
|
|
29
5
|
function resolvePackageEntry(packageName, paths) {
|
|
30
6
|
try {
|
|
31
7
|
return node_fs.realpathSync(require.resolve(packageName, {
|
|
@@ -69,94 +45,6 @@ function findPackageRoot(entryFile, packageName) {
|
|
|
69
45
|
function setAliasIfPresent(alias, name, value) {
|
|
70
46
|
if (value) alias.set(name, value);
|
|
71
47
|
}
|
|
72
|
-
function getCloudflareWorkerCompatFile(file) {
|
|
73
|
-
return node_path.join(CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR, file);
|
|
74
|
-
}
|
|
75
|
-
function getCloudflareWorkerNodeExternals() {
|
|
76
|
-
return Object.fromEntries(CLOUDFLARE_WORKER_NODE_BUILTINS.flatMap((builtin)=>{
|
|
77
|
-
const nodeBuiltin = `node:${builtin}`;
|
|
78
|
-
return [
|
|
79
|
-
[
|
|
80
|
-
builtin,
|
|
81
|
-
`module-import ${nodeBuiltin}`
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
nodeBuiltin,
|
|
85
|
-
`module-import ${nodeBuiltin}`
|
|
86
|
-
]
|
|
87
|
-
];
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
const reserveWorkerChunkName = (baseName, reservedOutputNames)=>{
|
|
91
|
-
let name = baseName;
|
|
92
|
-
while(reservedOutputNames.has(normalizeWorkerOutputName(name)))name = `${name}_`;
|
|
93
|
-
return name;
|
|
94
|
-
};
|
|
95
|
-
const normalizeWorkerOutputName = (name)=>node_path.posix.normalize(name.replace(/\\/gu, '/')).toLowerCase();
|
|
96
|
-
function getCloudflareWorkerRspackConfig(workerEntryNames) {
|
|
97
|
-
const entryNames = [
|
|
98
|
-
...workerEntryNames
|
|
99
|
-
];
|
|
100
|
-
for (const entryName of entryNames){
|
|
101
|
-
const slashName = entryName.replace(/\\/gu, '/');
|
|
102
|
-
const normalizedName = node_path.posix.normalize(slashName);
|
|
103
|
-
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.`);
|
|
104
|
-
}
|
|
105
|
-
const reservedNames = new Set(entryNames.map(normalizeWorkerOutputName));
|
|
106
|
-
const runtimeName = reserveWorkerChunkName('__modern_worker_runtime', reservedNames);
|
|
107
|
-
reservedNames.add(normalizeWorkerOutputName(runtimeName));
|
|
108
|
-
const sharedName = reserveWorkerChunkName('__modern_worker_shared', reservedNames);
|
|
109
|
-
return {
|
|
110
|
-
experiments: {
|
|
111
|
-
outputModule: true
|
|
112
|
-
},
|
|
113
|
-
externals: getCloudflareWorkerNodeExternals(),
|
|
114
|
-
externalsType: 'module-import',
|
|
115
|
-
module: {
|
|
116
|
-
parser: {
|
|
117
|
-
javascript: {
|
|
118
|
-
dynamicImportMode: 'eager'
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
optimization: {
|
|
123
|
-
runtimeChunk: {
|
|
124
|
-
name: runtimeName
|
|
125
|
-
},
|
|
126
|
-
splitChunks: {
|
|
127
|
-
chunks: 'all',
|
|
128
|
-
minSize: 0,
|
|
129
|
-
name: sharedName
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function applyCloudflareWorkerRspackConfig(chain, workerEntryNames) {
|
|
135
|
-
const config = getCloudflareWorkerRspackConfig(workerEntryNames);
|
|
136
|
-
chain.experiments(config.experiments);
|
|
137
|
-
chain.externals(config.externals);
|
|
138
|
-
chain.externalsType(config.externalsType);
|
|
139
|
-
chain.module.parser.merge(config.module.parser);
|
|
140
|
-
chain.optimization.runtimeChunk(config.optimization.runtimeChunk);
|
|
141
|
-
chain.optimization.splitChunks(config.optimization.splitChunks);
|
|
142
|
-
}
|
|
143
|
-
function applyCloudflareWorkerMfRuntimeBoundary(chain) {
|
|
144
|
-
chain.plugins.delete('plugin-module-federation');
|
|
145
|
-
chain.resolve.alias.set(`${MF_SSR_DATA_FETCH_RUNTIME_PLUGIN}$`, getCloudflareWorkerCompatFile('cloudflare-worker-mf-ssr-runtime-plugin.mjs'));
|
|
146
|
-
chain.resolve.alias.set(`${MF_SSR_DEV_RUNTIME_PLUGIN}$`, getCloudflareWorkerCompatFile('cloudflare-worker-mf-ssr-runtime-plugin.mjs'));
|
|
147
|
-
}
|
|
148
|
-
function getEffectBffEntry(normalizedConfig, appContext) {
|
|
149
|
-
if (!normalizedConfig.bff || 'hono' === normalizedConfig.bff.runtimeFramework) return;
|
|
150
|
-
const configuredEntry = normalizedConfig.bff.effect?.entry;
|
|
151
|
-
if (configuredEntry) {
|
|
152
|
-
const entryWithoutOrWithExtension = node_path.isAbsolute(configuredEntry) ? configuredEntry : node_path.resolve(appContext.appDirectory, configuredEntry);
|
|
153
|
-
return resolveJsOrTsEntry(entryWithoutOrWithExtension);
|
|
154
|
-
}
|
|
155
|
-
return resolveJsOrTsEntry(node_path.resolve(appContext.apiDirectory, 'index'));
|
|
156
|
-
}
|
|
157
|
-
function isCloudflareWorkerDeploy(normalizedConfig) {
|
|
158
|
-
return normalizedConfig.deploy?.target === 'cloudflare' || 'cloudflare' === process.env.MODERNJS_DEPLOY;
|
|
159
|
-
}
|
|
160
48
|
function getConsumingReactRuntimeAliases(appContext) {
|
|
161
49
|
const resolvePaths = [
|
|
162
50
|
appContext.appDirectory,
|
|
@@ -210,11 +98,6 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
210
98
|
const v = entries[entry];
|
|
211
99
|
serverEntries[entry] = v.map((entry)=>entry.replace('index.jsx', 'index.server.jsx')).map((entry)=>entry.replace('bootstrap.jsx', 'bootstrap.server.jsx'));
|
|
212
100
|
}
|
|
213
|
-
const cloudflareWorkerServerEntries = {};
|
|
214
|
-
for(const entry in entries){
|
|
215
|
-
const v = entries[entry];
|
|
216
|
-
cloudflareWorkerServerEntries[entry] = v.map((entry)=>entry.replace('index.jsx', 'index.server.jsx')).map((entry)=>entry.replace('bootstrap.jsx', 'index.server.jsx'));
|
|
217
|
-
}
|
|
218
101
|
const environments = {
|
|
219
102
|
client: {
|
|
220
103
|
output: {
|
|
@@ -239,122 +122,20 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
|
|
|
239
122
|
}
|
|
240
123
|
};
|
|
241
124
|
const useWorkerTarget = isServiceWorker(normalizedConfig);
|
|
242
|
-
if (useWorkerTarget) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const renderRscWorkerFile = useCloudflareModuleWorker ? resolvePackageFile('@modern-js/render', 'dist/esm/rscWorker.mjs', [
|
|
254
|
-
appContext.appDirectory,
|
|
255
|
-
process.cwd()
|
|
256
|
-
]) : void 0;
|
|
257
|
-
const reactFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'index.js', [
|
|
258
|
-
appContext.appDirectory,
|
|
259
|
-
process.cwd()
|
|
260
|
-
]) : void 0;
|
|
261
|
-
const reactJsxRuntimeFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'jsx-runtime.js', [
|
|
262
|
-
appContext.appDirectory,
|
|
263
|
-
process.cwd()
|
|
264
|
-
]) : void 0;
|
|
265
|
-
const reactJsxDevRuntimeFile = useCloudflareModuleWorker ? resolvePackageFile('react', 'jsx-dev-runtime.js', [
|
|
266
|
-
appContext.appDirectory,
|
|
267
|
-
process.cwd()
|
|
268
|
-
]) : void 0;
|
|
269
|
-
const reactDomFile = useCloudflareModuleWorker ? resolvePackageFile('react-dom', 'index.js', [
|
|
270
|
-
appContext.appDirectory,
|
|
271
|
-
process.cwd()
|
|
272
|
-
]) : void 0;
|
|
273
|
-
const reactDomServerEdgeFile = useCloudflareModuleWorker ? resolvePackageFile('react-dom', 'server.edge.js', [
|
|
274
|
-
appContext.appDirectory,
|
|
275
|
-
process.cwd()
|
|
276
|
-
]) : void 0;
|
|
277
|
-
const loadableComponentFile = useCloudflareModuleWorker ? resolvePackageFile('@loadable/component', 'dist/esm/loadable.esm.mjs', [
|
|
278
|
-
appContext.appDirectory,
|
|
279
|
-
process.cwd(),
|
|
280
|
-
CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR
|
|
281
|
-
]) : void 0;
|
|
282
|
-
const loadableServerWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-loadable-server.mjs') : void 0;
|
|
283
|
-
const fsPromisesWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-fs-promises.mjs') : void 0;
|
|
284
|
-
const pathWorkerFile = useCloudflareModuleWorker ? getCloudflareWorkerCompatFile('cloudflare-worker-path.mjs') : void 0;
|
|
285
|
-
const baseWorkerEntries = useCloudflareModuleWorker ? cloudflareWorkerServerEntries : serverEntries;
|
|
286
|
-
const workerEntries = effectApiEntry ? {
|
|
287
|
-
...baseWorkerEntries,
|
|
288
|
-
[BFF_EFFECT_WORKER_ENTRY_NAME]: [
|
|
289
|
-
`${effectApiEntry}?${BFF_EFFECT_WORKER_RUNTIME_QUERY}`
|
|
290
|
-
]
|
|
291
|
-
} : baseWorkerEntries;
|
|
292
|
-
environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
293
|
-
output: {
|
|
294
|
-
target: useCloudflareModuleWorker ? 'web' : 'web-worker',
|
|
295
|
-
...useCloudflareModuleWorker ? {
|
|
296
|
-
module: true
|
|
297
|
-
} : {}
|
|
298
|
-
},
|
|
299
|
-
source: {
|
|
300
|
-
entry: workerEntries
|
|
301
|
-
},
|
|
302
|
-
tools: {
|
|
303
|
-
htmlPlugin: false,
|
|
304
|
-
...useCloudflareModuleWorker ? {
|
|
305
|
-
bundlerChain: (chain)=>{
|
|
306
|
-
applyCloudflareWorkerRspackConfig(chain, Object.keys(workerEntries));
|
|
307
|
-
chain.output.module(true).library({
|
|
308
|
-
type: 'module'
|
|
309
|
-
}).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
310
|
-
for (const condition of [
|
|
311
|
-
'workerd',
|
|
312
|
-
'worker',
|
|
313
|
-
'webpack',
|
|
314
|
-
isProd() ? 'production' : 'development',
|
|
315
|
-
'import',
|
|
316
|
-
'require',
|
|
317
|
-
'module'
|
|
318
|
-
])chain.resolve.conditionNames.add(condition);
|
|
319
|
-
applyCloudflareWorkerMfRuntimeBoundary(chain);
|
|
320
|
-
if (tanstackRouterSsrServerFile) {
|
|
321
|
-
chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
|
|
322
|
-
chain.resolve.alias.set('@tanstack/router-core/ssr/server', tanstackRouterSsrServerFile);
|
|
323
|
-
}
|
|
324
|
-
if (runtimeRscWorkerFile) {
|
|
325
|
-
chain.resolve.alias.set('@modern-js/runtime/rsc/server$', runtimeRscWorkerFile);
|
|
326
|
-
chain.resolve.alias.set('@modern-js/runtime/rsc/server', runtimeRscWorkerFile);
|
|
327
|
-
}
|
|
328
|
-
if (renderRscWorkerFile) {
|
|
329
|
-
chain.resolve.alias.set('@modern-js/render/rsc$', renderRscWorkerFile);
|
|
330
|
-
chain.resolve.alias.set('@modern-js/render/rsc', renderRscWorkerFile);
|
|
331
|
-
chain.resolve.alias.set('@modern-js/render/rsc-worker$', renderRscWorkerFile);
|
|
332
|
-
}
|
|
333
|
-
setAliasIfPresent(chain.resolve.alias, 'react$', reactFile);
|
|
334
|
-
setAliasIfPresent(chain.resolve.alias, 'react/jsx-runtime$', reactJsxRuntimeFile);
|
|
335
|
-
setAliasIfPresent(chain.resolve.alias, 'react/jsx-dev-runtime$', reactJsxDevRuntimeFile);
|
|
336
|
-
setAliasIfPresent(chain.resolve.alias, 'react-dom$', reactDomFile);
|
|
337
|
-
setAliasIfPresent(chain.resolve.alias, 'react-dom/server.edge$', reactDomServerEdgeFile);
|
|
338
|
-
setAliasIfPresent(chain.resolve.alias, '@loadable/component$', loadableComponentFile);
|
|
339
|
-
setAliasIfPresent(chain.resolve.alias, '@loadable/server$', loadableServerWorkerFile);
|
|
340
|
-
setAliasIfPresent(chain.resolve.alias, 'fs/promises$', fsPromisesWorkerFile);
|
|
341
|
-
setAliasIfPresent(chain.resolve.alias, 'node:fs/promises$', fsPromisesWorkerFile);
|
|
342
|
-
setAliasIfPresent(chain.resolve.alias, 'path$', pathWorkerFile);
|
|
343
|
-
setAliasIfPresent(chain.resolve.alias, 'node:path$', pathWorkerFile);
|
|
344
|
-
chain.resolve.alias.set('react-server-dom-rspack/server.node$', 'react-server-dom-rspack/server.edge');
|
|
345
|
-
chain.resolve.alias.set('react-server-dom-rspack/server.node', 'react-server-dom-rspack/server.edge');
|
|
346
|
-
chain.resolve.alias.set('react-server-dom-rspack/client.node$', 'react-server-dom-rspack/client.edge');
|
|
347
|
-
chain.resolve.alias.set('react-server-dom-rspack/client.node', 'react-server-dom-rspack/client.edge');
|
|
348
|
-
chain.resolve.fallback.set('fs', false);
|
|
349
|
-
chain.resolve.fallback.set('node:fs', false);
|
|
350
|
-
}
|
|
351
|
-
} : {}
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
125
|
+
if (useWorkerTarget) environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
126
|
+
output: {
|
|
127
|
+
target: 'web-worker'
|
|
128
|
+
},
|
|
129
|
+
source: {
|
|
130
|
+
entry: serverEntries
|
|
131
|
+
},
|
|
132
|
+
tools: {
|
|
133
|
+
htmlPlugin: false
|
|
134
|
+
}
|
|
135
|
+
};
|
|
355
136
|
return {
|
|
356
137
|
environments,
|
|
357
138
|
builderConfig: tempBuilderConfig
|
|
358
139
|
};
|
|
359
140
|
}
|
|
360
|
-
export {
|
|
141
|
+
export { getBuilderEnvironments };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBuilder } from "@modern-js/builder";
|
|
2
2
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
3
|
-
import { builderPluginAdapterBasic, builderPluginAdapterHooks, builderPluginAdapterHtml,
|
|
3
|
+
import { builderPluginAdapterBasic, builderPluginAdapterHooks, builderPluginAdapterHtml, builderPluginAdapterPrecompress, builderPluginAdapterSSR } from "../shared/builderPlugins/index.mjs";
|
|
4
4
|
import { builderPluginAdapterCopy } from "./adapterCopy.mjs";
|
|
5
5
|
import { createBuilderProviderConfig } from "./createBuilderProviderConfig.mjs";
|
|
6
6
|
import { getBuilderEnvironments } from "./getBuilderEnvironments.mjs";
|
|
@@ -38,7 +38,6 @@ async function generateBuilder(options, bundlerType) {
|
|
|
38
38
|
async function applyBuilderPlugins(builder, options) {
|
|
39
39
|
builder.addPlugins([
|
|
40
40
|
builderPluginAdapterBasic(options),
|
|
41
|
-
builderPluginAdapterLazyCompilation(options),
|
|
42
41
|
builderPluginAdapterSSR(options),
|
|
43
42
|
builderPluginAdapterHtml(options),
|
|
44
43
|
builderPluginAdapterPrecompress(options),
|