vite-plugin-react-server 0.3.18 → 1.0.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/README.md +220 -141
- package/bin/patch.mjs +8 -2
- package/dist/package.json +15 -8
- package/dist/plugin/checkFilesExist.d.ts.map +1 -1
- package/dist/plugin/checkFilesExist.js +6 -2
- package/dist/plugin/checkFilesExist.js.map +1 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +23 -0
- package/dist/plugin/collect-manifest-client-files.d.ts.map +1 -0
- package/dist/plugin/collect-manifest-client-files.js +131 -0
- package/dist/plugin/collect-manifest-client-files.js.map +1 -0
- package/dist/plugin/components.d.ts +3 -13
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +3 -13
- package/dist/plugin/config/defaults.d.ts +14 -6
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +9 -5
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js +2 -7
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/mimeTypes.d.ts +2 -0
- package/dist/plugin/config/mimeTypes.d.ts.map +1 -0
- package/dist/plugin/config/mimeTypes.js +24 -0
- package/dist/plugin/config/mimeTypes.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +2 -2
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +47 -28
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +1 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +9 -5
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +2 -1
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +181 -147
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy-dir.js +23 -18
- package/dist/plugin/copy-dir.js.map +1 -0
- package/dist/plugin/css-collector-inline.d.ts +10 -0
- package/dist/plugin/css-collector-inline.d.ts.map +1 -0
- package/dist/plugin/css-collector-inline.js +55 -0
- package/dist/plugin/css-collector-inline.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +14 -0
- package/dist/plugin/css-collector.d.ts.map +1 -0
- package/dist/plugin/css-collector.js +49 -0
- package/dist/plugin/css-collector.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +17 -0
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createHandler.js +111 -0
- package/dist/plugin/helpers/createHandler.js.map +1 -0
- package/dist/plugin/helpers/createRscStream.d.ts +27 -0
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -0
- package/dist/plugin/helpers/createRscStream.js +80 -0
- package/dist/plugin/helpers/createRscStream.js.map +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +12 -4
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +5 -0
- package/dist/plugin/html.d.ts.map +1 -0
- package/dist/plugin/html.js +11 -0
- package/dist/plugin/html.js.map +1 -0
- package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +8 -5
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.js +2 -2
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +49 -14
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +21 -78
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +2 -0
- package/dist/plugin/react-server/index.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts +2 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +92 -225
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/index.d.ts +2 -0
- package/dist/plugin/react-static/index.d.ts.map +1 -0
- package/dist/plugin/react-static/index.js +1 -0
- package/dist/plugin/react-static/plugin.d.ts +7 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -0
- package/dist/plugin/react-static/plugin.js +207 -0
- package/dist/plugin/react-static/plugin.js.map +1 -0
- package/dist/plugin/react-static/types.d.ts +2 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -0
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +9 -0
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/root.d.ts +2 -0
- package/dist/plugin/root.d.ts.map +1 -0
- package/dist/plugin/root.js +12 -0
- package/dist/plugin/root.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +32 -23
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/types.d.ts +1 -18
- package/dist/plugin/transformer/types.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +70 -15
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +0 -1
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.d.ts +30 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +30 -2
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +3 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +12 -3
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/renderPages.d.ts +13 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +138 -86
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +104 -84
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -18
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +4 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/types.d.ts +3 -0
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -6
- package/plugin/checkFilesExist.ts +7 -3
- package/plugin/collect-manifest-client-files.ts +167 -0
- package/plugin/components.ts +3 -0
- package/plugin/config/defaults.tsx +70 -0
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/mimeTypes.ts +17 -0
- package/plugin/config/resolveOptions.ts +58 -45
- package/plugin/config/resolvePages.ts +8 -4
- package/plugin/config/resolveUserConfig.ts +220 -176
- package/plugin/css-collector-inline.tsx +60 -0
- package/plugin/css-collector.tsx +62 -0
- package/plugin/helpers/createHandler.ts +135 -0
- package/plugin/helpers/createRscStream.ts +109 -0
- package/plugin/helpers/getBundleManifest.ts +14 -5
- package/plugin/html.tsx +9 -0
- package/plugin/loader/createBuildLoader.ts +9 -6
- package/plugin/loader/css-loader.ts +0 -2
- package/plugin/loader/react-loader.ts +2 -2
- package/plugin/preserver/plugin.ts +64 -17
- package/plugin/react-client/plugin.ts +23 -93
- package/plugin/react-server/index.ts +2 -0
- package/plugin/react-server/plugin.ts +111 -302
- package/plugin/react-static/index.ts +1 -0
- package/plugin/react-static/plugin.ts +256 -0
- package/plugin/react-static/types.ts +3 -0
- package/plugin/resolvePage.ts +9 -0
- package/plugin/root.ts +4 -0
- package/plugin/transformer/plugin.ts +40 -31
- package/plugin/transformer/types.ts +0 -19
- package/plugin/types.ts +77 -16
- package/plugin/worker/createWorker.ts +1 -1
- package/plugin/worker/html/README.md +63 -0
- package/plugin/worker/html/html-worker.development.tsx +89 -2
- package/plugin/worker/html/html-worker.production.tsx +8 -10
- package/plugin/worker/html/messageHandler.ts +12 -3
- package/plugin/worker/html/renderPages.ts +178 -138
- package/plugin/worker/rsc/README.md +58 -0
- package/plugin/worker/rsc/messageHandler.tsx +112 -113
- package/plugin/worker/rsc/rsc-worker.development.ts +12 -22
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -1
- package/plugin/worker/rsc/state.ts +0 -3
- package/plugin/worker/types.ts +3 -0
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +114 -12
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +10571 -121
- package/tsconfig.json +2 -2
- package/dist/plugin/collect-css-manifest.d.ts +0 -4
- package/dist/plugin/collect-css-manifest.d.ts.map +0 -1
- package/dist/plugin/collect-css-manifest.js +0 -65
- package/dist/plugin/collect-css-manifest.js.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.d.ts +0 -11
- package/dist/plugin/config/createModuleIdGenerator.d.ts.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.js +0 -44
- package/dist/plugin/config/createModuleIdGenerator.js.map +0 -1
- package/dist/plugin/getEnv.d.ts +0 -19
- package/dist/plugin/getEnv.d.ts.map +0 -1
- package/dist/plugin/getEnv.js +0 -107
- package/dist/plugin/loader/createCssLoader.d.ts +0 -30
- package/dist/plugin/loader/createCssLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createCssLoader.js +0 -35
- package/dist/plugin/loader/createPageLoader.d.ts +0 -24
- package/dist/plugin/loader/createPageLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createPageLoader.js +0 -50
- package/dist/plugin/loader/rsc/messageHandler.d.ts +0 -2
- package/dist/plugin/loader/rsc/messageHandler.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +0 -2
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.js +0 -1
- package/dist/plugin/module-graph.d.ts +0 -10
- package/dist/plugin/module-graph.d.ts.map +0 -1
- package/dist/plugin/module-graph.js +0 -35
- package/dist/plugin/react-server/createHandler.d.ts +0 -17
- package/dist/plugin/react-server/createHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createHandler.js +0 -126
- package/dist/plugin/react-server/createHandler.js.map +0 -1
- package/dist/plugin/react-server/createRscStream.d.ts +0 -16
- package/dist/plugin/react-server/createRscStream.d.ts.map +0 -1
- package/dist/plugin/react-server/createRscStream.js +0 -70
- package/dist/plugin/react-server/createRscStream.js.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts +0 -4
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.js +0 -95
- package/dist/plugin/utils/logger.d.ts +0 -9
- package/dist/plugin/utils/logger.d.ts.map +0 -1
- package/dist/plugin/utils/logger.js +0 -68
- package/dist/plugin/utils/logger.js.map +0 -1
- package/dist/plugin/worker/html/plugin.d.ts +0 -4
- package/dist/plugin/worker/html/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/html/plugin.js +0 -94
- package/dist/plugin/worker/plugin.d.ts +0 -19
- package/dist/plugin/worker/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/plugin.js +0 -23
- package/dist/plugin/worker/rsc/plugin.d.ts +0 -4
- package/dist/plugin/worker/rsc/plugin.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/plugin.js +0 -76
- package/plugin/collect-css-manifest.ts +0 -82
- package/plugin/components.tsx +0 -14
- package/plugin/config/createModuleIdGenerator.ts +0 -52
- package/plugin/config/defaults.ts +0 -51
- package/plugin/getEnv.ts +0 -135
- package/plugin/loader/createCssLoader.ts +0 -73
- package/plugin/loader/createPageLoader.ts +0 -103
- package/plugin/loader/rsc/messageHandler.tsx +0 -1
- package/plugin/loader/rsc/rsc-worker.development.ts +0 -1
- package/plugin/module-graph.ts +0 -48
- package/plugin/react-server/createHandler.ts +0 -162
- package/plugin/react-server/createRscStream.ts +0 -86
- package/plugin/react-server/createSsrHandler.ts +0 -125
- package/plugin/utils/logger.ts +0 -52
- package/plugin/worker/html/plugin.ts +0 -101
- package/plugin/worker/plugin.ts +0 -26
- package/plugin/worker/rsc/plugin.ts +0 -84
- /package/dist/plugin/{loader/rsc/messageHandler.js → react-static/types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,213 +1,292 @@
|
|
|
1
|
-
# Vite React Server
|
|
1
|
+
# Vite React Server Plugin
|
|
2
2
|
|
|
3
|
-
A Vite plugin that enables React Server Components (RSC) streaming and static
|
|
3
|
+
A Vite plugin that enables React Server Components (RSC) streaming and static HTML page generation. It leverages experimental dependencies from React, specifically `react-server-dom-esm`.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Example Projects
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- ⚡ Full RSC streaming support
|
|
10
|
-
- 📦 Dual-worker architecture for optimal performance
|
|
11
|
-
- 🔧 Automatic client/server code splitting
|
|
12
|
-
- 🎯 Directive-based component targeting
|
|
13
|
-
|
|
14
|
-
## Example Project
|
|
15
|
-
|
|
16
|
-
The [mmcelebration.com project](https://github.com/nicobrinkkemper/mmc) uses this plugin. Build time for ~200 html pages is just a few seconds.
|
|
7
|
+
- [The official demo](https://github.com/nicobrinkkemper/vite-plugin-react-server-demo-official)
|
|
8
|
+
- [The mmcelebration.com project](https://github.com/nicobrinkkemper/mmc)
|
|
17
9
|
|
|
18
10
|
## Installation
|
|
19
11
|
|
|
20
|
-
```
|
|
21
|
-
npm install vite-plugin-react-
|
|
12
|
+
```sh
|
|
13
|
+
npm install -D vite-plugin-react-stream
|
|
22
14
|
```
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
## Open Source and Work in Progress
|
|
25
17
|
|
|
26
|
-
This
|
|
18
|
+
This project uses the latest *OSS-experimental* React version from [the official React GitHub repository](https://github.com/facebook/react). The plugin includes a patch system to facilitate setup. First, install dependencies and patches:
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
npm install react-server-dom-esm
|
|
20
|
+
```sh
|
|
21
|
+
npm install -D patch-package react@experimental react-dom@experimental react-server-dom-esm
|
|
31
22
|
```
|
|
32
23
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
Add the following command to your `package.json` scripts:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
"patch": "check-react-version && patch"
|
|
36
28
|
```
|
|
37
|
-
This will:
|
|
38
|
-
- Detect your installed React version
|
|
39
|
-
- Adapt the patch accordingly
|
|
40
|
-
- Create `patches/react-server-dom-esm+YOUR-REACT-VERSION.patch`
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
Run the patch command:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npm run patch
|
|
45
34
|
```
|
|
46
35
|
|
|
47
|
-
|
|
36
|
+
It will instruct you to add:
|
|
37
|
+
|
|
48
38
|
```json
|
|
49
|
-
|
|
50
|
-
"scripts": {
|
|
51
|
-
"postinstall": "patch-package"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
39
|
+
"postinstall": "patch-package"
|
|
54
40
|
```
|
|
55
41
|
|
|
56
|
-
|
|
42
|
+
This ensures the patch is applied after every `npm install`. If errors arise related to `react-server-dom-esm`, verify that the postinstall step ran.
|
|
57
43
|
|
|
58
|
-
|
|
44
|
+
---
|
|
59
45
|
|
|
60
|
-
|
|
61
|
-
// vite.react-server.config.ts
|
|
62
|
-
import { defineConfig } from 'vite'
|
|
63
|
-
import type { Options } from 'vite-plugin-react-server'
|
|
46
|
+
## Plugin Structure and Purpose
|
|
64
47
|
|
|
65
|
-
|
|
66
|
-
const createRouter = (file: 'props.ts' | 'Page.tsx') => (url: string) => {
|
|
67
|
-
if(url.includes('bidoof')) return `src/page/bidoof/${file}`
|
|
68
|
-
if(url === '/index.rsc') return `src/page/${file}`;
|
|
69
|
-
return `src/page/404/${file}`;
|
|
70
|
-
}
|
|
48
|
+
### Strict Client-Server Separation
|
|
71
49
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
50
|
+
This plugin enforces a **strict architectural separation** between client and server execution. It achieves this by requiring **distinct entry files** for both environments, preventing unintended dependencies or cross-thread interactions. While this approach improves maintainability and clarity, it requires additional boilerplate.
|
|
51
|
+
|
|
52
|
+
The separation is accomplished through two complementary plugins:
|
|
53
|
+
|
|
54
|
+
- **vite-plugin-react-server/client** → Handles client-side rendering and ESM bundling
|
|
55
|
+
- **vite-plugin-react-server** → Manages server-side streaming and RSC processing
|
|
56
|
+
|
|
57
|
+
This ensures that client-side and server-side concerns remain isolated from the beginning, reducing potential inconsistencies.
|
|
58
|
+
|
|
59
|
+
### Custom composition
|
|
60
|
+
|
|
61
|
+
You can pick and choose only the plugins you like to get the desired behavior as well. For example, we can choose only to use the preserver, the transformer, static plugin, etc.
|
|
62
|
+
|
|
63
|
+
### Worker support
|
|
64
|
+
|
|
65
|
+
The client plugin uses the `rsc-worker` to create server side streams. The server plugin uses the `html-worker` to create client side html. If you don't want to use the rsc-worker, simply don't serve the client plugin. If you don't want to use the `html-worker` simply don't configure the `build.pages` option.
|
|
66
|
+
|
|
67
|
+
### Custom Worker
|
|
68
|
+
|
|
69
|
+
Both workers can be customized using the `htmlWorkerPath` and `rscWorkerPath` respectively. The paths will be used to create the workers instead of the prebuilt worker included with this plugin. If these paths are defined, they will be made part of your application build as well.
|
|
70
|
+
|
|
71
|
+
Keep in mind that, using your custom worker means interacting with the message system of this plugin during development/static generation process.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Plugin Usage
|
|
75
|
+
|
|
76
|
+
### vite-plugin-react-server/client
|
|
77
|
+
|
|
78
|
+
Used in `vite.config.ts` for standard Vite client-side behavior
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { defineConfig, type Plugin } from "vite";
|
|
82
|
+
import { vitePluginReactClient } from "vite-plugin-react-server/client";
|
|
83
|
+
import { config } from "./vite.react.config";
|
|
84
|
+
|
|
85
|
+
export default defineConfig({
|
|
86
|
+
plugins: vitePluginReactClient(config) as Plugin[],
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Build Steps
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
vite build
|
|
79
94
|
```
|
|
95
|
+
Outputs React client-side ESM files to `dist/client`.
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
```sh
|
|
98
|
+
vite build --ssr
|
|
99
|
+
```
|
|
100
|
+
Outputs files for server-side execution to `dist/server`.
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
vite preview
|
|
104
|
+
```
|
|
105
|
+
Serves the static directory.
|
|
82
106
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### vite-plugin-react-server
|
|
110
|
+
|
|
111
|
+
Used in `vite.server.config.ts`, this plugin strictly separates client and server execution. The client components will be emitted as references.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { defineConfig, Plugin } from "vite";
|
|
115
|
+
import { vitePluginReactServer } from "vite-plugin-react-server";
|
|
116
|
+
import { config } from "./vite.react.config";
|
|
88
117
|
|
|
89
118
|
export default defineConfig({
|
|
90
|
-
plugins:
|
|
91
|
-
})
|
|
119
|
+
plugins: vitePluginReactServer(config) as Plugin[],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Running in Development
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
NODE_OPTIONS="--conditions=react-server" vite --config vite.server.config.ts
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Build Steps
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
NODE_OPTIONS="--conditions=react-server" vite build --config vite.server.config.ts
|
|
92
133
|
```
|
|
134
|
+
Generates server and static folder. The plugin ensures proper SSR handling without requiring `--ssr` manually.
|
|
135
|
+
Note: ssr can still be disabled via config `{ssr:false}`, which will enable vite's browser virtualization
|
|
93
136
|
|
|
94
|
-
|
|
137
|
+
---
|
|
95
138
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
import {
|
|
139
|
+
## Static Site Generation
|
|
140
|
+
|
|
141
|
+
Single-out the static generation step by only inluding the static plugin. Expects client and server folders to be there.
|
|
142
|
+
```ts
|
|
143
|
+
import { defineConfig, Plugin } from "vite";
|
|
144
|
+
import { reactStaticPlugin } from "vite-plugin-react-server/static";
|
|
145
|
+
import { config } from "./vite.react.config";
|
|
101
146
|
|
|
102
147
|
export default defineConfig({
|
|
103
|
-
plugins: [
|
|
104
|
-
})
|
|
148
|
+
plugins: [reactStaticPlugin(config)],
|
|
149
|
+
});
|
|
105
150
|
```
|
|
106
151
|
|
|
107
|
-
|
|
152
|
+
Example output structure:
|
|
108
153
|
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"build:client": "vite build",
|
|
115
|
-
"build:server": "NODE_OPTIONS=--conditions=react-server vite build --ssr --config vite.server.config.ts",
|
|
116
|
-
"test:server": "NODE_OPTIONS=--conditions=react-server vitest --config vite.server.config.ts"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
154
|
+
```sh
|
|
155
|
+
dist/static/index.html
|
|
156
|
+
dist/static/index.rsc
|
|
157
|
+
dist/static/about/index.html
|
|
158
|
+
dist/static/about/index.rsc
|
|
119
159
|
```
|
|
120
160
|
|
|
121
|
-
|
|
161
|
+
The entire `dist/client` directory is copied into `dist/static`, as well as any assets used server-side. Allowing easy deployment by moving the static folder to a hosting service.
|
|
122
162
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Configuration
|
|
166
|
+
|
|
167
|
+
### moduleBase
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
const config = {
|
|
171
|
+
moduleBase: "src",
|
|
128
172
|
}
|
|
129
173
|
```
|
|
174
|
+
Defines the root directory for project modules. This can be customized.
|
|
130
175
|
|
|
131
|
-
###
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const res = await fetch("https://pokeapi.co/api/v2/pokemon-form/399/")
|
|
136
|
-
return res.json()
|
|
137
|
-
}
|
|
176
|
+
### moduleBasePath
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
moduleBasePath: "",
|
|
138
180
|
```
|
|
181
|
+
Passed as the second argument to `renderToPipeableStream` for server-side rendering.
|
|
139
182
|
|
|
140
|
-
###
|
|
141
|
-
Use the "use client" directive for client-side features:
|
|
142
|
-
```tsx
|
|
143
|
-
"use client"
|
|
144
|
-
import { useState } from 'react'
|
|
183
|
+
### moduleBaseURL
|
|
145
184
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return <button onClick={() => setCount(c => c + 1)}>{count}</button>
|
|
149
|
-
}
|
|
185
|
+
```ts
|
|
186
|
+
moduleBaseURL: "https://github.com/my-gh-pages",
|
|
150
187
|
```
|
|
188
|
+
Defines asset URL resolution for CSS collectors and bootstrapModule.
|
|
151
189
|
|
|
152
|
-
###
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
190
|
+
### Page and props Mapping
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
Page: (id) => join(id.replace('index.rsc',''), 'page.tsx')
|
|
194
|
+
```
|
|
195
|
+
Defines how pages are mapped to file paths.
|
|
196
|
+
```ts
|
|
197
|
+
props: (id) => join(id.replace('index.rsc',''), 'props.ts')
|
|
159
198
|
```
|
|
199
|
+
Defines how to load the initial props of the page file.
|
|
160
200
|
|
|
161
|
-
|
|
201
|
+
If you do not want prop files, just don't define it.
|
|
202
|
+
```ts
|
|
203
|
+
pageExport: 'Page',
|
|
204
|
+
```
|
|
205
|
+
Changes the default name "Page"
|
|
206
|
+
```ts
|
|
207
|
+
propsExport: 'props',
|
|
208
|
+
```
|
|
209
|
+
Changes the default name "props"
|
|
162
210
|
|
|
163
|
-
|
|
164
|
-
- CSS files are automatically collected and link tags emitted
|
|
165
|
-
- Components are streamed only when visited
|
|
166
|
-
- Supports both sync and async props, and all kinds of combinations I haven't tried or tested yet!
|
|
211
|
+
---
|
|
167
212
|
|
|
168
|
-
##
|
|
213
|
+
## Example Setup
|
|
169
214
|
|
|
170
|
-
|
|
215
|
+
### package.json Scripts
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
"scripts": {
|
|
219
|
+
"build": "build:client && build:server",
|
|
220
|
+
"dev": "NODE_OPTIONS='--conditions react-server' vite --config vite.server.config.ts",
|
|
221
|
+
"dev:client": "vite",
|
|
222
|
+
"build:server": "NODE_OPTIONS='--conditions react-server' vite build --config vite.server.config.ts",
|
|
223
|
+
"build:client": "vite build"
|
|
224
|
+
}
|
|
225
|
+
```
|
|
171
226
|
|
|
172
|
-
|
|
227
|
+
### Sample Page Component
|
|
173
228
|
|
|
174
|
-
|
|
229
|
+
```tsx
|
|
230
|
+
// src/my-page.tsx
|
|
231
|
+
export const Page = ({ name }) => {
|
|
232
|
+
return <div>Hello {name}</div>;
|
|
233
|
+
};
|
|
234
|
+
```
|
|
175
235
|
|
|
176
|
-
|
|
236
|
+
### Sample Props File
|
|
177
237
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
238
|
+
```ts
|
|
239
|
+
// src/my-props.ts
|
|
240
|
+
export const props = {
|
|
241
|
+
name: "John Doe",
|
|
242
|
+
};
|
|
243
|
+
```
|
|
182
244
|
|
|
183
|
-
|
|
245
|
+
### Vite Configuration Files
|
|
184
246
|
|
|
185
|
-
|
|
247
|
+
#### Client Configuration (`vite.config.ts`)
|
|
186
248
|
|
|
187
|
-
|
|
249
|
+
```ts
|
|
250
|
+
import { vitePluginReactClient } from "vite-plugin-react-server/client";
|
|
251
|
+
import { defineConfig } from "vite";
|
|
188
252
|
|
|
253
|
+
export default defineConfig({
|
|
254
|
+
plugins: vitePluginReactClient(),
|
|
255
|
+
});
|
|
256
|
+
```
|
|
189
257
|
|
|
190
|
-
|
|
191
|
-
this plugin will register it as a server action - which means you can intend the exported functions to be API endpoints.
|
|
258
|
+
#### Server Configuration (`vite.server.config.ts`)
|
|
192
259
|
|
|
193
|
-
|
|
260
|
+
```ts
|
|
261
|
+
import { vitePluginReactServer } from "vite-plugin-react-server";
|
|
262
|
+
import { defineConfig } from "vite";
|
|
194
263
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
264
|
+
export default defineConfig({
|
|
265
|
+
plugins: vitePluginReactServer(),
|
|
266
|
+
});
|
|
267
|
+
```
|
|
198
268
|
|
|
199
|
-
|
|
269
|
+
---
|
|
200
270
|
|
|
201
|
-
|
|
271
|
+
```sh
|
|
272
|
+
NODE_OPTIONS='--conditions react-server' npx vite --config vite.server.config.ts
|
|
273
|
+
```
|
|
202
274
|
|
|
203
|
-
|
|
204
|
-
- This condition must NOT be present for client-side React operations (generating HTML from RSC streams)
|
|
275
|
+
In development mode, the server plugin pipes the React stream directly to the response.
|
|
205
276
|
|
|
206
|
-
|
|
277
|
+
```sh
|
|
278
|
+
NODE_OPTIONS='--conditions react-server' npx vite build --config vite.server.config.ts
|
|
279
|
+
```
|
|
280
|
+
This builds the `dist/server` directory. It sets ssr to true by default, so you can't forget to. Additionally, when the build is done it generates the `dist/static` directory using the /static plugin.
|
|
207
281
|
|
|
208
|
-
|
|
282
|
+
---
|
|
209
283
|
|
|
210
|
-
|
|
284
|
+
## Summary
|
|
211
285
|
|
|
286
|
+
- **Strict Client-Server Separation** → Ensures modularity and maintainability
|
|
287
|
+
- **Static Site Generation** → Produces deployable HTML and RSC files
|
|
288
|
+
- **Dual RSC Implementation** → Supports direct streaming and worker-based approaches
|
|
289
|
+
- **Customizable Module Loading** → Allows flexible project configurations
|
|
212
290
|
|
|
291
|
+
This plugin provides a workflow for React Server Components within Vite, balancing **performance, modularity, and ease of use**.
|
|
213
292
|
|
package/bin/patch.mjs
CHANGED
|
@@ -13,8 +13,6 @@ async function patchReactExperimental() {
|
|
|
13
13
|
try {
|
|
14
14
|
// Read installed React version from user's project
|
|
15
15
|
|
|
16
|
-
const installedVersion = React.version
|
|
17
|
-
const PATCH_RECONCILER_VERSION = installedVersion.replace('19.1.0', '0.0.0')
|
|
18
16
|
if(TEMPLATE_VERSION === PATCH_RECONCILER_VERSION) {
|
|
19
17
|
console.log('React version is patched')
|
|
20
18
|
}
|
|
@@ -25,6 +23,14 @@ async function patchReactExperimental() {
|
|
|
25
23
|
template: `../scripts/react-server-dom-esm+${TEMPLATE_VERSION}.patch`,
|
|
26
24
|
output: `react-server-dom-esm+${STUB_VERSION}.patch`
|
|
27
25
|
},
|
|
26
|
+
{
|
|
27
|
+
template: `../scripts/react+${TEMPLATE_VERSION}.patch`,
|
|
28
|
+
output: `react+${PATCH_RECONCILER_VERSION}.patch`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
template: `../scripts/react-dom+${TEMPLATE_VERSION}.patch`,
|
|
32
|
+
output: `react-dom+${PATCH_RECONCILER_VERSION}.patch`
|
|
33
|
+
},
|
|
28
34
|
]
|
|
29
35
|
|
|
30
36
|
// Create patches dir in user's project
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Vite plugin for React Server Components (RSC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin/index.js",
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
".": "./dist/plugin/index.js",
|
|
20
20
|
"./client": "./dist/client.js",
|
|
21
21
|
"./server": "./dist/server.js",
|
|
22
|
+
"./static": "./dist/static.js",
|
|
22
23
|
"./html-worker": "./dist/plugin/worker/html-worker.js",
|
|
23
24
|
"./rsc-worker": "./dist/plugin/worker/rsc-worker.js",
|
|
24
25
|
"./loader": "./dist/plugin/worker/loader.js",
|
|
25
26
|
"./package.json": "./package.json",
|
|
26
27
|
"./patch": "./scripts/patch.mjs",
|
|
27
28
|
"./check-react-version": "./scripts/check-react-version.mjs",
|
|
28
|
-
"./css-loader": "./dist/plugin/loader/css-loader.js"
|
|
29
|
+
"./css-loader": "./dist/plugin/loader/css-loader.js",
|
|
30
|
+
"./components": "./dist/plugin/components.js"
|
|
29
31
|
},
|
|
30
32
|
"typesVersions": {
|
|
31
33
|
"*": {
|
|
@@ -38,11 +40,17 @@
|
|
|
38
40
|
"server": [
|
|
39
41
|
"./dist/plugin/react-server/plugin.d.ts"
|
|
40
42
|
],
|
|
43
|
+
"static": [
|
|
44
|
+
"./dist/plugin/static/plugin.d.ts"
|
|
45
|
+
],
|
|
41
46
|
"worker": [
|
|
42
47
|
"./dist/plugin/worker/worker.d.ts"
|
|
43
48
|
],
|
|
44
49
|
"loader": [
|
|
45
50
|
"./dist/plugin/worker/loader.d.ts"
|
|
51
|
+
],
|
|
52
|
+
"components": [
|
|
53
|
+
"./dist/plugin/components.d.ts"
|
|
46
54
|
]
|
|
47
55
|
}
|
|
48
56
|
},
|
|
@@ -91,8 +99,8 @@
|
|
|
91
99
|
},
|
|
92
100
|
"homepage": "https://github.com/nicobrinkkemper/vite-plugin-react-server#readme",
|
|
93
101
|
"peerDependencies": {
|
|
94
|
-
"react": "^0.0.0-experimental-
|
|
95
|
-
"react-dom": "^0.0.0-experimental-
|
|
102
|
+
"react": "^0.0.0-experimental-f9d78089-20250306",
|
|
103
|
+
"react-dom": "^0.0.0-experimental-f9d78089-20250306",
|
|
96
104
|
"vite": "*"
|
|
97
105
|
},
|
|
98
106
|
"peerDependenciesMeta": {
|
|
@@ -120,13 +128,12 @@
|
|
|
120
128
|
"typescript": "^5.7.3",
|
|
121
129
|
"vite": "^6.0.11",
|
|
122
130
|
"vitest": "^3.0.4",
|
|
123
|
-
"webpack-sources": "^3.2.3"
|
|
131
|
+
"webpack-sources": "^3.2.3",
|
|
132
|
+
"tsx": "^4.19.2"
|
|
124
133
|
},
|
|
125
134
|
"bin": {
|
|
126
135
|
"check-react-version": "./scripts/check-react-version.mjs",
|
|
127
136
|
"patch": "./bin/patch.mjs"
|
|
128
137
|
},
|
|
129
|
-
"dependencies": {
|
|
130
|
-
"tsx": "^4.19.2"
|
|
131
|
-
}
|
|
138
|
+
"dependencies": {}
|
|
132
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkFilesExist.d.ts","sourceRoot":"","sources":["../../plugin/checkFilesExist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"checkFilesExist.d.ts","sourceRoot":"","sources":["../../plugin/checkFilesExist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAY7E,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,CA+ChC"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { existsSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import 'vite';
|
|
9
8
|
import { createInputNormalizer } from './helpers/inputNormalizer.js';
|
|
10
9
|
|
|
10
|
+
let stashedFiles = null;
|
|
11
11
|
const resolveFileOption = (pageOrProps) => {
|
|
12
12
|
if (typeof pageOrProps === "string") {
|
|
13
13
|
return () => pageOrProps;
|
|
@@ -15,6 +15,9 @@ const resolveFileOption = (pageOrProps) => {
|
|
|
15
15
|
return pageOrProps;
|
|
16
16
|
};
|
|
17
17
|
async function checkFilesExist(pages, options, root) {
|
|
18
|
+
if (stashedFiles) {
|
|
19
|
+
return stashedFiles;
|
|
20
|
+
}
|
|
18
21
|
if (!root || root === "") {
|
|
19
22
|
throw new Error("Root not found");
|
|
20
23
|
}
|
|
@@ -56,7 +59,8 @@ async function checkFilesExist(pages, options, root) {
|
|
|
56
59
|
pageMap.set(pageKey, pageValue);
|
|
57
60
|
propsMap.set(propsKey, propsValue);
|
|
58
61
|
}
|
|
59
|
-
|
|
62
|
+
stashedFiles = { pageMap, pageSet, propsMap, propsSet, urlMap, errors };
|
|
63
|
+
return stashedFiles;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
export { checkFilesExist };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkFilesExist.js","sources":["../../plugin/checkFilesExist.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { CheckFilesExistReturn, ResolvedUserOptions } from \"./types.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"checkFilesExist.js","sources":["../../plugin/checkFilesExist.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { CheckFilesExistReturn, ResolvedUserOptions } from \"./types.js\";\nimport { createInputNormalizer } from \"./helpers/inputNormalizer.js\";\n\nlet stashedFiles: CheckFilesExistReturn | null = null;\n\nconst resolveFileOption = (pageOrProps: string | ((url: string) => string)) => {\n if (typeof pageOrProps === \"string\") {\n return () => pageOrProps;\n }\n return pageOrProps;\n};\n\nexport async function checkFilesExist(\n pages: string[],\n options: ResolvedUserOptions,\n root: string\n): Promise<CheckFilesExistReturn> {\n if(stashedFiles){\n return stashedFiles;\n }\n if (!root || root === \"\") {\n throw new Error(\"Root not found\");\n }\n const errors: string[] = [];\n const pageSet = new Set<string>();\n const propsSet = new Set<string>();\n const pageMap = new Map<string, string>();\n const propsMap = new Map<string, string>();\n const urlMap = new Map<string, { props: string; page: string }>();\n const normalizer = createInputNormalizer({\n root,\n preserveModulesRoot: options.build.preserveModulesRoot === true ? options.moduleBase : undefined,\n removeExtension: true,\n });\n const pageFn = resolveFileOption(options.Page);\n const propsFn = resolveFileOption(options.props);\n for (const page of pages) {\n const pagePath = pageFn(page);\n const propsPath = propsFn(page);\n const [pageKey, pageValue] = normalizer(pagePath);\n const [propsKey, propsValue] = normalizer(propsPath);\n try {\n if (!existsSync(join(root, pageValue))) {\n errors.push(\n `Page file not found: ${pagePath}, ${join(root, pagePath)}`\n );\n }\n if (!existsSync(join(root, propsValue))) {\n errors.push(\n `Props file not found: ${propsPath}, ${join(root, propsPath)}`\n );\n }\n } catch (error) {\n errors.push(`Error checking files: ${error}`);\n }\n urlMap.set(page, { props: propsPath, page: pagePath });\n pageSet.add(pagePath);\n propsSet.add(propsPath);\n pageMap.set(pageKey, pageValue);\n propsMap.set(propsKey, propsValue);\n }\n stashedFiles = { pageMap, pageSet, propsMap, propsSet, urlMap, errors };\n return stashedFiles;\n}\n"],"names":[],"mappings":";;;;;;;;;AAKA,IAAI,YAA6C,GAAA,IAAA;AAEjD,MAAM,iBAAA,GAAoB,CAAC,WAAoD,KAAA;AAC7E,EAAI,IAAA,OAAO,gBAAgB,QAAU,EAAA;AACnC,IAAA,OAAO,MAAM,WAAA;AAAA;AAEf,EAAO,OAAA,WAAA;AACT,CAAA;AAEsB,eAAA,eAAA,CACpB,KACA,EAAA,OAAA,EACA,IACgC,EAAA;AAChC,EAAA,IAAG,YAAa,EAAA;AACd,IAAO,OAAA,YAAA;AAAA;AAET,EAAI,IAAA,CAAC,IAAQ,IAAA,IAAA,KAAS,EAAI,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,gBAAgB,CAAA;AAAA;AAElC,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA;AAChC,EAAM,MAAA,QAAA,uBAAe,GAAY,EAAA;AACjC,EAAM,MAAA,OAAA,uBAAc,GAAoB,EAAA;AACxC,EAAM,MAAA,QAAA,uBAAe,GAAoB,EAAA;AACzC,EAAM,MAAA,MAAA,uBAAa,GAA6C,EAAA;AAChE,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAA;AAAA,IACA,qBAAqB,OAAQ,CAAA,KAAA,CAAM,mBAAwB,KAAA,IAAA,GAAO,QAAQ,UAAa,GAAA,SAAA;AAAA,IACvF,eAAiB,EAAA;AAAA,GAClB,CAAA;AACD,EAAM,MAAA,MAAA,GAAS,iBAAkB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC7C,EAAM,MAAA,OAAA,GAAU,iBAAkB,CAAA,OAAA,CAAQ,KAAK,CAAA;AAC/C,EAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,IAAM,MAAA,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,IAAM,MAAA,SAAA,GAAY,QAAQ,IAAI,CAAA;AAC9B,IAAA,MAAM,CAAC,OAAA,EAAS,SAAS,CAAA,GAAI,WAAW,QAAQ,CAAA;AAChD,IAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,WAAW,SAAS,CAAA;AACnD,IAAI,IAAA;AACF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,SAAS,CAAC,CAAG,EAAA;AACtC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,wBAAwB,QAAQ,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,QAAQ,CAAC,CAAA;AAAA,SAC3D;AAAA;AAEF,MAAA,IAAI,CAAC,UAAW,CAAA,IAAA,CAAK,IAAM,EAAA,UAAU,CAAC,CAAG,EAAA;AACvC,QAAO,MAAA,CAAA,IAAA;AAAA,UACL,yBAAyB,SAAS,CAAA,EAAA,EAAK,IAAK,CAAA,IAAA,EAAM,SAAS,CAAC,CAAA;AAAA,SAC9D;AAAA;AACF,aACO,KAAO,EAAA;AACd,MAAO,MAAA,CAAA,IAAA,CAAK,CAAyB,sBAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAE9C,IAAA,MAAA,CAAO,IAAI,IAAM,EAAA,EAAE,OAAO,SAAW,EAAA,IAAA,EAAM,UAAU,CAAA;AACrD,IAAA,OAAA,CAAQ,IAAI,QAAQ,CAAA;AACpB,IAAA,QAAA,CAAS,IAAI,SAAS,CAAA;AACtB,IAAQ,OAAA,CAAA,GAAA,CAAI,SAAS,SAAS,CAAA;AAC9B,IAAS,QAAA,CAAA,GAAA,CAAI,UAAU,UAAU,CAAA;AAAA;AAEnC,EAAA,YAAA,GAAe,EAAE,OAAS,EAAA,OAAA,EAAS,QAAU,EAAA,QAAA,EAAU,QAAQ,MAAO,EAAA;AACtE,EAAO,OAAA,YAAA;AACT;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Manifest, ModuleGraph } from "vite";
|
|
2
|
+
export declare function collectModuleGraphCss({ moduleGraph, pagePath, onCss, parentUrl, }: {
|
|
3
|
+
moduleGraph: ModuleGraph;
|
|
4
|
+
pagePath: string;
|
|
5
|
+
onCss?: (path: string, parentUrl: string) => void;
|
|
6
|
+
parentUrl?: string;
|
|
7
|
+
}): Promise<Map<string, string>>;
|
|
8
|
+
export declare function collectManifestClientFiles({ manifest, root, pagePath, preserveModulesRoot, moduleBase, onCss, onClientModule, testClient, testJson, }: {
|
|
9
|
+
manifest: Manifest;
|
|
10
|
+
root: string;
|
|
11
|
+
pagePath: string;
|
|
12
|
+
preserveModulesRoot?: boolean;
|
|
13
|
+
moduleBase?: string;
|
|
14
|
+
onCss?: (path: string, parentUrl: string) => void;
|
|
15
|
+
onClientModule?: (path: string, parentUrl: string) => void;
|
|
16
|
+
parentUrl?: string;
|
|
17
|
+
testClient?: (id: string) => boolean;
|
|
18
|
+
testJson?: (id: string) => boolean;
|
|
19
|
+
}): {
|
|
20
|
+
cssFiles: Map<string, string>;
|
|
21
|
+
clientFiles: Map<string, string>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=collect-manifest-client-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-manifest-client-files.d.ts","sourceRoot":"","sources":["../../plugin/collect-manifest-client-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAIlD,wBAAsB,qBAAqB,CAAC,EAC1C,WAAW,EACX,QAAQ,EACR,KAAK,EACL,SAAS,GACV,EAAE;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,gCAoBA;AAED,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,cAAc,EACd,UAA0D,EAC1D,QAAmD,GACpD,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;CACpC;;;EA6GA"}
|