@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.17 → 3.2.0-ultramodern.22

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.
@@ -1,5 +1,6 @@
1
1
  import "node:module";
2
2
  import { provider } from "std-env";
3
+ import { createCloudflarePreset } from "./platforms/cloudflare.mjs";
3
4
  import { createGhPagesPreset } from "./platforms/gh-pages.mjs";
4
5
  import { createNetlifyPreset } from "./platforms/netlify.mjs";
5
6
  import { createNodePreset } from "./platforms/node.mjs";
@@ -9,14 +10,18 @@ const deployPresets = {
9
10
  node: createNodePreset,
10
11
  vercel: createVercelPreset,
11
12
  netlify: createNetlifyPreset,
12
- ghPages: createGhPagesPreset
13
+ ghPages: createGhPagesPreset,
14
+ cloudflare: createCloudflarePreset
13
15
  };
16
+ const getSupportedDeployTargets = ()=>Object.keys(deployPresets);
17
+ const isDeployTarget = (target)=>Object.prototype.hasOwnProperty.call(deployPresets, target);
18
+ const resolveDeployTarget = (modernConfig, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = provider)=>modernConfig.deploy?.target || envDeployTarget || detectedProvider || 'node';
14
19
  async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
15
20
  const { appDirectory, distDirectory, metaName } = appContext;
16
21
  const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory, metaName);
17
22
  const needModernServer = useSSR || useAPI || useWebServer;
23
+ if (!isDeployTarget(deployTarget)) throw new Error(`Unknown deploy target: '${deployTarget}'. deploy.target or MODERNJS_DEPLOY should be one of: ${getSupportedDeployTargets().join(', ')}.`);
18
24
  const createPreset = deployPresets[deployTarget];
19
- if (!createPreset) throw new Error(`Unknown deploy target: '${deployTarget}'. MODERNJS_DEPLOY should be 'node', 'vercel', or 'netlify'.`);
20
25
  return createPreset({
21
26
  appContext,
22
27
  modernConfig,
@@ -27,12 +32,12 @@ async function getDeployPreset(appContext, modernConfig, deployTarget, api) {
27
32
  const deploy = ()=>({
28
33
  name: '@modern-js/plugin-deploy',
29
34
  setup: (api)=>{
30
- const deployTarget = process.env.MODERNJS_DEPLOY || provider || 'node';
31
35
  api.deploy(async ()=>{
32
36
  const appContext = api.getAppContext();
33
37
  const { metaName } = appContext;
34
- if ('modern-js' !== metaName && !process.env.MODERNJS_DEPLOY) return;
35
38
  const modernConfig = api.getNormalizedConfig();
39
+ const deployTarget = resolveDeployTarget(modernConfig);
40
+ if ('modern-js' !== metaName && !modernConfig.deploy?.target && !process.env.MODERNJS_DEPLOY) return;
36
41
  const deployPreset = await getDeployPreset(appContext, modernConfig, deployTarget, api);
37
42
  deployPreset?.prepare && await deployPreset?.prepare();
38
43
  deployPreset?.writeOutput && await deployPreset?.writeOutput();
@@ -42,3 +47,4 @@ const deploy = ()=>({
42
47
  }
43
48
  });
44
49
  export default deploy;
50
+ export { getSupportedDeployTargets, resolveDeployTarget };
@@ -0,0 +1,185 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { fs } from "@modern-js/utils";
4
+ import { readTemplate } from "../utils/index.mjs";
5
+ const WORKER_ENTRY = 'server/index.mjs';
6
+ const WORKER_MANIFEST = 'server/modern-worker-manifest.json';
7
+ const ASSETS_BINDING = 'ASSETS';
8
+ const ROUTE_SPEC_FILE = 'route.json';
9
+ const ROUTE_SPEC_OUTPUT = `server/${ROUTE_SPEC_FILE}`;
10
+ const LOADABLE_STATS_FILE = 'loadable-stats.json';
11
+ const ROUTE_MANIFEST_FILE = 'routes-manifest.json';
12
+ const PUBLIC_ASSETS_DIRECTORY = 'public';
13
+ const WORKER_BUNDLE_DIRECTORY = 'worker';
14
+ const SERVER_BUNDLE_DIRECTORY = 'bundles';
15
+ const BFF_EFFECT_WORKER_ENTRY = `${WORKER_BUNDLE_DIRECTORY}/__modern_bff_effect.js`;
16
+ const getCompatibilityDate = ()=>new Date().toISOString().slice(0, 10);
17
+ const getWorkerName = (appDirectory)=>{
18
+ const basename = node_path.basename(appDirectory);
19
+ return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
20
+ };
21
+ const readRouteSpec = async (outputDirectory)=>{
22
+ const routeSpecPath = node_path.join(outputDirectory, ROUTE_SPEC_OUTPUT);
23
+ if (!await fs.pathExists(routeSpecPath)) return {
24
+ routes: []
25
+ };
26
+ const routeSpec = await fs.readJSON(routeSpecPath);
27
+ return {
28
+ ...routeSpec,
29
+ routes: Array.isArray(routeSpec.routes) ? routeSpec.routes : []
30
+ };
31
+ };
32
+ const createWorkerManifest = async (outputDirectory, modernConfig)=>{
33
+ const routeSpec = await readRouteSpec(outputDirectory);
34
+ const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
35
+ const worker = 'string' == typeof route.worker ? route.worker : void 0;
36
+ return {
37
+ urlPath: route.urlPath,
38
+ entryName: route.entryName,
39
+ entryPath: route.entryPath,
40
+ isSSR: Boolean(route.isSSR),
41
+ worker,
42
+ bundle: 'string' == typeof route.bundle ? route.bundle : void 0,
43
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false,
44
+ bundleExists: 'string' == typeof route.bundle ? await fs.pathExists(node_path.join(outputDirectory, route.bundle)) : false
45
+ };
46
+ }));
47
+ const bffPrefix = modernConfig.bff?.prefix;
48
+ const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
49
+ const isEffectBff = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
50
+ const effectBffWorkerExists = await fs.pathExists(node_path.join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
51
+ return {
52
+ version: 1,
53
+ runtime: {
54
+ type: 'cloudflare-module-worker',
55
+ entry: WORKER_ENTRY,
56
+ fetchExport: true,
57
+ nodeListen: false
58
+ },
59
+ assets: {
60
+ binding: ASSETS_BINDING,
61
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`
62
+ },
63
+ routeSpec: {
64
+ file: ROUTE_SPEC_OUTPUT,
65
+ routes
66
+ },
67
+ workerBundles: {
68
+ directory: WORKER_BUNDLE_DIRECTORY,
69
+ format: 'esm',
70
+ importableFromModuleWorker: true,
71
+ requestHandlerExport: 'requestHandler'
72
+ },
73
+ resources: {
74
+ loadableStats: LOADABLE_STATS_FILE,
75
+ routeManifest: ROUTE_MANIFEST_FILE
76
+ },
77
+ bff: isEffectBff && primaryBffPrefix && effectBffWorkerExists ? {
78
+ runtimeFramework: 'effect',
79
+ prefix: primaryBffPrefix,
80
+ worker: BFF_EFFECT_WORKER_ENTRY
81
+ } : void 0
82
+ };
83
+ };
84
+ const createWorkerModuleLoaders = (manifest)=>{
85
+ const imports = new Map();
86
+ for (const route of manifest.routeSpec.routes){
87
+ if (route.worker && route.workerExists) {
88
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
89
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
90
+ }
91
+ if (route.bundle && route.bundleExists) {
92
+ const importPath = `../${String(route.bundle).replace(/^\/+/u, '')}`;
93
+ imports.set(route.bundle, `() => import(${JSON.stringify(importPath)})`);
94
+ }
95
+ }
96
+ if (manifest.bff?.worker) {
97
+ const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
98
+ imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
99
+ }
100
+ if (0 === imports.size) return '{}';
101
+ const loaders = [
102
+ ...imports.entries()
103
+ ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
104
+ return `{\n${loaders.join(',\n')}\n}`;
105
+ };
106
+ const shouldCopyToPublicAssets = (src, distDirectory)=>{
107
+ const relativePath = node_path.relative(distDirectory, src);
108
+ if (!relativePath) return true;
109
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
110
+ const [topLevelDirectory] = normalizedRelativePath.split('/');
111
+ return normalizedRelativePath !== ROUTE_SPEC_FILE && topLevelDirectory !== WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== SERVER_BUNDLE_DIRECTORY;
112
+ };
113
+ const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
114
+ const relativePath = node_path.relative(workerBundleDirectory, src);
115
+ if (!relativePath) return true;
116
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
117
+ const basename = node_path.basename(normalizedRelativePath);
118
+ if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
119
+ return [
120
+ '.cjs',
121
+ '.js',
122
+ '.mjs'
123
+ ].includes(node_path.extname(normalizedRelativePath));
124
+ };
125
+ const createCloudflarePreset = ({ appContext, modernConfig })=>{
126
+ const { appDirectory, distDirectory } = appContext;
127
+ const outputDirectory = node_path.join(appDirectory, '.output');
128
+ const publicDirectory = node_path.join(outputDirectory, PUBLIC_ASSETS_DIRECTORY);
129
+ const workerEntryPath = node_path.join(outputDirectory, WORKER_ENTRY);
130
+ const workerManifestPath = node_path.join(outputDirectory, WORKER_MANIFEST);
131
+ const routeSpecOutputPath = node_path.join(outputDirectory, ROUTE_SPEC_OUTPUT);
132
+ const wranglerConfigPath = node_path.join(outputDirectory, 'wrangler.json');
133
+ return {
134
+ async prepare () {
135
+ await fs.remove(outputDirectory);
136
+ },
137
+ async writeOutput () {
138
+ await fs.copy(distDirectory, publicDirectory, {
139
+ filter: (src)=>shouldCopyToPublicAssets(src, distDirectory)
140
+ });
141
+ await fs.ensureDir(node_path.dirname(workerEntryPath));
142
+ await fs.ensureDir(node_path.dirname(workerManifestPath));
143
+ const routeSpecSourcePath = node_path.join(distDirectory, ROUTE_SPEC_FILE);
144
+ if (await fs.pathExists(routeSpecSourcePath)) await fs.copy(routeSpecSourcePath, routeSpecOutputPath);
145
+ const workerBundleSourceDirectory = node_path.join(distDirectory, WORKER_BUNDLE_DIRECTORY);
146
+ if (await fs.pathExists(workerBundleSourceDirectory)) await fs.copy(workerBundleSourceDirectory, node_path.join(outputDirectory, WORKER_BUNDLE_DIRECTORY), {
147
+ filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
148
+ });
149
+ const serverBundleSourceDirectory = node_path.join(distDirectory, SERVER_BUNDLE_DIRECTORY);
150
+ if (await fs.pathExists(serverBundleSourceDirectory)) {
151
+ await fs.copy(serverBundleSourceDirectory, node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY));
152
+ await fs.writeJSON(node_path.join(outputDirectory, SERVER_BUNDLE_DIRECTORY, 'package.json'), {
153
+ type: 'commonjs'
154
+ });
155
+ }
156
+ await fs.writeJSON(wranglerConfigPath, {
157
+ $schema: 'node_modules/wrangler/config-schema.json',
158
+ name: getWorkerName(appDirectory),
159
+ main: WORKER_ENTRY,
160
+ compatibility_date: getCompatibilityDate(),
161
+ compatibility_flags: [
162
+ 'nodejs_compat'
163
+ ],
164
+ assets: {
165
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
166
+ binding: ASSETS_BINDING
167
+ }
168
+ }, {
169
+ spaces: 2
170
+ });
171
+ await fs.writeJSON(workerManifestPath, await createWorkerManifest(outputDirectory, modernConfig), {
172
+ spaces: 2
173
+ });
174
+ await fs.writeJSON(node_path.join(outputDirectory, 'package.json'), {
175
+ type: 'module'
176
+ });
177
+ },
178
+ async genEntry () {
179
+ const template = await readTemplate('cloudflare-entry.mjs');
180
+ const manifest = await fs.readJSON(workerManifestPath);
181
+ await fs.writeFile(workerEntryPath, template.replace('p_workerManifest', JSON.stringify(manifest, null, 2)).replace('p_workerModuleLoaders', createWorkerModuleLoaders(manifest)));
182
+ }
183
+ };
184
+ };
185
+ export { createCloudflarePreset };
@@ -0,0 +1,227 @@
1
+ const ASSETS_BINDING = 'ASSETS';
2
+ const MODERN_WORKER_MANIFEST = p_workerManifest;
3
+ const WORKER_MODULE_LOADERS = p_workerModuleLoaders;
4
+ const workerModulePromises = new Map();
5
+ globalThis.__dirname ??= '/';
6
+ globalThis.__filename ??= '/index.js';
7
+ async function fetchAsset(request, env) {
8
+ const assets = env?.[ASSETS_BINDING];
9
+ if (!assets || 'function' != typeof assets.fetch) return null;
10
+ const response = await assets.fetch(request);
11
+ if (404 === response.status) return null;
12
+ return response;
13
+ }
14
+ async function fetchAssetByPath(pathname, request, env) {
15
+ const url = new URL(request.url);
16
+ url.pathname = `/${pathname.replace(/^\/+/u, '')}`;
17
+ return fetchAsset(new Request(url, request), env);
18
+ }
19
+ async function readAssetText(pathname, request, env) {
20
+ const response = await fetchAssetByPath(pathname, request, env);
21
+ if (!response || !response.ok) return;
22
+ return response.text();
23
+ }
24
+ async function readAssetJson(pathname, request, env) {
25
+ const text = await readAssetText(pathname, request, env);
26
+ if (!text) return {};
27
+ return JSON.parse(text);
28
+ }
29
+ function normalizeRoutePath(pathname) {
30
+ if ('/' === pathname) return pathname;
31
+ return pathname.replace(/\/+$/u, '');
32
+ }
33
+ function routeMatches(route, pathname) {
34
+ if ('string' != typeof route.urlPath) return false;
35
+ const routePath = normalizeRoutePath(route.urlPath);
36
+ const requestPath = normalizeRoutePath(pathname);
37
+ return routePath === requestPath || '/' === routePath && route.isSSR || requestPath.startsWith(`${routePath}/`);
38
+ }
39
+ function findRoute(request) {
40
+ const { pathname } = new URL(request.url);
41
+ const routes = MODERN_WORKER_MANIFEST.routeSpec.routes;
42
+ return [
43
+ ...routes
44
+ ].sort((left, right)=>{
45
+ const leftLength = left.urlPath?.length || 0;
46
+ const rightLength = right.urlPath?.length || 0;
47
+ return rightLength - leftLength;
48
+ }).find((route)=>routeMatches(route, pathname));
49
+ }
50
+ async function fetchRouteHtml(route, request, env) {
51
+ if (!route?.entryPath) return null;
52
+ return fetchAssetByPath(route.entryPath, request, env);
53
+ }
54
+ function createNoopMonitors() {
55
+ const noop = ()=>{};
56
+ return {
57
+ debug: noop,
58
+ error: noop,
59
+ info: noop,
60
+ warn: noop
61
+ };
62
+ }
63
+ function createRequestHandlerOptions({ route, htmlTemplate, routeManifest, loadableStats }) {
64
+ const monitors = createNoopMonitors();
65
+ return {
66
+ resource: {
67
+ route,
68
+ routeManifest,
69
+ loadableStats,
70
+ htmlTemplate,
71
+ entryName: route.entryName
72
+ },
73
+ params: {},
74
+ loaderContext: {},
75
+ config: {},
76
+ locals: {},
77
+ staticGenerate: false,
78
+ monitors,
79
+ onError (error) {
80
+ monitors.error(error);
81
+ },
82
+ onTiming () {},
83
+ reporter: {
84
+ reportTiming: ()=>{}
85
+ }
86
+ };
87
+ }
88
+ async function getRequestHandlerOptions(route, request, env) {
89
+ const [htmlTemplate, routeManifest, loadableStats] = await Promise.all([
90
+ readAssetText(route.entryPath, request, env),
91
+ readAssetJson(MODERN_WORKER_MANIFEST.resources.routeManifest, request, env),
92
+ readAssetJson(MODERN_WORKER_MANIFEST.resources.loadableStats, request, env)
93
+ ]);
94
+ return createRequestHandlerOptions({
95
+ route,
96
+ htmlTemplate: htmlTemplate || '',
97
+ routeManifest,
98
+ loadableStats
99
+ });
100
+ }
101
+ async function loadWorkerModule(workerPath) {
102
+ const loader = WORKER_MODULE_LOADERS[workerPath];
103
+ if (!loader) return;
104
+ if (!workerModulePromises.has(workerPath)) workerModulePromises.set(workerPath, loader());
105
+ return workerModulePromises.get(workerPath);
106
+ }
107
+ function getFetchHandler(workerModule) {
108
+ const defaultExport = workerModule.default;
109
+ return defaultExport && 'object' == typeof defaultExport && 'function' == typeof defaultExport.fetch && defaultExport.fetch.bind(defaultExport) || 'function' == typeof workerModule.fetch && workerModule.fetch;
110
+ }
111
+ async function getRequestHandler(workerModule) {
112
+ const defaultExport = workerModule.default;
113
+ const defaultRequestHandler = defaultExport && 'object' == typeof defaultExport && 'requestHandler' in defaultExport ? defaultExport.requestHandler : void 0;
114
+ return await workerModule.requestHandler || await defaultRequestHandler || ('function' == typeof defaultExport ? defaultExport : void 0);
115
+ }
116
+ async function dispatchRouteWorker(route, request, env, ctx) {
117
+ const candidatePaths = [
118
+ route.worker,
119
+ route.bundle
120
+ ].filter(Boolean);
121
+ let missingPath;
122
+ for (const candidatePath of candidatePaths){
123
+ const workerModule = await loadWorkerModule(candidatePath);
124
+ if (!workerModule) {
125
+ missingPath = candidatePath;
126
+ continue;
127
+ }
128
+ const fetchHandler = getFetchHandler(workerModule);
129
+ if (fetchHandler) return fetchHandler(request, env, ctx);
130
+ const requestHandler = await getRequestHandler(workerModule);
131
+ if ('function' == typeof requestHandler) {
132
+ const requestHandlerOptions = await getRequestHandlerOptions(route, request, env);
133
+ return requestHandler(request, requestHandlerOptions);
134
+ }
135
+ }
136
+ if (missingPath) return new Response(`Worker bundle not found: ${missingPath}`, {
137
+ status: 500,
138
+ headers: {
139
+ 'content-type': 'text/plain; charset=utf-8',
140
+ 'x-modern-js-route-worker': missingPath
141
+ }
142
+ });
143
+ if (candidatePaths.length > 0) return new Response(`Worker bundle has no fetch or requestHandler export: ${candidatePaths.join(', ')}`, {
144
+ status: 500,
145
+ headers: {
146
+ 'content-type': 'text/plain; charset=utf-8',
147
+ 'x-modern-js-route-worker': candidatePaths.join(', ')
148
+ }
149
+ });
150
+ return new Response('Route has no worker bundle', {
151
+ status: 500
152
+ });
153
+ }
154
+ function matchesPrefix(pathname, prefix) {
155
+ if (!prefix || '/' === prefix) return true;
156
+ const normalized = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
157
+ return pathname === normalized || pathname.startsWith(`${normalized}/`);
158
+ }
159
+ function createRequestForMountedPrefix(request, prefix) {
160
+ if (!prefix || '/' === prefix) return request;
161
+ const url = new URL(request.url);
162
+ const normalized = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
163
+ if (!matchesPrefix(url.pathname, normalized)) return request;
164
+ const nextPath = url.pathname.slice(normalized.length) || '/';
165
+ url.pathname = nextPath.startsWith('/') ? nextPath : `/${nextPath}`;
166
+ return new Request(url, request);
167
+ }
168
+ function createEffectContext(originalRequest, mountedRequest, env) {
169
+ const url = new URL(originalRequest.url);
170
+ return {
171
+ request: mountedRequest,
172
+ env: env || {},
173
+ path: url.pathname,
174
+ method: originalRequest.method,
175
+ operationContext: {
176
+ request: mountedRequest,
177
+ env: env || {},
178
+ path: url.pathname,
179
+ method: originalRequest.method
180
+ }
181
+ };
182
+ }
183
+ async function dispatchBffRequest(request, env) {
184
+ const bff = MODERN_WORKER_MANIFEST.bff;
185
+ if (!bff?.worker || !matchesPrefix(new URL(request.url).pathname, bff.prefix)) return null;
186
+ const workerModule = await loadWorkerModule(bff.worker);
187
+ if (!workerModule) return new Response(`BFF worker bundle not found: ${bff.worker}`, {
188
+ status: 500,
189
+ headers: {
190
+ 'content-type': 'text/plain; charset=utf-8',
191
+ 'x-modern-js-bff-worker': bff.worker
192
+ }
193
+ });
194
+ const mountedRequest = createRequestForMountedPrefix(request, bff.prefix);
195
+ const effectContext = createEffectContext(request, mountedRequest, env);
196
+ const defaultExport = workerModule.default;
197
+ const runtime = defaultExport && 'object' == typeof defaultExport ? {
198
+ ...workerModule,
199
+ ...defaultExport
200
+ } : workerModule;
201
+ const directHandler = 'function' == typeof runtime.handler && runtime.handler || 'function' == typeof defaultExport && defaultExport;
202
+ const createdHandler = 'function' == typeof runtime.createHandler ? runtime.createHandler().handler : void 0;
203
+ const handler = directHandler || createdHandler;
204
+ if ('function' != typeof handler) return new Response(`BFF worker bundle has no handler export: ${bff.worker}`, {
205
+ status: 500,
206
+ headers: {
207
+ 'content-type': 'text/plain; charset=utf-8',
208
+ 'x-modern-js-bff-worker': bff.worker
209
+ }
210
+ });
211
+ return handler.length > 1 ? handler(mountedRequest, effectContext) : handler(mountedRequest);
212
+ }
213
+ export default {
214
+ async fetch (request, env, ctx) {
215
+ const assetResponse = await fetchAsset(request, env);
216
+ if (assetResponse) return assetResponse;
217
+ const bffResponse = await dispatchBffRequest(request, env);
218
+ if (bffResponse) return bffResponse;
219
+ const route = findRoute(request);
220
+ if (route?.worker) return dispatchRouteWorker(route, request, env, ctx);
221
+ const htmlResponse = await fetchRouteHtml(route, request, env);
222
+ if (htmlResponse) return htmlResponse;
223
+ return new Response('Not found', {
224
+ status: 404
225
+ });
226
+ }
227
+ };
@@ -8,12 +8,12 @@ import { loadInternalPlugins } from "./utils/loadPlugins.mjs";
8
8
  import { __webpack_require__ } from "./rslib-runtime.mjs";
9
9
  import * as __rspack_external__modern_js_plugin_cli_caa09fa2 from "@modern-js/plugin/cli";
10
10
  __webpack_require__.add({
11
- "@modern-js/plugin/cli?f956" (module) {
11
+ "@modern-js/plugin/cli?8936" (module) {
12
12
  module.exports = __rspack_external__modern_js_plugin_cli_caa09fa2;
13
13
  }
14
14
  });
15
15
  const MODERN_META_NAME = 'modern-js';
16
- const { createConfigOptions: createConfigOptions } = __webpack_require__("@modern-js/plugin/cli?f956");
16
+ const { createConfigOptions: createConfigOptions } = __webpack_require__("@modern-js/plugin/cli?8936");
17
17
  async function resolveModernRsbuildConfig(options) {
18
18
  const { cwd = process.cwd(), metaName = MODERN_META_NAME } = options;
19
19
  const configFile = options.configPath || getConfigFile(void 0, cwd);
@@ -1,3 +1,6 @@
1
- import type { AppTools, CliPlugin } from '../../types';
1
+ import type { AppTools, AppToolsNormalizedConfig, CliPlugin } from '../../types';
2
+ import type { DeployTarget } from '../../types/config/deploy';
3
+ export declare const getSupportedDeployTargets: () => DeployTarget[];
4
+ export declare const resolveDeployTarget: (modernConfig: AppToolsNormalizedConfig, envDeployTarget?: string | undefined, detectedProvider?: import("std-env").ProviderName) => string;
2
5
  declare const _default: () => CliPlugin<AppTools>;
3
6
  export default _default;
@@ -0,0 +1,2 @@
1
+ import type { CreatePreset } from './platform';
2
+ export declare const createCloudflarePreset: CreatePreset;
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ fetch(request: any, env: any, ctx: any): Promise<any>;
3
+ };
4
+ export default _default;
@@ -26,7 +26,14 @@ export interface MicroFrontend {
26
26
  */
27
27
  attestation?: string;
28
28
  }
29
+ export type DeployTarget = 'node' | 'vercel' | 'netlify' | 'ghPages' | 'cloudflare';
29
30
  export interface DeployUserConfig {
31
+ /**
32
+ * Selects the deploy output preset.
33
+ * `MODERNJS_DEPLOY` still overrides provider auto-detection when set.
34
+ * @default node
35
+ */
36
+ target?: DeployTarget;
30
37
  /**
31
38
  * Used to configure micro-frontend sub-application information.
32
39
  * @default false
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.17",
20
+ "version": "3.2.0-ultramodern.22",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -85,8 +85,8 @@
85
85
  "@babel/parser": "^7.29.3",
86
86
  "@babel/traverse": "^7.29.0",
87
87
  "@babel/types": "^7.29.0",
88
- "@rsbuild/core": "2.0.6",
89
- "@swc/core": "1.15.33",
88
+ "@rsbuild/core": "2.0.7",
89
+ "@swc/core": "1.15.40",
90
90
  "@swc/helpers": "^0.5.21",
91
91
  "compression-webpack-plugin": "^12.0.0",
92
92
  "es-module-lexer": "^2.1.0",
@@ -98,22 +98,22 @@
98
98
  "ndepe": "^0.1.13",
99
99
  "pkg-types": "^2.3.1",
100
100
  "std-env": "4.1.0",
101
- "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.17",
102
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.17",
103
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.17",
104
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.17",
105
- "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.2.0-ultramodern.17",
106
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.17",
107
- "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.17",
108
- "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.17",
109
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.17",
110
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.17"
101
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.2.0-ultramodern.22",
102
+ "@modern-js/builder": "npm:@bleedingdev/modern-js-builder@3.2.0-ultramodern.22",
103
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.22",
104
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.2.0-ultramodern.22",
105
+ "@modern-js/prod-server": "npm:@bleedingdev/modern-js-prod-server@3.2.0-ultramodern.22",
106
+ "@modern-js/server": "npm:@bleedingdev/modern-js-server@3.2.0-ultramodern.22",
107
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.22",
108
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.2.0-ultramodern.22",
109
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.22",
110
+ "@modern-js/server-utils": "npm:@bleedingdev/modern-js-server-utils@3.2.0-ultramodern.22"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@rslib/core": "0.21.5",
114
114
  "@types/babel__traverse": "7.28.0",
115
- "@types/node": "^25.8.0",
116
- "@typescript/native-preview": "7.0.0-dev.20260516.1",
115
+ "@types/node": "^25.9.1",
116
+ "@typescript/native-preview": "7.0.0-dev.20260526.1",
117
117
  "tsconfig-paths": "^4.2.0",
118
118
  "@scripts/rstest-config": "2.66.0"
119
119
  },