@bleedingdev/modern-js-builder 3.5.0-ultramodern.99 → 3.8.1-ultramodern.1
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/dist/cjs/createBuilder.js +5 -2
- package/dist/cjs/plugins/rscConfig.js +16 -4
- package/dist/cjs/shared/rsc/rscDisabledClientBrowserRuntime.js +69 -0
- package/dist/cjs/shared/rsc/rscDisabledClientEdgeRuntime.js +61 -0
- package/dist/cjs/shared/rsc/rscDisabledClientNodeRuntime.js +65 -0
- package/dist/cjs/shared/rsc/rscDisabledRuntime.js +140 -0
- package/dist/cjs/shared/rsc/rscDisabledRuntimeError.js +42 -0
- package/dist/cjs/shared/rsc/rscDisabledServerEdgeRuntime.js +93 -0
- package/dist/cjs/shared/rsc/rscDisabledServerNodeRuntime.js +101 -0
- package/dist/esm/createBuilder.mjs +5 -2
- package/dist/esm/plugins/rscConfig.mjs +14 -5
- package/dist/esm/shared/rsc/rscDisabledClientBrowserRuntime.mjs +10 -0
- package/dist/esm/shared/rsc/rscDisabledClientEdgeRuntime.mjs +8 -0
- package/dist/esm/shared/rsc/rscDisabledClientNodeRuntime.mjs +9 -0
- package/dist/esm/shared/rsc/rscDisabledRuntime.mjs +92 -0
- package/dist/esm/shared/rsc/rscDisabledRuntimeError.mjs +4 -0
- package/dist/esm/shared/rsc/rscDisabledServerEdgeRuntime.mjs +16 -0
- package/dist/esm/shared/rsc/rscDisabledServerNodeRuntime.mjs +18 -0
- package/dist/esm-node/createBuilder.mjs +5 -2
- package/dist/esm-node/plugins/rscConfig.mjs +14 -5
- package/dist/esm-node/shared/rsc/rscDisabledClientBrowserRuntime.mjs +11 -0
- package/dist/esm-node/shared/rsc/rscDisabledClientEdgeRuntime.mjs +9 -0
- package/dist/esm-node/shared/rsc/rscDisabledClientNodeRuntime.mjs +10 -0
- package/dist/esm-node/shared/rsc/rscDisabledRuntime.mjs +97 -0
- package/dist/esm-node/shared/rsc/rscDisabledRuntimeError.mjs +5 -0
- package/dist/esm-node/shared/rsc/rscDisabledServerEdgeRuntime.mjs +17 -0
- package/dist/esm-node/shared/rsc/rscDisabledServerNodeRuntime.mjs +19 -0
- package/dist/types/plugins/rscConfig.d.ts +1 -0
- package/dist/types/shared/rsc/rscDisabledClientBrowserRuntime.d.ts +9 -0
- package/dist/types/shared/rsc/rscDisabledClientEdgeRuntime.d.ts +7 -0
- package/dist/types/shared/rsc/rscDisabledClientNodeRuntime.d.ts +8 -0
- package/dist/types/shared/rsc/rscDisabledRuntime.d.ts +2 -0
- package/dist/types/shared/rsc/rscDisabledRuntimeError.d.ts +1 -0
- package/dist/types/shared/rsc/rscDisabledServerEdgeRuntime.d.ts +15 -0
- package/dist/types/shared/rsc/rscDisabledServerNodeRuntime.d.ts +17 -0
- package/package.json +18 -5
- package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +0 -68
- package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +0 -20
- package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +0 -25
- package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +0 -2
|
@@ -2,7 +2,7 @@ import { createRsbuild } from "@rsbuild/core";
|
|
|
2
2
|
import { getRscPlugins } from "./plugins/rscConfig.mjs";
|
|
3
3
|
import { pluginRsdoctor } from "./plugins/rsdoctor.mjs";
|
|
4
4
|
import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { rscDisabledRuntimePlugin } from "./shared/rsc/rscDisabledRuntime.mjs";
|
|
6
6
|
async function parseConfig(builderConfig, options) {
|
|
7
7
|
builderConfig.performance ??= {};
|
|
8
8
|
builderConfig.performance.buildCache ??= true;
|
|
@@ -30,7 +30,10 @@ async function parseConfig(builderConfig, options) {
|
|
|
30
30
|
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
31
31
|
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
32
32
|
rsbuildPlugins.push(...rscPlugins);
|
|
33
|
-
} else
|
|
33
|
+
} else rsbuildConfig.plugins = [
|
|
34
|
+
...rsbuildConfig.plugins ?? [],
|
|
35
|
+
rscDisabledRuntimePlugin()
|
|
36
|
+
];
|
|
34
37
|
const rsdoctorPlugin = pluginRsdoctor(rsdoctorConfig);
|
|
35
38
|
if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
|
|
36
39
|
return {
|
|
@@ -10,6 +10,7 @@ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
|
|
|
10
10
|
const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
|
|
11
11
|
const SERVER_ONLY_MESSAGE_PATTERN = /server-only|server only|only works in a Server Component|cannot be imported (?:directly )?(?:from|into) (?:a )?Client Component/i;
|
|
12
12
|
const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
|
|
13
|
+
const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
|
|
13
14
|
const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
|
|
14
15
|
const isAsyncStorageExclude = (exclude)=>{
|
|
15
16
|
if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
|
|
@@ -166,7 +167,7 @@ function pluginRscConfig() {
|
|
|
166
167
|
} catch {
|
|
167
168
|
emptyModulePath = path.resolve(__dirname, '../shared/rsc/rscEmptyModule');
|
|
168
169
|
}
|
|
169
|
-
chain.resolve.alias.set('server-only$', emptyModulePath);
|
|
170
|
+
chain.module.rule('rsc-route-data-server-only').test(ROUTE_DATA_FILE_PATTERN).resolve.alias.set('server-only$', emptyModulePath);
|
|
170
171
|
const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
|
|
171
172
|
const appFilePattern = /[/\\]App\.[tj]sx?$/;
|
|
172
173
|
const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
|
|
@@ -240,8 +241,7 @@ function pluginRscConfig() {
|
|
|
240
241
|
}
|
|
241
242
|
async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
242
243
|
if (enableRsc) {
|
|
243
|
-
|
|
244
|
-
const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
|
|
244
|
+
const rscLayerMatchers = createRscLayerMatchers(internalDirectory);
|
|
245
245
|
const { pluginRSC } = await import("rsbuild-plugin-rsc");
|
|
246
246
|
return [
|
|
247
247
|
pluginRSC({
|
|
@@ -254,7 +254,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
|
254
254
|
RENDER_RSC_SOURCE_PATTERN,
|
|
255
255
|
RENDER_RSC_RSLIB_ENTRY_PATTERN,
|
|
256
256
|
/AppProxy/,
|
|
257
|
-
|
|
257
|
+
...rscLayerMatchers
|
|
258
258
|
]
|
|
259
259
|
}
|
|
260
260
|
}),
|
|
@@ -263,4 +263,13 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
|
263
263
|
}
|
|
264
264
|
return [];
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
function createRscLayerMatchers(internalDirectory) {
|
|
267
|
+
const escapedInternalDirectory = internalDirectory.split(/[/\\]+/u).map((segment)=>segment.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')).join('[/\\\\]');
|
|
268
|
+
const routesFileReg = new RegExp(`${escapedInternalDirectory}[/\\\\][^/\\\\]+[/\\\\]routes(?:\\.server)?\\.js(?:\\?.*)?$`);
|
|
269
|
+
const isolatedRouteDataReg = new RegExp(`${escapedInternalDirectory}[/\\\\][^/\\\\]+[/\\\\]__rsc_route_data__[/\\\\][^/\\\\]+\\.js(?:\\?.*)?$`);
|
|
270
|
+
return [
|
|
271
|
+
routesFileReg,
|
|
272
|
+
isolatedRouteDataReg
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
export { createRscLayerMatchers, enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
2
|
+
const createFromFetch = disabledRscRuntime;
|
|
3
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
4
|
+
const createServerReference = disabledRscRuntime;
|
|
5
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
6
|
+
const encodeReply = disabledRscRuntime;
|
|
7
|
+
const registerServerReference = disabledRscRuntime;
|
|
8
|
+
const setFindSourceMapURLCallback = disabledRscRuntime;
|
|
9
|
+
const setServerCallback = disabledRscRuntime;
|
|
10
|
+
export { createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference, setFindSourceMapURLCallback, setServerCallback };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
2
|
+
const createFromFetch = disabledRscRuntime;
|
|
3
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
4
|
+
const createServerReference = disabledRscRuntime;
|
|
5
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
6
|
+
const encodeReply = disabledRscRuntime;
|
|
7
|
+
const registerServerReference = disabledRscRuntime;
|
|
8
|
+
export { createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
2
|
+
const createFromFetch = disabledRscRuntime;
|
|
3
|
+
const createFromNodeStream = disabledRscRuntime;
|
|
4
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
5
|
+
const createServerReference = disabledRscRuntime;
|
|
6
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
7
|
+
const encodeReply = disabledRscRuntime;
|
|
8
|
+
const registerServerReference = disabledRscRuntime;
|
|
9
|
+
export { createFromFetch, createFromNodeStream, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
const disabledRuntimeModules = {
|
|
3
|
+
'react-server-dom-rspack/client.browser': './rscDisabledClientBrowserRuntime',
|
|
4
|
+
'react-server-dom-rspack/client.edge': './rscDisabledClientEdgeRuntime',
|
|
5
|
+
'react-server-dom-rspack/client.node': './rscDisabledClientNodeRuntime',
|
|
6
|
+
'react-server-dom-rspack/server.edge': './rscDisabledServerEdgeRuntime',
|
|
7
|
+
'react-server-dom-rspack/server.node': './rscDisabledServerNodeRuntime'
|
|
8
|
+
};
|
|
9
|
+
const disabledRuntimeRequests = Object.keys(disabledRuntimeModules);
|
|
10
|
+
function aliasMatchesRequest(aliasName, request) {
|
|
11
|
+
const exact = aliasName.endsWith('$');
|
|
12
|
+
const normalizedName = exact ? aliasName.slice(0, -1) : aliasName;
|
|
13
|
+
return exact ? normalizedName === request : request === normalizedName || request.startsWith(`${normalizedName}/`);
|
|
14
|
+
}
|
|
15
|
+
function objectAliasMatchesDisabledRuntime(aliasName) {
|
|
16
|
+
return disabledRuntimeRequests.some((request)=>aliasMatchesRequest(aliasName, request));
|
|
17
|
+
}
|
|
18
|
+
function arrayAliasMatchesDisabledRuntime(alias) {
|
|
19
|
+
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
20
|
+
return objectAliasMatchesDisabledRuntime(aliasName);
|
|
21
|
+
}
|
|
22
|
+
function normalizeArrayAliases(aliases) {
|
|
23
|
+
const normalized = {};
|
|
24
|
+
for (const alias of aliases){
|
|
25
|
+
if (arrayAliasMatchesDisabledRuntime(alias)) continue;
|
|
26
|
+
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
27
|
+
const existing = normalized[aliasName];
|
|
28
|
+
if (void 0 === existing) {
|
|
29
|
+
normalized[aliasName] = alias.alias;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
normalized[aliasName] = [
|
|
33
|
+
...Array.isArray(existing) ? existing : [
|
|
34
|
+
existing
|
|
35
|
+
],
|
|
36
|
+
...Array.isArray(alias.alias) ? alias.alias : [
|
|
37
|
+
alias.alias
|
|
38
|
+
]
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return normalized;
|
|
42
|
+
}
|
|
43
|
+
function resolveDisabledRuntimeModules() {
|
|
44
|
+
const resolvedModules = new Map();
|
|
45
|
+
return Object.fromEntries(Object.entries(disabledRuntimeModules).map(([request, moduleRequest])=>{
|
|
46
|
+
let modulePath = resolvedModules.get(moduleRequest);
|
|
47
|
+
if (void 0 === modulePath) {
|
|
48
|
+
try {
|
|
49
|
+
modulePath = require.resolve(moduleRequest);
|
|
50
|
+
} catch {
|
|
51
|
+
modulePath = path.resolve(__dirname, moduleRequest);
|
|
52
|
+
}
|
|
53
|
+
resolvedModules.set(moduleRequest, modulePath);
|
|
54
|
+
}
|
|
55
|
+
return [
|
|
56
|
+
`${request}$`,
|
|
57
|
+
modulePath
|
|
58
|
+
];
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
function applyDisabledRuntimeAliases(config, disabledAliases) {
|
|
62
|
+
config.resolve ??= {};
|
|
63
|
+
if (Array.isArray(config.resolve.alias)) config.resolve.alias = {
|
|
64
|
+
...disabledAliases,
|
|
65
|
+
...normalizeArrayAliases(config.resolve.alias)
|
|
66
|
+
};
|
|
67
|
+
else config.resolve.alias = {
|
|
68
|
+
...disabledAliases,
|
|
69
|
+
...Object.fromEntries(Object.entries(config.resolve.alias ?? {}).filter(([aliasName])=>!objectAliasMatchesDisabledRuntime(aliasName)))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function rscDisabledRuntimePlugin() {
|
|
73
|
+
return {
|
|
74
|
+
name: 'builder:rsc-disabled-runtime',
|
|
75
|
+
setup (api) {
|
|
76
|
+
const disabledAliases = resolveDisabledRuntimeModules();
|
|
77
|
+
api.modifyRspackConfig({
|
|
78
|
+
order: 'post',
|
|
79
|
+
handler (config) {
|
|
80
|
+
applyDisabledRuntimeAliases(config, disabledAliases);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
api.onBeforeCreateCompiler({
|
|
84
|
+
order: 'post',
|
|
85
|
+
handler ({ bundlerConfigs }) {
|
|
86
|
+
for (const config of bundlerConfigs)applyDisabledRuntimeAliases(config, disabledAliases);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export { rscDisabledRuntimePlugin };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
2
|
+
const createServerEntry = disabledRscRuntime;
|
|
3
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
4
|
+
const decodeAction = disabledRscRuntime;
|
|
5
|
+
const decodeFormState = disabledRscRuntime;
|
|
6
|
+
const decodeReply = disabledRscRuntime;
|
|
7
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
8
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
9
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
10
|
+
const ensureServerActions = disabledRscRuntime;
|
|
11
|
+
const loadServerAction = disabledRscRuntime;
|
|
12
|
+
const registerClientReference = disabledRscRuntime;
|
|
13
|
+
const registerServerReference = disabledRscRuntime;
|
|
14
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
15
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
16
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
2
|
+
const createServerEntry = disabledRscRuntime;
|
|
3
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
4
|
+
const decodeAction = disabledRscRuntime;
|
|
5
|
+
const decodeFormState = disabledRscRuntime;
|
|
6
|
+
const decodeReply = disabledRscRuntime;
|
|
7
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
8
|
+
const decodeReplyFromBusboy = disabledRscRuntime;
|
|
9
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
10
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
11
|
+
const ensureServerActions = disabledRscRuntime;
|
|
12
|
+
const loadServerAction = disabledRscRuntime;
|
|
13
|
+
const registerClientReference = disabledRscRuntime;
|
|
14
|
+
const registerServerReference = disabledRscRuntime;
|
|
15
|
+
const renderToPipeableStream = disabledRscRuntime;
|
|
16
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
17
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
18
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decodeReplyFromBusboy, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToPipeableStream, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -3,7 +3,7 @@ import { createRsbuild } from "@rsbuild/core";
|
|
|
3
3
|
import { getRscPlugins } from "./plugins/rscConfig.mjs";
|
|
4
4
|
import { pluginRsdoctor } from "./plugins/rsdoctor.mjs";
|
|
5
5
|
import { parseCommonConfig } from "./shared/parseCommonConfig.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { rscDisabledRuntimePlugin } from "./shared/rsc/rscDisabledRuntime.mjs";
|
|
7
7
|
async function parseConfig(builderConfig, options) {
|
|
8
8
|
builderConfig.performance ??= {};
|
|
9
9
|
builderConfig.performance.buildCache ??= true;
|
|
@@ -31,7 +31,10 @@ async function parseConfig(builderConfig, options) {
|
|
|
31
31
|
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
32
32
|
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
33
33
|
rsbuildPlugins.push(...rscPlugins);
|
|
34
|
-
} else
|
|
34
|
+
} else rsbuildConfig.plugins = [
|
|
35
|
+
...rsbuildConfig.plugins ?? [],
|
|
36
|
+
rscDisabledRuntimePlugin()
|
|
37
|
+
];
|
|
35
38
|
const rsdoctorPlugin = pluginRsdoctor(rsdoctorConfig);
|
|
36
39
|
if (rsdoctorPlugin) rsbuildPlugins.push(rsdoctorPlugin);
|
|
37
40
|
return {
|
|
@@ -15,6 +15,7 @@ const ENTRY_NAME_VAR = '__MODERN_JS_ENTRY_NAME';
|
|
|
15
15
|
const SERVER_ONLY_MARKER_PATTERN = /(?:^|[/\\])server-only[/\\]index\.js(?:\?|$)/;
|
|
16
16
|
const SERVER_ONLY_MESSAGE_PATTERN = /server-only|server only|only works in a Server Component|cannot be imported (?:directly )?(?:from|into) (?:a )?Client Component/i;
|
|
17
17
|
const SERVER_ONLY_DIAGNOSTIC_PREFIX = '[Modern.js RSC server-only diagnostic context]';
|
|
18
|
+
const ROUTE_DATA_FILE_PATTERN = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
|
|
18
19
|
const createVirtualModule = (content)=>`data:text/javascript,${encodeURIComponent(content)}`;
|
|
19
20
|
const isAsyncStorageExclude = (exclude)=>{
|
|
20
21
|
if ('string' == typeof exclude) return ASYNC_STORAGE_PATTERN.test(exclude);
|
|
@@ -171,7 +172,7 @@ function pluginRscConfig() {
|
|
|
171
172
|
} catch {
|
|
172
173
|
emptyModulePath = path.resolve(__rspack_import_meta_dirname__, '../shared/rsc/rscEmptyModule');
|
|
173
174
|
}
|
|
174
|
-
chain.resolve.alias.set('server-only$', emptyModulePath);
|
|
175
|
+
chain.module.rule('rsc-route-data-server-only').test(ROUTE_DATA_FILE_PATTERN).resolve.alias.set('server-only$', emptyModulePath);
|
|
175
176
|
const routeFilePattern = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.[tj]sx?$/;
|
|
176
177
|
const appFilePattern = /[/\\]App\.[tj]sx?$/;
|
|
177
178
|
const combinedPattern = new RegExp(`(${routeFilePattern.source}|${appFilePattern.source})`);
|
|
@@ -245,8 +246,7 @@ function pluginRscConfig() {
|
|
|
245
246
|
}
|
|
246
247
|
async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
247
248
|
if (enableRsc) {
|
|
248
|
-
|
|
249
|
-
const routeDataFileReg = /[/\\]routes[/\\](?:.*[/\\])?(?:layout|page|\$)\.(?:loader|data)\.[tj]sx?(?:\?.*)?$/;
|
|
249
|
+
const rscLayerMatchers = createRscLayerMatchers(internalDirectory);
|
|
250
250
|
const { pluginRSC } = await import("rsbuild-plugin-rsc");
|
|
251
251
|
return [
|
|
252
252
|
pluginRSC({
|
|
@@ -259,7 +259,7 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
|
259
259
|
RENDER_RSC_SOURCE_PATTERN,
|
|
260
260
|
RENDER_RSC_RSLIB_ENTRY_PATTERN,
|
|
261
261
|
/AppProxy/,
|
|
262
|
-
|
|
262
|
+
...rscLayerMatchers
|
|
263
263
|
]
|
|
264
264
|
}
|
|
265
265
|
}),
|
|
@@ -268,4 +268,13 @@ async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
|
268
268
|
}
|
|
269
269
|
return [];
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
function createRscLayerMatchers(internalDirectory) {
|
|
272
|
+
const escapedInternalDirectory = internalDirectory.split(/[/\\]+/u).map((segment)=>segment.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')).join('[/\\\\]');
|
|
273
|
+
const routesFileReg = new RegExp(`${escapedInternalDirectory}[/\\\\][^/\\\\]+[/\\\\]routes(?:\\.server)?\\.js(?:\\?.*)?$`);
|
|
274
|
+
const isolatedRouteDataReg = new RegExp(`${escapedInternalDirectory}[/\\\\][^/\\\\]+[/\\\\]__rsc_route_data__[/\\\\][^/\\\\]+\\.js(?:\\?.*)?$`);
|
|
275
|
+
return [
|
|
276
|
+
routesFileReg,
|
|
277
|
+
isolatedRouteDataReg
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
export { createRscLayerMatchers, enrichServerOnlyDiagnostics, getRscPlugins, pluginRscConfig };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createFromFetch = disabledRscRuntime;
|
|
4
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
5
|
+
const createServerReference = disabledRscRuntime;
|
|
6
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
7
|
+
const encodeReply = disabledRscRuntime;
|
|
8
|
+
const registerServerReference = disabledRscRuntime;
|
|
9
|
+
const setFindSourceMapURLCallback = disabledRscRuntime;
|
|
10
|
+
const setServerCallback = disabledRscRuntime;
|
|
11
|
+
export { createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference, setFindSourceMapURLCallback, setServerCallback };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createFromFetch = disabledRscRuntime;
|
|
4
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
5
|
+
const createServerReference = disabledRscRuntime;
|
|
6
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
7
|
+
const encodeReply = disabledRscRuntime;
|
|
8
|
+
const registerServerReference = disabledRscRuntime;
|
|
9
|
+
export { createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createFromFetch = disabledRscRuntime;
|
|
4
|
+
const createFromNodeStream = disabledRscRuntime;
|
|
5
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
6
|
+
const createServerReference = disabledRscRuntime;
|
|
7
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
8
|
+
const encodeReply = disabledRscRuntime;
|
|
9
|
+
const registerServerReference = disabledRscRuntime;
|
|
10
|
+
export { createFromFetch, createFromNodeStream, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
6
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
7
|
+
const disabledRuntimeModules = {
|
|
8
|
+
'react-server-dom-rspack/client.browser': './rscDisabledClientBrowserRuntime',
|
|
9
|
+
'react-server-dom-rspack/client.edge': './rscDisabledClientEdgeRuntime',
|
|
10
|
+
'react-server-dom-rspack/client.node': './rscDisabledClientNodeRuntime',
|
|
11
|
+
'react-server-dom-rspack/server.edge': './rscDisabledServerEdgeRuntime',
|
|
12
|
+
'react-server-dom-rspack/server.node': './rscDisabledServerNodeRuntime'
|
|
13
|
+
};
|
|
14
|
+
const disabledRuntimeRequests = Object.keys(disabledRuntimeModules);
|
|
15
|
+
function aliasMatchesRequest(aliasName, request) {
|
|
16
|
+
const exact = aliasName.endsWith('$');
|
|
17
|
+
const normalizedName = exact ? aliasName.slice(0, -1) : aliasName;
|
|
18
|
+
return exact ? normalizedName === request : request === normalizedName || request.startsWith(`${normalizedName}/`);
|
|
19
|
+
}
|
|
20
|
+
function objectAliasMatchesDisabledRuntime(aliasName) {
|
|
21
|
+
return disabledRuntimeRequests.some((request)=>aliasMatchesRequest(aliasName, request));
|
|
22
|
+
}
|
|
23
|
+
function arrayAliasMatchesDisabledRuntime(alias) {
|
|
24
|
+
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
25
|
+
return objectAliasMatchesDisabledRuntime(aliasName);
|
|
26
|
+
}
|
|
27
|
+
function normalizeArrayAliases(aliases) {
|
|
28
|
+
const normalized = {};
|
|
29
|
+
for (const alias of aliases){
|
|
30
|
+
if (arrayAliasMatchesDisabledRuntime(alias)) continue;
|
|
31
|
+
const aliasName = `${alias.name}${alias.onlyModule ? '$' : ''}`;
|
|
32
|
+
const existing = normalized[aliasName];
|
|
33
|
+
if (void 0 === existing) {
|
|
34
|
+
normalized[aliasName] = alias.alias;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
normalized[aliasName] = [
|
|
38
|
+
...Array.isArray(existing) ? existing : [
|
|
39
|
+
existing
|
|
40
|
+
],
|
|
41
|
+
...Array.isArray(alias.alias) ? alias.alias : [
|
|
42
|
+
alias.alias
|
|
43
|
+
]
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
return normalized;
|
|
47
|
+
}
|
|
48
|
+
function resolveDisabledRuntimeModules() {
|
|
49
|
+
const resolvedModules = new Map();
|
|
50
|
+
return Object.fromEntries(Object.entries(disabledRuntimeModules).map(([request, moduleRequest])=>{
|
|
51
|
+
let modulePath = resolvedModules.get(moduleRequest);
|
|
52
|
+
if (void 0 === modulePath) {
|
|
53
|
+
try {
|
|
54
|
+
modulePath = require.resolve(moduleRequest);
|
|
55
|
+
} catch {
|
|
56
|
+
modulePath = path.resolve(__rspack_import_meta_dirname__, moduleRequest);
|
|
57
|
+
}
|
|
58
|
+
resolvedModules.set(moduleRequest, modulePath);
|
|
59
|
+
}
|
|
60
|
+
return [
|
|
61
|
+
`${request}$`,
|
|
62
|
+
modulePath
|
|
63
|
+
];
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
function applyDisabledRuntimeAliases(config, disabledAliases) {
|
|
67
|
+
config.resolve ??= {};
|
|
68
|
+
if (Array.isArray(config.resolve.alias)) config.resolve.alias = {
|
|
69
|
+
...disabledAliases,
|
|
70
|
+
...normalizeArrayAliases(config.resolve.alias)
|
|
71
|
+
};
|
|
72
|
+
else config.resolve.alias = {
|
|
73
|
+
...disabledAliases,
|
|
74
|
+
...Object.fromEntries(Object.entries(config.resolve.alias ?? {}).filter(([aliasName])=>!objectAliasMatchesDisabledRuntime(aliasName)))
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function rscDisabledRuntimePlugin() {
|
|
78
|
+
return {
|
|
79
|
+
name: 'builder:rsc-disabled-runtime',
|
|
80
|
+
setup (api) {
|
|
81
|
+
const disabledAliases = resolveDisabledRuntimeModules();
|
|
82
|
+
api.modifyRspackConfig({
|
|
83
|
+
order: 'post',
|
|
84
|
+
handler (config) {
|
|
85
|
+
applyDisabledRuntimeAliases(config, disabledAliases);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
api.onBeforeCreateCompiler({
|
|
89
|
+
order: 'post',
|
|
90
|
+
handler ({ bundlerConfigs }) {
|
|
91
|
+
for (const config of bundlerConfigs)applyDisabledRuntimeAliases(config, disabledAliases);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export { rscDisabledRuntimePlugin };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createServerEntry = disabledRscRuntime;
|
|
4
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
5
|
+
const decodeAction = disabledRscRuntime;
|
|
6
|
+
const decodeFormState = disabledRscRuntime;
|
|
7
|
+
const decodeReply = disabledRscRuntime;
|
|
8
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
9
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
10
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
11
|
+
const ensureServerActions = disabledRscRuntime;
|
|
12
|
+
const loadServerAction = disabledRscRuntime;
|
|
13
|
+
const registerClientReference = disabledRscRuntime;
|
|
14
|
+
const registerServerReference = disabledRscRuntime;
|
|
15
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
16
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
17
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createServerEntry = disabledRscRuntime;
|
|
4
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
5
|
+
const decodeAction = disabledRscRuntime;
|
|
6
|
+
const decodeFormState = disabledRscRuntime;
|
|
7
|
+
const decodeReply = disabledRscRuntime;
|
|
8
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
9
|
+
const decodeReplyFromBusboy = disabledRscRuntime;
|
|
10
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
11
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
12
|
+
const ensureServerActions = disabledRscRuntime;
|
|
13
|
+
const loadServerAction = disabledRscRuntime;
|
|
14
|
+
const registerClientReference = disabledRscRuntime;
|
|
15
|
+
const registerServerReference = disabledRscRuntime;
|
|
16
|
+
const renderToPipeableStream = disabledRscRuntime;
|
|
17
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
18
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
19
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decodeReplyFromBusboy, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToPipeableStream, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { disabledRscRuntime } from './rscDisabledRuntimeError';
|
|
2
|
+
export declare const createFromFetch: typeof disabledRscRuntime;
|
|
3
|
+
export declare const createFromReadableStream: typeof disabledRscRuntime;
|
|
4
|
+
export declare const createServerReference: typeof disabledRscRuntime;
|
|
5
|
+
export declare const createTemporaryReferenceSet: typeof disabledRscRuntime;
|
|
6
|
+
export declare const encodeReply: typeof disabledRscRuntime;
|
|
7
|
+
export declare const registerServerReference: typeof disabledRscRuntime;
|
|
8
|
+
export declare const setFindSourceMapURLCallback: typeof disabledRscRuntime;
|
|
9
|
+
export declare const setServerCallback: typeof disabledRscRuntime;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { disabledRscRuntime } from './rscDisabledRuntimeError';
|
|
2
|
+
export declare const createFromFetch: typeof disabledRscRuntime;
|
|
3
|
+
export declare const createFromReadableStream: typeof disabledRscRuntime;
|
|
4
|
+
export declare const createServerReference: typeof disabledRscRuntime;
|
|
5
|
+
export declare const createTemporaryReferenceSet: typeof disabledRscRuntime;
|
|
6
|
+
export declare const encodeReply: typeof disabledRscRuntime;
|
|
7
|
+
export declare const registerServerReference: typeof disabledRscRuntime;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { disabledRscRuntime } from './rscDisabledRuntimeError';
|
|
2
|
+
export declare const createFromFetch: typeof disabledRscRuntime;
|
|
3
|
+
export declare const createFromNodeStream: typeof disabledRscRuntime;
|
|
4
|
+
export declare const createFromReadableStream: typeof disabledRscRuntime;
|
|
5
|
+
export declare const createServerReference: typeof disabledRscRuntime;
|
|
6
|
+
export declare const createTemporaryReferenceSet: typeof disabledRscRuntime;
|
|
7
|
+
export declare const encodeReply: typeof disabledRscRuntime;
|
|
8
|
+
export declare const registerServerReference: typeof disabledRscRuntime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function disabledRscRuntime(): never;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { disabledRscRuntime } from './rscDisabledRuntimeError';
|
|
2
|
+
export declare const createServerEntry: typeof disabledRscRuntime;
|
|
3
|
+
export declare const createTemporaryReferenceSet: typeof disabledRscRuntime;
|
|
4
|
+
export declare const decodeAction: typeof disabledRscRuntime;
|
|
5
|
+
export declare const decodeFormState: typeof disabledRscRuntime;
|
|
6
|
+
export declare const decodeReply: typeof disabledRscRuntime;
|
|
7
|
+
export declare const decodeReplyFromAsyncIterable: typeof disabledRscRuntime;
|
|
8
|
+
export declare const decryptServerActionBoundArgs: typeof disabledRscRuntime;
|
|
9
|
+
export declare const encryptServerActionBoundArgs: typeof disabledRscRuntime;
|
|
10
|
+
export declare const ensureServerActions: typeof disabledRscRuntime;
|
|
11
|
+
export declare const loadServerAction: typeof disabledRscRuntime;
|
|
12
|
+
export declare const registerClientReference: typeof disabledRscRuntime;
|
|
13
|
+
export declare const registerServerReference: typeof disabledRscRuntime;
|
|
14
|
+
export declare const renderToReadableStream: typeof disabledRscRuntime;
|
|
15
|
+
export declare const setServerActionBoundArgsEncryption: typeof disabledRscRuntime;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { disabledRscRuntime } from './rscDisabledRuntimeError';
|
|
2
|
+
export declare const createServerEntry: typeof disabledRscRuntime;
|
|
3
|
+
export declare const createTemporaryReferenceSet: typeof disabledRscRuntime;
|
|
4
|
+
export declare const decodeAction: typeof disabledRscRuntime;
|
|
5
|
+
export declare const decodeFormState: typeof disabledRscRuntime;
|
|
6
|
+
export declare const decodeReply: typeof disabledRscRuntime;
|
|
7
|
+
export declare const decodeReplyFromAsyncIterable: typeof disabledRscRuntime;
|
|
8
|
+
export declare const decodeReplyFromBusboy: typeof disabledRscRuntime;
|
|
9
|
+
export declare const decryptServerActionBoundArgs: typeof disabledRscRuntime;
|
|
10
|
+
export declare const encryptServerActionBoundArgs: typeof disabledRscRuntime;
|
|
11
|
+
export declare const ensureServerActions: typeof disabledRscRuntime;
|
|
12
|
+
export declare const loadServerAction: typeof disabledRscRuntime;
|
|
13
|
+
export declare const registerClientReference: typeof disabledRscRuntime;
|
|
14
|
+
export declare const registerServerReference: typeof disabledRscRuntime;
|
|
15
|
+
export declare const renderToPipeableStream: typeof disabledRscRuntime;
|
|
16
|
+
export declare const renderToReadableStream: typeof disabledRscRuntime;
|
|
17
|
+
export declare const setServerActionBoundArgsEncryption: typeof disabledRscRuntime;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bleedingdev/modern-js-builder",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1-ultramodern.1",
|
|
4
4
|
"description": "A builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.
|
|
29
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.8.1-ultramodern.1",
|
|
30
30
|
"@rsbuild/core": "2.1.5",
|
|
31
31
|
"@rsbuild/plugin-assets-retry": "2.0.1",
|
|
32
32
|
"@rsbuild/plugin-check-syntax": "2.0.0",
|
|
@@ -57,20 +57,33 @@
|
|
|
57
57
|
"postcss-media-minmax": "5.0.0",
|
|
58
58
|
"postcss-nesting": "14.0.0",
|
|
59
59
|
"postcss-page-break": "3.0.4",
|
|
60
|
-
"rsbuild-plugin-rsc": "0.1.1",
|
|
61
60
|
"rspack-manifest-plugin": "5.2.2",
|
|
62
61
|
"ts-deepmerge": "8.0.0"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.
|
|
64
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.8.1-ultramodern.1",
|
|
66
65
|
"@rslib/core": "0.23.2",
|
|
67
66
|
"@scripts/rstest-config": "2.66.0",
|
|
68
67
|
"@types/html-minifier-terser": "^7.0.2",
|
|
69
68
|
"@types/lodash": "^4.17.24",
|
|
70
|
-
"react": "^19.2.
|
|
69
|
+
"react": "^19.2.8",
|
|
70
|
+
"react-server-dom-rspack": "0.0.3",
|
|
71
|
+
"rsbuild-plugin-rsc": "0.1.1",
|
|
71
72
|
"terser": "^5.48.0",
|
|
72
73
|
"typescript": "^7.0.2"
|
|
73
74
|
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react-server-dom-rspack": "0.0.3",
|
|
77
|
+
"rsbuild-plugin-rsc": "0.1.1"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"react-server-dom-rspack": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"rsbuild-plugin-rsc": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
74
87
|
"publishConfig": {
|
|
75
88
|
"access": "public"
|
|
76
89
|
},
|