@vitejs/plugin-rsc 0.4.33 → 0.4.34
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/README.md +4 -0
- package/dist/index.js +1 -1
- package/dist/{plugin-BDLEZ1UW.js → plugin-BLedJFh7.js} +32 -13
- package/dist/plugin.js +1 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -561,6 +561,10 @@ Note that while there are official npm packages [`server-only`](https://www.npmj
|
|
|
561
561
|
|
|
562
562
|
This build-time validation is enabled by default and can be disabled by setting `validateImports: false` in the plugin options.
|
|
563
563
|
|
|
564
|
+
### `react-server-dom-webpack`
|
|
565
|
+
|
|
566
|
+
Currently `@vitejs/plugin-rsc` includes a vendored version of `react-server-dom-webpack`. However, when `react-server-dom-webpack` is installed in user project's dependencies, the plugin will automatically use it instead. This allows you to stay up-to-date with the latest React Server Components runtime without waiting for plugin updates.
|
|
567
|
+
|
|
564
568
|
## Credits
|
|
565
569
|
|
|
566
570
|
This project builds on fundamental techniques and insights from pioneering Vite RSC implementations.
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import "./plugin-CZbI4rhS.js";
|
|
|
3
3
|
import "./transforms-CpF3zNE0.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-CUvSZurk.js";
|
|
6
|
-
import { getPluginApi, vitePluginRsc } from "./plugin-
|
|
6
|
+
import { getPluginApi, vitePluginRsc } from "./plugin-BLedJFh7.js";
|
|
7
7
|
import "./cjs-BamOAUgw.js";
|
|
8
8
|
import "./shared-n-ykEs15.js";
|
|
9
9
|
|
|
@@ -423,27 +423,31 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
423
423
|
fs.writeFileSync(manifestPath, assetsManifestCode);
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
+
let hasReactServerDomWebpack = false;
|
|
426
427
|
return [
|
|
427
428
|
{
|
|
428
429
|
name: "rsc",
|
|
429
430
|
async config(config, env) {
|
|
430
431
|
if (config.rsc) Object.assign(rscPluginOptions, vite.mergeConfig(config.rsc, rscPluginOptions));
|
|
432
|
+
const result = await crawlFrameworkPkgs({
|
|
433
|
+
root: process.cwd(),
|
|
434
|
+
isBuild: env.command === "build",
|
|
435
|
+
isFrameworkPkgByJson(pkgJson) {
|
|
436
|
+
if ([PKG_NAME, "react-dom"].includes(pkgJson.name)) return;
|
|
437
|
+
const deps = pkgJson["peerDependencies"];
|
|
438
|
+
return deps && "react" in deps;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
431
441
|
const noExternal = [
|
|
432
442
|
"react",
|
|
433
443
|
"react-dom",
|
|
434
444
|
"server-only",
|
|
435
445
|
"client-only",
|
|
436
446
|
PKG_NAME,
|
|
437
|
-
...(
|
|
438
|
-
root: process.cwd(),
|
|
439
|
-
isBuild: env.command === "build",
|
|
440
|
-
isFrameworkPkgByJson(pkgJson) {
|
|
441
|
-
if ([PKG_NAME, "react-dom"].includes(pkgJson.name)) return;
|
|
442
|
-
const deps = pkgJson["peerDependencies"];
|
|
443
|
-
return deps && "react" in deps;
|
|
444
|
-
}
|
|
445
|
-
})).ssr.noExternal.sort()
|
|
447
|
+
...result.ssr.noExternal.sort()
|
|
446
448
|
];
|
|
449
|
+
hasReactServerDomWebpack = result.ssr.noExternal.includes("react-server-dom-webpack");
|
|
450
|
+
const reactServerDomPackageName = hasReactServerDomWebpack ? "react-server-dom-webpack" : REACT_SERVER_DOM_NAME;
|
|
447
451
|
return {
|
|
448
452
|
appType: config.appType ?? "custom",
|
|
449
453
|
define: { "import.meta.env.__vite_rsc_build__": JSON.stringify(env.command === "build") },
|
|
@@ -454,7 +458,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
454
458
|
rollupOptions: { input: rscPluginOptions.entries?.client && { index: rscPluginOptions.entries.client } }
|
|
455
459
|
},
|
|
456
460
|
optimizeDeps: {
|
|
457
|
-
include: ["react-dom/client", `${
|
|
461
|
+
include: ["react-dom/client", `${reactServerDomPackageName}/client.browser`],
|
|
458
462
|
exclude: [PKG_NAME]
|
|
459
463
|
}
|
|
460
464
|
},
|
|
@@ -473,7 +477,7 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
473
477
|
"react/jsx-dev-runtime",
|
|
474
478
|
"react-dom/server.edge",
|
|
475
479
|
"react-dom/static.edge",
|
|
476
|
-
`${
|
|
480
|
+
`${reactServerDomPackageName}/client.edge`
|
|
477
481
|
],
|
|
478
482
|
exclude: [PKG_NAME]
|
|
479
483
|
}
|
|
@@ -495,8 +499,8 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
495
499
|
"react-dom",
|
|
496
500
|
"react/jsx-runtime",
|
|
497
501
|
"react/jsx-dev-runtime",
|
|
498
|
-
`${
|
|
499
|
-
`${
|
|
502
|
+
`${reactServerDomPackageName}/server.edge`,
|
|
503
|
+
`${reactServerDomPackageName}/client.edge`
|
|
500
504
|
],
|
|
501
505
|
exclude: [PKG_NAME]
|
|
502
506
|
}
|
|
@@ -630,6 +634,21 @@ function vitePluginRsc(rscPluginOptions = {}) {
|
|
|
630
634
|
}
|
|
631
635
|
}
|
|
632
636
|
},
|
|
637
|
+
{
|
|
638
|
+
name: "rsc:react-server-dom-webpack-alias",
|
|
639
|
+
resolveId: {
|
|
640
|
+
order: "pre",
|
|
641
|
+
async handler(source, importer, options) {
|
|
642
|
+
if (hasReactServerDomWebpack && source.startsWith(`${PKG_NAME}/vendor/react-server-dom/`)) {
|
|
643
|
+
const newSource = source.replace(`${PKG_NAME}/vendor/react-server-dom`, "react-server-dom-webpack");
|
|
644
|
+
return await this.resolve(newSource, importer, {
|
|
645
|
+
...options,
|
|
646
|
+
skipSelf: true
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
},
|
|
633
652
|
{
|
|
634
653
|
name: "rsc:load-ssr-module",
|
|
635
654
|
transform(code) {
|
package/dist/plugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import "./plugin-CZbI4rhS.js";
|
|
|
3
3
|
import "./transforms-CpF3zNE0.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-CUvSZurk.js";
|
|
6
|
-
import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-
|
|
6
|
+
import { getPluginApi, transformRscCssExport, vitePluginRsc, vitePluginRscMinimal } from "./plugin-BLedJFh7.js";
|
|
7
7
|
import "./cjs-BamOAUgw.js";
|
|
8
8
|
import "./shared-n-ykEs15.js";
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitejs/plugin-rsc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.34",
|
|
4
4
|
"description": "React Server Components (RSC) support for Vite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -67,6 +67,12 @@
|
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"react": "*",
|
|
69
69
|
"react-dom": "*",
|
|
70
|
+
"react-server-dom-webpack": "*",
|
|
70
71
|
"vite": "*"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"react-server-dom-webpack": {
|
|
75
|
+
"optional": true
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
}
|