@modern-js/builder 3.3.0 → 3.5.0
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 +4 -2
- package/dist/cjs/plugins/rscConfig.js +4 -1
- package/dist/esm/createBuilder.mjs +4 -2
- package/dist/esm/plugins/rscConfig.mjs +4 -1
- package/dist/esm-node/createBuilder.mjs +4 -2
- package/dist/esm-node/plugins/rscConfig.mjs +4 -1
- package/dist/types/plugins/rscConfig.d.ts +10 -1
- package/dist/types/types.d.ts +26 -2
- package/package.json +9 -9
|
@@ -56,9 +56,11 @@ async function parseConfig(builderConfig, options) {
|
|
|
56
56
|
autoprefixer: builderConfig.tools?.autoprefixer
|
|
57
57
|
}));
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const rscConfig = builderConfig.server?.rsc ?? false;
|
|
60
|
+
const enableRsc = Boolean(rscConfig);
|
|
60
61
|
if (enableRsc) {
|
|
61
|
-
const
|
|
62
|
+
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
63
|
+
const rscPlugins = await (0, rscConfig_js_namespaceObject.getRscPlugins)(enableRsc, options.internalDirectory, rscEnvironments);
|
|
62
64
|
rsbuildPlugins.push(...rscPlugins);
|
|
63
65
|
} else rsbuildPlugins.push((0, rscClientBrowserFallback_js_namespaceObject.rscClientBrowserFallbackPlugin)());
|
|
64
66
|
return {
|
|
@@ -133,12 +133,15 @@ function pluginRscConfig() {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
async function getRscPlugins(enableRsc, internalDirectory) {
|
|
136
|
+
async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
137
137
|
if (enableRsc) {
|
|
138
138
|
const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
|
|
139
139
|
const { pluginRSC } = await import("rsbuild-plugin-rsc");
|
|
140
140
|
return [
|
|
141
141
|
pluginRSC({
|
|
142
|
+
...environments ? {
|
|
143
|
+
environments
|
|
144
|
+
} : {},
|
|
142
145
|
layers: {
|
|
143
146
|
rsc: [
|
|
144
147
|
/render[/\\].*[/\\]server[/\\]rsc/,
|
|
@@ -23,9 +23,11 @@ async function parseConfig(builderConfig, options) {
|
|
|
23
23
|
autoprefixer: builderConfig.tools?.autoprefixer
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const rscConfig = builderConfig.server?.rsc ?? false;
|
|
27
|
+
const enableRsc = Boolean(rscConfig);
|
|
27
28
|
if (enableRsc) {
|
|
28
|
-
const
|
|
29
|
+
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
30
|
+
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
29
31
|
rsbuildPlugins.push(...rscPlugins);
|
|
30
32
|
} else rsbuildPlugins.push(rscClientBrowserFallbackPlugin());
|
|
31
33
|
return {
|
|
@@ -90,12 +90,15 @@ function pluginRscConfig() {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
async function getRscPlugins(enableRsc, internalDirectory) {
|
|
93
|
+
async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
94
94
|
if (enableRsc) {
|
|
95
95
|
const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
|
|
96
96
|
const { pluginRSC } = await import("rsbuild-plugin-rsc");
|
|
97
97
|
return [
|
|
98
98
|
pluginRSC({
|
|
99
|
+
...environments ? {
|
|
100
|
+
environments
|
|
101
|
+
} : {},
|
|
99
102
|
layers: {
|
|
100
103
|
rsc: [
|
|
101
104
|
/render[/\\].*[/\\]server[/\\]rsc/,
|
|
@@ -24,9 +24,11 @@ async function parseConfig(builderConfig, options) {
|
|
|
24
24
|
autoprefixer: builderConfig.tools?.autoprefixer
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const rscConfig = builderConfig.server?.rsc ?? false;
|
|
28
|
+
const enableRsc = Boolean(rscConfig);
|
|
28
29
|
if (enableRsc) {
|
|
29
|
-
const
|
|
30
|
+
const rscEnvironments = 'object' == typeof rscConfig ? rscConfig.environments : void 0;
|
|
31
|
+
const rscPlugins = await getRscPlugins(enableRsc, options.internalDirectory, rscEnvironments);
|
|
30
32
|
rsbuildPlugins.push(...rscPlugins);
|
|
31
33
|
} else rsbuildPlugins.push(rscClientBrowserFallbackPlugin());
|
|
32
34
|
return {
|
|
@@ -95,12 +95,15 @@ function pluginRscConfig() {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
async function getRscPlugins(enableRsc, internalDirectory) {
|
|
98
|
+
async function getRscPlugins(enableRsc, internalDirectory, environments) {
|
|
99
99
|
if (enableRsc) {
|
|
100
100
|
const routesFileReg = new RegExp(`${internalDirectory.replace(/[/\\]/g, '[/\\\\]')}[/\\\\][^/\\\\]*[/\\\\]routes`);
|
|
101
101
|
const { pluginRSC } = await import("rsbuild-plugin-rsc");
|
|
102
102
|
return [
|
|
103
103
|
pluginRSC({
|
|
104
|
+
...environments ? {
|
|
105
|
+
environments
|
|
106
|
+
} : {},
|
|
104
107
|
layers: {
|
|
105
108
|
rsc: [
|
|
106
109
|
/render[/\\].*[/\\]server[/\\]rsc/,
|
|
@@ -13,6 +13,15 @@ export declare function pluginRscConfig(): RsbuildPlugin;
|
|
|
13
13
|
* Get RSC plugins based on configuration
|
|
14
14
|
* @param enableRsc - Whether RSC is enabled
|
|
15
15
|
* @param internalDirectory - Internal directory path for route matching
|
|
16
|
+
* @param environments - Optional mapping of the RSC plugin's `server`/`client`
|
|
17
|
+
* environments onto existing Rsbuild environment names. When omitted, the RSC
|
|
18
|
+
* plugin uses its defaults (`'server'` / `'client'`). Frameworks that already
|
|
19
|
+
* declare their own environments can point RSC at them instead of having the
|
|
20
|
+
* plugin create new empty environments (which would otherwise fall back to the
|
|
21
|
+
* default `./src` entry and fail to resolve).
|
|
16
22
|
* @returns Array of RSC-related plugins
|
|
17
23
|
*/
|
|
18
|
-
export declare function getRscPlugins(enableRsc: boolean, internalDirectory: string
|
|
24
|
+
export declare function getRscPlugins(enableRsc: boolean, internalDirectory: string, environments?: {
|
|
25
|
+
server?: string;
|
|
26
|
+
client?: string;
|
|
27
|
+
}): Promise<RsbuildPlugin[]>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export type BuilderExtraConfig = {
|
|
|
91
91
|
*/
|
|
92
92
|
devServer?: ToolsDevServerConfig;
|
|
93
93
|
/**
|
|
94
|
-
* Modify the options of [
|
|
94
|
+
* Modify the options of [ts-checker-rspack-plugin](https://github.com/rstackjs/ts-checker-rspack-plugin).
|
|
95
95
|
*/
|
|
96
96
|
tsChecker?: PluginTypeCheckerOptions['tsCheckerOptions'];
|
|
97
97
|
/**
|
|
@@ -235,6 +235,30 @@ export type DistPath = DistPathConfig & {
|
|
|
235
235
|
server?: string;
|
|
236
236
|
worker?: string;
|
|
237
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* RSC (React Server Components) configuration.
|
|
240
|
+
*
|
|
241
|
+
* - `true` / `false`: enable or disable RSC with the default `'server'` and
|
|
242
|
+
* `'client'` environment names.
|
|
243
|
+
* - object form: enable RSC and customize which Rsbuild environments the RSC
|
|
244
|
+
* plugin attaches to. Frameworks whose environment names differ from the
|
|
245
|
+
* defaults (e.g. multi-page builders that already declare their own
|
|
246
|
+
* server/client environments) can map RSC onto those existing environments
|
|
247
|
+
* instead of letting the plugin create new empty `'server'`/`'client'` ones.
|
|
248
|
+
*/
|
|
249
|
+
export type RscConfig = boolean | {
|
|
250
|
+
/**
|
|
251
|
+
* Map the RSC plugin's server/client environments onto existing Rsbuild
|
|
252
|
+
* environment names. Omitted keys fall back to the defaults
|
|
253
|
+
* (`'server'` / `'client'`).
|
|
254
|
+
*/
|
|
255
|
+
environments?: {
|
|
256
|
+
/** Rsbuild environment name for the React Server Components (server) bundle. @default 'server' */
|
|
257
|
+
server?: string;
|
|
258
|
+
/** Rsbuild environment name for the client (browser) bundle. @default 'client' */
|
|
259
|
+
client?: string;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
238
262
|
export type BuilderConfig = {
|
|
239
263
|
dev?: Omit<DevConfig, 'setupMiddlewares'> & {
|
|
240
264
|
server?: {
|
|
@@ -251,7 +275,7 @@ export type BuilderConfig = {
|
|
|
251
275
|
distPath?: DistPath;
|
|
252
276
|
};
|
|
253
277
|
server?: {
|
|
254
|
-
rsc?:
|
|
278
|
+
rsc?: RscConfig;
|
|
255
279
|
port?: number;
|
|
256
280
|
cors?: ServerConfig['cors'];
|
|
257
281
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/builder",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
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
|
-
"@rsbuild/core": "2.0
|
|
29
|
+
"@rsbuild/core": "2.1.0",
|
|
30
30
|
"@rsbuild/plugin-assets-retry": "2.0.1",
|
|
31
31
|
"@rsbuild/plugin-check-syntax": "2.0.0",
|
|
32
32
|
"@rsbuild/plugin-css-minimizer": "2.0.1",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"@rsbuild/plugin-sass": "1.5.3",
|
|
37
37
|
"@rsbuild/plugin-source-build": "1.0.6",
|
|
38
38
|
"@rsbuild/plugin-svgr": "2.0.3",
|
|
39
|
-
"@rsbuild/plugin-type-check": "1.
|
|
39
|
+
"@rsbuild/plugin-type-check": "1.5.0",
|
|
40
40
|
"@rsbuild/plugin-typed-css-modules": "1.2.3",
|
|
41
|
-
"@swc/core": "1.15.
|
|
41
|
+
"@swc/core": "1.15.41",
|
|
42
42
|
"@swc/helpers": "^0.5.17",
|
|
43
43
|
"autoprefixer": "10.4.27",
|
|
44
44
|
"browserslist": "4.28.2",
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"postcss-media-minmax": "5.0.0",
|
|
55
55
|
"postcss-nesting": "12.1.5",
|
|
56
56
|
"postcss-page-break": "3.0.4",
|
|
57
|
-
"rsbuild-plugin-rsc": "0.1.
|
|
57
|
+
"rsbuild-plugin-rsc": "0.1.1",
|
|
58
58
|
"rspack-manifest-plugin": "5.2.2",
|
|
59
59
|
"ts-deepmerge": "7.0.3",
|
|
60
|
-
"@modern-js/utils": "3.
|
|
60
|
+
"@modern-js/utils": "3.5.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@rslib/core": "0.
|
|
63
|
+
"@rslib/core": "0.23.0",
|
|
64
64
|
"@types/html-minifier-terser": "^7.0.2",
|
|
65
65
|
"@types/lodash": "^4.17.24",
|
|
66
66
|
"react": "^19.2.7",
|
|
67
|
-
"terser": "^5.
|
|
67
|
+
"terser": "^5.48.0",
|
|
68
68
|
"typescript": "^5.3.0",
|
|
69
69
|
"@modern-js/rslib": "2.68.10",
|
|
70
|
-
"@modern-js/types": "3.
|
|
70
|
+
"@modern-js/types": "3.5.0",
|
|
71
71
|
"@scripts/rstest-config": "2.66.0"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|