vite-plugin-react-server 0.3.10 → 0.3.12
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/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +16 -14
- package/dist/plugin/assertServerCondition.d.ts +5 -1
- package/dist/plugin/assertServerCondition.d.ts.map +1 -1
- package/dist/plugin/assertServerCondition.js +1 -3
- package/dist/plugin/checkFilesExist.d.ts +2 -2
- package/dist/plugin/checkFilesExist.d.ts.map +1 -1
- package/dist/plugin/checkFilesExist.js +43 -58
- package/dist/plugin/checkFilesExist.js.map +1 -1
- package/dist/plugin/collect-css-manifest.d.ts.map +1 -1
- package/dist/plugin/collect-css-manifest.js +5 -0
- package/dist/plugin/collect-css-manifest.js.map +1 -1
- package/dist/plugin/components.js +10 -15
- package/dist/plugin/config/createModuleIdGenerator.d.ts +11 -0
- package/dist/plugin/config/createModuleIdGenerator.d.ts.map +1 -0
- package/dist/plugin/config/createModuleIdGenerator.js +44 -0
- package/dist/plugin/config/createModuleIdGenerator.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +27 -24
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +26 -31
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getPaths.js +1 -1
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +223 -16
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +2 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +2 -2
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +149 -50
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.d.ts +25 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -0
- package/dist/plugin/helpers/getBundleManifest.js +72 -0
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts +14 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +128 -16
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/tryManifest.d.ts +3 -1
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +1 -1
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +6 -2
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +37 -9
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/createPageLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createPageLoader.js +0 -7
- package/dist/plugin/loader/css-loader.d.ts +16 -0
- package/dist/plugin/loader/css-loader.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.js +70 -0
- package/dist/plugin/loader/css-loader.js.map +1 -0
- package/dist/plugin/loader/react-loader.d.ts +17 -0
- package/dist/plugin/loader/react-loader.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.js +647 -0
- package/dist/plugin/loader/react-loader.js.map +1 -0
- package/dist/plugin/loader/rsc/messageHandler.d.ts +2 -0
- package/dist/plugin/loader/rsc/messageHandler.d.ts.map +1 -0
- package/dist/plugin/loader/rsc/messageHandler.js +1 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +2 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +1 -0
- package/dist/plugin/loader/rsc/rsc-worker.development.js +1 -0
- package/dist/plugin/plugin.d.ts +0 -1
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +2 -1
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +3 -2
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +2 -1
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +19 -1
- package/dist/plugin/react-client/index.js.map +1 -0
- package/dist/plugin/react-client/plugin.d.ts +2 -2
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +283 -10
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/createHandler.d.ts +2 -2
- package/dist/plugin/react-server/createHandler.d.ts.map +1 -1
- package/dist/plugin/react-server/createHandler.js +15 -9
- package/dist/plugin/react-server/createHandler.js.map +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts +15 -3
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -1
- package/dist/plugin/react-server/createRscStream.js +53 -36
- package/dist/plugin/react-server/createRscStream.js.map +1 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts +2 -2
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -1
- package/dist/plugin/react-server/createSsrHandler.js +5 -12
- package/dist/plugin/react-server/index.js +18 -9
- package/dist/plugin/react-server/index.js.map +1 -0
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +147 -137
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.d.ts +2 -1
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +68 -75
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/types.d.ts +4 -0
- package/dist/plugin/transformer/types.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +56 -20
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/utils/logger.d.ts +9 -0
- package/dist/plugin/utils/logger.d.ts.map +1 -0
- package/dist/plugin/utils/logger.js +68 -0
- package/dist/plugin/utils/logger.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +1 -0
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +23 -36
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +5 -1
- 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 +33 -28
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/html/plugin.js +10 -5
- package/dist/plugin/worker/html/renderPages.d.ts +7 -6
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +147 -93
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/loader.d.ts +1 -11
- package/dist/plugin/worker/loader.d.ts.map +1 -1
- package/dist/plugin/worker/loader.js +2 -2
- package/dist/plugin/worker/loader.js.map +1 -1
- package/dist/plugin/worker/plugin.d.ts +10 -1
- package/dist/plugin/worker/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/plugin.js +10 -1
- package/dist/plugin/worker/rsc/index.d.ts +1 -3
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/index.js +1 -9
- package/dist/plugin/worker/rsc/index.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts +3 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.js +107 -0
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -0
- package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/plugin.js +74 -80
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +32 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.js +43 -0
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.js +4 -106
- package/dist/plugin/worker/rsc/rsc-worker.production.d.ts +2 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.js +14 -0
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -0
- package/dist/plugin/worker/rsc/state.d.ts +11 -0
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/state.js +12 -0
- package/dist/plugin/worker/rsc/state.js.map +1 -0
- package/dist/plugin/worker/types.d.ts +62 -35
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -14
- package/plugin/assertServerCondition.ts +2 -3
- package/plugin/checkFilesExist.ts +46 -66
- package/plugin/collect-css-manifest.ts +5 -1
- package/plugin/config/createModuleIdGenerator.ts +52 -0
- package/plugin/config/defaults.ts +27 -20
- package/plugin/config/resolveOptions.ts +311 -25
- package/plugin/config/resolvePages.ts +1 -1
- package/plugin/config/resolveUserConfig.ts +195 -61
- package/plugin/helpers/getBundleManifest.ts +113 -0
- package/plugin/helpers/inputNormalizer.ts +186 -25
- package/plugin/helpers/tryManifest.ts +3 -1
- package/plugin/loader/createBuildLoader.ts +50 -9
- package/plugin/loader/createPageLoader.ts +1 -7
- package/plugin/loader/css-loader.ts +96 -0
- package/plugin/loader/react-loader.ts +945 -0
- package/plugin/loader/rsc/messageHandler.tsx +1 -0
- package/plugin/loader/rsc/rsc-worker.development.ts +1 -0
- package/plugin/plugin.ts +2 -1
- package/plugin/preserver/plugin.ts +2 -1
- package/plugin/react-client/index.ts +12 -1
- package/plugin/react-client/plugin.ts +351 -11
- package/plugin/react-server/createHandler.ts +16 -18
- package/plugin/react-server/createRscStream.ts +75 -42
- package/plugin/react-server/createSsrHandler.ts +7 -26
- package/plugin/react-server/plugin.ts +192 -155
- package/plugin/transformer/plugin.ts +70 -104
- package/plugin/transformer/types.ts +4 -0
- package/plugin/types/global.d.ts +8 -0
- package/plugin/types.ts +120 -64
- package/plugin/utils/logger.ts +52 -0
- package/plugin/worker/createWorker.ts +43 -44
- package/plugin/worker/html/html-worker.production.tsx +7 -2
- package/plugin/worker/html/messageHandler.ts +42 -35
- package/plugin/worker/html/plugin.ts +15 -11
- package/plugin/worker/html/renderPages.ts +177 -123
- package/plugin/worker/loader.ts +4 -13
- package/plugin/worker/plugin.ts +10 -1
- package/plugin/worker/rsc/index.ts +4 -13
- package/plugin/worker/rsc/messageHandler.tsx +143 -0
- package/plugin/worker/rsc/plugin.ts +38 -37
- package/plugin/worker/rsc/rsc-worker.development.ts +107 -0
- package/plugin/worker/rsc/rsc-worker.production.ts +13 -0
- package/plugin/worker/rsc/rsc-worker.tsx +5 -128
- package/plugin/worker/rsc/state.ts +37 -0
- package/plugin/worker/types.ts +83 -38
- package/scripts/check-react-version.mjs +17 -7
- package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +143 -4170
- package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +14271 -90079
- package/dist/node_modules/magic-string/dist/magic-string.es.js +0 -1283
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +0 -1
- package/dist/plugin/build/createClientBuildConfig.d.ts +0 -3
- package/dist/plugin/build/createClientBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createClientBuildConfig.js +0 -14
- package/dist/plugin/build/createServerBuildConfig.d.ts +0 -12
- package/dist/plugin/build/createServerBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createServerBuildConfig.js +0 -40
- package/dist/plugin/build/createSharedBuildConfig.d.ts +0 -5
- package/dist/plugin/build/createSharedBuildConfig.d.ts.map +0 -1
- package/dist/plugin/build/createSharedBuildConfig.js +0 -28
- package/dist/plugin/build/mergeInputs.d.ts +0 -9
- package/dist/plugin/build/mergeInputs.d.ts.map +0 -1
- package/dist/plugin/build/mergeInputs.js +0 -56
- package/dist/plugin/components.js.map +0 -1
- package/dist/plugin/config/moduleIdDefault.d.ts +0 -8
- package/dist/plugin/config/moduleIdDefault.d.ts.map +0 -1
- package/dist/plugin/config/moduleIdDefault.js +0 -23
- package/dist/plugin/config/moduleIdDefault.js.map +0 -1
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts +0 -8
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createClientInputNormalizer.js +0 -35
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts +0 -9
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createServerInputNormalizer.js +0 -37
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +0 -7
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +0 -1
- package/dist/plugin/helpers/createStaticInputNormalizer.js +0 -18
- package/dist/plugin/helpers/getModuleManifest.d.ts +0 -12
- package/dist/plugin/helpers/getModuleManifest.d.ts.map +0 -1
- package/dist/plugin/helpers/getModuleManifest.js +0 -24
- package/dist/plugin/helpers/getModuleManifest.js.map +0 -1
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts +0 -11
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +0 -1
- package/dist/plugin/helpers/inputNormalizerWorker.js +0 -30
- package/dist/plugin/helpers/normalizedRelativePath.d.ts +0 -11
- package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +0 -1
- package/dist/plugin/helpers/normalizedRelativePath.js +0 -36
- package/dist/plugin/helpers/resolveFilePath.d.ts +0 -13
- package/dist/plugin/helpers/resolveFilePath.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveFilePath.js +0 -74
- package/dist/plugin/helpers/resolveWorkerModule.d.ts +0 -6
- package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveWorkerModule.js +0 -24
- package/dist/plugin/helpers/validateModuleBase.d.ts +0 -3
- package/dist/plugin/helpers/validateModuleBase.d.ts.map +0 -1
- package/dist/plugin/helpers/validateModuleBase.js +0 -16
- package/dist/plugin/helpers/validateResolvedConfig.d.ts +0 -3
- package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +0 -1
- package/dist/plugin/helpers/validateResolvedConfig.js +0 -17
- package/dist/plugin/react-server/createDevMiddleware.d.ts +0 -8
- package/dist/plugin/react-server/createDevMiddleware.d.ts.map +0 -1
- package/dist/plugin/react-server/createDevMiddleware.js +0 -68
- package/dist/plugin/react-server/createDevServer.d.ts +0 -4
- package/dist/plugin/react-server/createDevServer.d.ts.map +0 -1
- package/dist/plugin/react-server/createDevServer.js +0 -4
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts +0 -10
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +0 -1
- package/dist/plugin/react-server/createReactNodeStreamer.js +0 -7
- package/dist/plugin/transformer/transformer-client-components.d.ts +0 -21
- package/dist/plugin/transformer/transformer-client-components.d.ts.map +0 -1
- package/dist/plugin/transformer/transformer-client-components.js +0 -61
- package/dist/plugin/transformer/transformer-client-components.js.map +0 -1
- package/dist/plugin/transformer/transformer-server-actions.d.ts +0 -29
- package/dist/plugin/transformer/transformer-server-actions.d.ts.map +0 -1
- package/dist/plugin/transformer/transformer-server-actions.js +0 -76
- package/dist/plugin/transformer/transformer-server-actions.js.map +0 -1
- package/dist/plugin/worker/rsc/createRscStream.d.ts +0 -5
- package/dist/plugin/worker/rsc/createRscStream.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/createRscStream.js +0 -39
- package/dist/plugin/worker/rsc/createRscStream.js.map +0 -1
- package/dist/plugin/worker/rsc/development.d.ts +0 -5
- package/dist/plugin/worker/rsc/development.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/development.js +0 -13
- package/dist/plugin/worker/rsc/development.js.map +0 -1
- package/dist/plugin/worker/rsc/plugin.js.map +0 -1
- package/dist/plugin/worker/rsc/production.d.ts +0 -5
- package/dist/plugin/worker/rsc/production.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/production.js +0 -13
- package/dist/plugin/worker/rsc/production.js.map +0 -1
- package/plugin/build/createClientBuildConfig.ts +0 -21
- package/plugin/build/createServerBuildConfig.ts +0 -66
- package/plugin/build/createSharedBuildConfig.ts +0 -35
- package/plugin/build/mergeInputs.ts +0 -58
- package/plugin/config/moduleIdDefault.ts +0 -23
- package/plugin/helpers/createClientInputNormalizer.ts +0 -48
- package/plugin/helpers/createServerInputNormalizer.ts +0 -52
- package/plugin/helpers/createStaticInputNormalizer.ts +0 -26
- package/plugin/helpers/getModuleManifest.ts +0 -31
- package/plugin/helpers/inputNormalizerWorker.ts +0 -47
- package/plugin/helpers/normalizedRelativePath.ts +0 -59
- package/plugin/helpers/resolveFilePath.ts +0 -108
- package/plugin/helpers/resolveWorkerModule.ts +0 -41
- package/plugin/helpers/validateModuleBase.ts +0 -30
- package/plugin/helpers/validateResolvedConfig.ts +0 -21
- package/plugin/react-server/createDevMiddleware.ts +0 -91
- package/plugin/react-server/createDevServer.ts +0 -9
- package/plugin/react-server/createReactNodeStreamer.ts +0 -26
- package/plugin/transformer/transformer-client-components.ts +0 -94
- package/plugin/transformer/transformer-server-actions.ts +0 -110
- package/plugin/worker/rsc/createRscStream.ts +0 -42
- package/plugin/worker/rsc/development.ts +0 -6
- package/plugin/worker/rsc/production.ts +0 -6
- package/scripts/react-server-dom-esm+0.0.1.patch +0 -24775
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This file can be overridden via the plugin options:
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* reactStreamPlugin({
|
|
7
|
-
* loaderPath: './my-custom-loader.ts'
|
|
8
|
-
* })
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* The default loader provides basic module loading functionality.
|
|
12
|
-
* Override this if you need custom module resolution or transformation.
|
|
2
|
+
* Not used currently
|
|
13
3
|
*/
|
|
14
4
|
export declare function load(id: string): Promise<any>;
|
|
15
5
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../plugin/worker/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../plugin/worker/loader.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,gBAEpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sources":["../../../plugin/worker/loader.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"loader.js","sources":["../../../plugin/worker/loader.ts"],"sourcesContent":["\n/**\n * Not used currently\n */\nexport async function load(id: string) {\n return await import(id);\n}\n"],"names":[],"mappings":";;;;;AAIA,eAAsB,KAAK,EAAY,EAAA;AACrC,EAAA,OAAO,MAAM,OAAO,EAAA,CAAA;AACtB;;;;"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { StreamPluginOptions } from "../types.js";
|
|
2
2
|
import type { Plugin } from "vite";
|
|
3
3
|
/**
|
|
4
|
-
* This plugin can be used to create your own worker paths.
|
|
4
|
+
* This plugin can be used to create your own worker paths. This build should be separated from the main build.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @example
|
|
9
|
+
*export reactWorkerPluginConfig = {
|
|
10
|
+
* htmlWorkerPath: './workers/html.tsx',
|
|
11
|
+
* rscWorkerPath: './workers/rsc.tsx',
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
5
14
|
*
|
|
6
15
|
* @param options
|
|
7
16
|
* @returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/worker/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/worker/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAKxE"}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { reactHtmlWorkerPlugin } from "./html/plugin.js";
|
|
2
2
|
import { reactRscWorkerPlugin } from "./rsc/plugin.js";
|
|
3
3
|
/**
|
|
4
|
-
* This plugin can be used to create your own worker paths.
|
|
4
|
+
* This plugin can be used to create your own worker paths. This build should be separated from the main build.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* @example
|
|
9
|
+
*export reactWorkerPluginConfig = {
|
|
10
|
+
* htmlWorkerPath: './workers/html.tsx',
|
|
11
|
+
* rscWorkerPath: './workers/rsc.tsx',
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
5
14
|
*
|
|
6
15
|
* @param options
|
|
7
16
|
* @returns
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export declare const worker: typeof import("./production.js");
|
|
3
|
-
export declare const createRscStream: typeof import("./createRscStream.js").createRscStream, createWorker: typeof import("../createWorker.js").createWorker;
|
|
1
|
+
export {};
|
|
4
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/index.ts"],"names":[],"mappings":""}
|
|
@@ -3,13 +3,5 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const worker = await (process.env["NODE_ENV"] === "production" ? import('./production.js') : import('./development.js'));
|
|
9
|
-
const {
|
|
10
|
-
createRscStream,
|
|
11
|
-
createWorker
|
|
12
|
-
} = worker;
|
|
13
|
-
|
|
14
|
-
export { createRscStream, createWorker, worker };
|
|
6
|
+
await (process.env["NODE_ENV"] === "production" ? import('./rsc-worker.production.js') : import('./rsc-worker.development.js'));
|
|
15
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../plugin/worker/rsc/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../plugin/worker/rsc/index.ts"],"sourcesContent":["await(\n process.env[\"NODE_ENV\"] === \"production\"\n ? import(\"./rsc-worker.production.js\")\n : import(\"./rsc-worker.development.js\")\n);\n"],"names":[],"mappings":";;;;;AAAA,OACE,OAAA,CAAQ,IAAI,UAAU,CAAA,KAAM,eACxB,OAAO,4BAA4B,CACnC,GAAA,OAAO,6BAA6B,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/messageHandler.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAoCrB,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,iBA6F7D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { parentPort } from 'node:worker_threads';
|
|
10
|
+
import { PassThrough } from 'node:stream';
|
|
11
|
+
import { renderToPipeableStream } from 'react-server-dom-esm/server.node';
|
|
12
|
+
import { createLogger } from '../../utils/logger.js';
|
|
13
|
+
import { cssFiles, addCssFile } from './state.js';
|
|
14
|
+
import React__default from 'react';
|
|
15
|
+
|
|
16
|
+
const log = createLogger("rsc-worker");
|
|
17
|
+
function CssCollector({
|
|
18
|
+
children,
|
|
19
|
+
cssFiles: cssFiles2
|
|
20
|
+
}) {
|
|
21
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, Array.from(cssFiles2.entries()).map(([id, css]) => {
|
|
22
|
+
return /* @__PURE__ */ React__default.createElement("style", { key: id, "data-source": id }, css);
|
|
23
|
+
}), children);
|
|
24
|
+
}
|
|
25
|
+
async function messageHandler(message) {
|
|
26
|
+
if (message.type === "RSC_RENDER") {
|
|
27
|
+
const {
|
|
28
|
+
id,
|
|
29
|
+
pageImport,
|
|
30
|
+
propsImport,
|
|
31
|
+
pageExportName,
|
|
32
|
+
propsExportName,
|
|
33
|
+
url,
|
|
34
|
+
outDir,
|
|
35
|
+
projectRoot,
|
|
36
|
+
moduleBaseURL,
|
|
37
|
+
moduleBasePath,
|
|
38
|
+
pipableStreamOptions
|
|
39
|
+
} = message;
|
|
40
|
+
try {
|
|
41
|
+
const [Component, propsModule] = await Promise.all([
|
|
42
|
+
import(join(projectRoot, pageImport)),
|
|
43
|
+
import(join(projectRoot, propsImport))
|
|
44
|
+
]);
|
|
45
|
+
const propsAtExport = propsModule[propsExportName];
|
|
46
|
+
const props = await Promise.resolve(
|
|
47
|
+
typeof propsAtExport === "function" ? propsAtExport(url) : propsAtExport
|
|
48
|
+
);
|
|
49
|
+
const PageComponent = Component[pageExportName];
|
|
50
|
+
const stream = renderToPipeableStream(
|
|
51
|
+
/* @__PURE__ */ React__default.createElement(CssCollector, { cssFiles }, /* @__PURE__ */ React__default.createElement(PageComponent, { ...props })),
|
|
52
|
+
moduleBaseURL,
|
|
53
|
+
{
|
|
54
|
+
onError: (error) => {
|
|
55
|
+
log.error(`Stream error at ${id}:`, error);
|
|
56
|
+
parentPort?.postMessage({
|
|
57
|
+
type: "ERROR",
|
|
58
|
+
id,
|
|
59
|
+
error: error instanceof Error ? error.message : String(error)
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
onPostpone: log?.info ?? console.info,
|
|
63
|
+
environmentName: "Server",
|
|
64
|
+
importMap: {
|
|
65
|
+
imports: {
|
|
66
|
+
...pipableStreamOptions?.importMap?.imports,
|
|
67
|
+
"/": moduleBasePath
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
...pipableStreamOptions
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
const passThrough = new PassThrough();
|
|
74
|
+
stream.pipe(passThrough);
|
|
75
|
+
passThrough.on("data", (chunk) => {
|
|
76
|
+
parentPort?.postMessage({
|
|
77
|
+
type: "RSC_CHUNK",
|
|
78
|
+
id,
|
|
79
|
+
chunk: chunk.toString(),
|
|
80
|
+
moduleRootPath: moduleBasePath,
|
|
81
|
+
moduleBaseURL,
|
|
82
|
+
outDir,
|
|
83
|
+
rscOutputPath: `${outDir}/${id}.rsc`,
|
|
84
|
+
cssFiles: Array.from(cssFiles.entries())
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
passThrough.on("end", () => {
|
|
88
|
+
parentPort?.postMessage({
|
|
89
|
+
type: "RSC_END",
|
|
90
|
+
id
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.trace(error);
|
|
95
|
+
parentPort?.postMessage({
|
|
96
|
+
type: "ERROR",
|
|
97
|
+
id,
|
|
98
|
+
error: error instanceof Error ? error.message : String(error)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
} else if (message.type === "CSS_FILE") {
|
|
102
|
+
addCssFile(message.id, message.cssFile);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { messageHandler };
|
|
107
|
+
//# sourceMappingURL=messageHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageHandler.js","sources":["../../../../plugin/worker/rsc/messageHandler.tsx"],"sourcesContent":["import { createWriteStream } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { parentPort } from \"node:worker_threads\";\nimport { PassThrough } from \"node:stream\";\nimport {\n renderToPipeableStream,\n // @ts-ignore\n} from \"react-server-dom-esm/server.node\";\nimport type {\n RscChunkMessage,\n RscEndMessage,\n RscWorkerMessage,\n} from \"../types.js\";\nimport { createLogger } from \"../../utils/logger.js\";\nimport {\n cssFiles,\n clientFiles,\n serverActionFiles,\n addCssFile,\n clearCssFiles,\n} from \"./state.js\";\nimport type { WriteStream } from \"node:fs\";\nimport React from \"react\";\n\nconst log = createLogger(\"rsc-worker\");\n\n// CSS collector component\nfunction CssCollector({\n children,\n cssFiles,\n}: {\n children: React.ReactNode;\n cssFiles: Map<string, string>;\n}) {\n return (\n <>\n {Array.from(cssFiles.entries()).map(([id, css]) => {\n return (\n <style key={id} data-source={id}>\n {css}\n </style>\n );\n })}\n {children}\n </>\n );\n}\n\nexport async function messageHandler(message: RscWorkerMessage) {\n\n if (message.type === \"RSC_RENDER\") {\n const {\n id,\n pageImport,\n propsImport,\n pageExportName,\n propsExportName,\n url,\n outDir,\n projectRoot,\n moduleBaseURL,\n moduleBasePath,\n pipableStreamOptions,\n } = message;\n\n try {\n // Load modules which will trigger CSS loading\n const [Component, propsModule] = await Promise.all([\n import(join(projectRoot, pageImport)),\n import(join(projectRoot, propsImport)),\n ]);\n\n const propsAtExport = propsModule[propsExportName];\n const props = await Promise.resolve(\n typeof propsAtExport === \"function\" ? propsAtExport(url) : propsAtExport\n );\n\n const PageComponent = Component[pageExportName];\n // Now render with collected CSS\n const stream = renderToPipeableStream(\n <CssCollector cssFiles={cssFiles}>\n <PageComponent {...props} />\n </CssCollector>,\n moduleBaseURL,\n {\n onError: (error: Error) => {\n log.error(`Stream error at ${id}:`, error);\n parentPort?.postMessage({\n type: \"ERROR\",\n id,\n error: error instanceof Error ? error.message : String(error),\n });\n },\n onPostpone: log?.info ?? console.info,\n environmentName: \"Server\",\n importMap: {\n imports: {\n ...pipableStreamOptions?.importMap?.imports,\n \"/\": moduleBasePath,\n },\n },\n ...pipableStreamOptions,\n }\n );\n\n // Listen for data and end events\n const passThrough = new PassThrough();\n\n stream.pipe(passThrough);\n\n passThrough.on(\"data\", (chunk) => {\n // Send to parent\n parentPort?.postMessage({\n type: \"RSC_CHUNK\",\n id,\n chunk: chunk.toString(),\n moduleRootPath: moduleBasePath,\n moduleBaseURL,\n outDir,\n rscOutputPath: `${outDir}/${id}.rsc`,\n cssFiles: Array.from(cssFiles.entries()),\n } satisfies RscChunkMessage);\n });\n\n passThrough.on(\"end\", () => {\n parentPort?.postMessage({\n type: \"RSC_END\",\n id,\n } satisfies RscEndMessage);\n });\n } catch (error) {\n console.trace(error);\n parentPort?.postMessage({\n type: \"ERROR\",\n id,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n } else if (message.type === \"CSS_FILE\") {\n addCssFile(message.id, message.cssFile);\n }\n}\n"],"names":["cssFiles","React"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAI1D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAI1D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA4EzE"}
|
|
@@ -1,82 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
import { DEFAULT_CONFIG } from "../../config/defaults.js";
|
|
3
|
+
import { getPluginRoot } from "../../config/getPaths.js";
|
|
4
|
+
export function reactRscWorkerPlugin(options) {
|
|
5
|
+
return {
|
|
6
|
+
name: "vite:react-rsc-worker",
|
|
7
|
+
config(config) {
|
|
8
|
+
const root = config.root ?? process.cwd();
|
|
9
|
+
const pluginRoot = getPluginRoot();
|
|
10
|
+
const rscWorkerPath = typeof options.rscWorkerPath === "string"
|
|
11
|
+
? resolve(root, options.rscWorkerPath)
|
|
12
|
+
: resolve(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);
|
|
13
|
+
const format = "esm";
|
|
14
|
+
// Single worker output for server build
|
|
15
|
+
const workerConfig = {
|
|
16
|
+
input: {
|
|
17
|
+
"rsc-worker": rscWorkerPath,
|
|
18
|
+
},
|
|
19
|
+
output: {
|
|
20
|
+
format,
|
|
21
|
+
dir: options.build?.server ?? "dist/server", // Output to server directory
|
|
22
|
+
entryFileNames: "[name].js",
|
|
23
|
+
preserveModules: true,
|
|
24
|
+
manualChunks: {
|
|
25
|
+
"rsc-worker": [rscWorkerPath],
|
|
26
|
+
},
|
|
27
|
+
resolve: {
|
|
28
|
+
conditions: ["react-server"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
build: {
|
|
34
|
+
rollupOptions: {
|
|
35
|
+
preserveEntrySignatures: "strict",
|
|
36
|
+
input: {
|
|
37
|
+
...workerConfig.input,
|
|
38
|
+
...(typeof config.build?.rollupOptions?.input === "object"
|
|
39
|
+
? config.build?.rollupOptions?.input
|
|
40
|
+
: {}),
|
|
41
|
+
},
|
|
42
|
+
external: [
|
|
43
|
+
"vite",
|
|
44
|
+
"rollup",
|
|
45
|
+
"react",
|
|
46
|
+
"react-dom",
|
|
47
|
+
"react-dom/server",
|
|
48
|
+
"react-server-dom-esm",
|
|
49
|
+
"react-server-dom-esm/client.node",
|
|
50
|
+
"react-server-dom-esm/server.node",
|
|
51
|
+
"react-server-dom-esm/node-loader",
|
|
52
|
+
"source-map",
|
|
53
|
+
"acorn-loose",
|
|
54
|
+
"webpack-sources",
|
|
55
|
+
"stream",
|
|
56
|
+
"util",
|
|
57
|
+
"crypto",
|
|
58
|
+
"async_hooks",
|
|
59
|
+
"fs",
|
|
60
|
+
"path",
|
|
61
|
+
"worker_threads",
|
|
62
|
+
// if we use node: paths in our code, it should always be catched by below rule.
|
|
63
|
+
/^node:.*/,
|
|
64
|
+
],
|
|
65
|
+
output: {
|
|
66
|
+
...workerConfig.output,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
manifest: true, // Ensure manifest is generated
|
|
70
|
+
minify: false,
|
|
71
|
+
sourcemap: true,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
21
74
|
},
|
|
22
|
-
|
|
23
|
-
format,
|
|
24
|
-
dir: options.build?.server ?? "dist/server",
|
|
25
|
-
// Output to server directory
|
|
26
|
-
entryFileNames: "[name].js",
|
|
27
|
-
preserveModules: true,
|
|
28
|
-
manualChunks: {
|
|
29
|
-
"rsc-worker": [rscWorkerPath]
|
|
30
|
-
},
|
|
31
|
-
resolve: {
|
|
32
|
-
conditions: ["react-server"]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
build: {
|
|
38
|
-
rollupOptions: {
|
|
39
|
-
preserveEntrySignatures: "strict",
|
|
40
|
-
input: {
|
|
41
|
-
...workerConfig.input,
|
|
42
|
-
...typeof config.build?.rollupOptions?.input === "object" ? config.build?.rollupOptions?.input : {}
|
|
43
|
-
},
|
|
44
|
-
external: [
|
|
45
|
-
"vite",
|
|
46
|
-
"rollup",
|
|
47
|
-
"react",
|
|
48
|
-
"react-dom",
|
|
49
|
-
"react-dom/server",
|
|
50
|
-
"react-server-dom-esm",
|
|
51
|
-
"react-server-dom-esm/client.node",
|
|
52
|
-
"react-server-dom-esm/server.node",
|
|
53
|
-
"react-server-dom-esm/node-loader",
|
|
54
|
-
"source-map",
|
|
55
|
-
"acorn-loose",
|
|
56
|
-
"webpack-sources",
|
|
57
|
-
"stream",
|
|
58
|
-
"util",
|
|
59
|
-
"crypto",
|
|
60
|
-
"async_hooks",
|
|
61
|
-
"fs",
|
|
62
|
-
"path",
|
|
63
|
-
"worker_threads",
|
|
64
|
-
// if we use node: paths in our code, it should always be catched by below rule.
|
|
65
|
-
/^node:.*/
|
|
66
|
-
],
|
|
67
|
-
output: {
|
|
68
|
-
...workerConfig.output
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
manifest: true,
|
|
72
|
-
// Ensure manifest is generated
|
|
73
|
-
minify: false,
|
|
74
|
-
sourcemap: true
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
};
|
|
75
|
+
};
|
|
79
76
|
}
|
|
80
|
-
|
|
81
|
-
export { reactRscWorkerPlugin };
|
|
82
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare module 'node:module' {
|
|
2
|
+
interface ImportAttributes {
|
|
3
|
+
[key: string]: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface ResolveHookContext {
|
|
6
|
+
conditions: string[];
|
|
7
|
+
parentURL: string | undefined;
|
|
8
|
+
importAttributes: ImportAttributes;
|
|
9
|
+
}
|
|
10
|
+
interface LoadHookContext {
|
|
11
|
+
conditions: string[];
|
|
12
|
+
format: ModuleFormat | null | undefined;
|
|
13
|
+
importAttributes: ImportAttributes;
|
|
14
|
+
shortCircuit?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface ResolveResult {
|
|
17
|
+
url: string;
|
|
18
|
+
shortCircuit: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface LoadResult {
|
|
21
|
+
format: string;
|
|
22
|
+
source: string | SharedArrayBuffer | Uint8Array;
|
|
23
|
+
shortCircuit: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface HooksAPI {
|
|
26
|
+
resolve?: (specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context: ResolveHookContext) => ResolveResult) => ResolveResult;
|
|
27
|
+
load?: (url: string, context: LoadHookContext, nextLoad: (url: string, context: LoadHookContext) => LoadResult) => LoadResult;
|
|
28
|
+
}
|
|
29
|
+
function registerHooks(hooks: HooksAPI): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=rsc-worker.development.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAiB,gBAAgB;QAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC;IAED,UAAiB,kBAAkB;QACjC,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,gBAAgB,EAAE,gBAAgB,CAAC;KACpC;IAED,UAAiB,eAAe;QAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;QACxC,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB;IAED,UAAiB,aAAa;QAC5B,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,OAAO,CAAC;KACvB;IAED,UAAiB,UAAU;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,UAAU,CAAC;QAChD,YAAY,EAAE,OAAO,CAAC;KACvB;IAED,UAAiB,QAAQ;QACvB,OAAO,CAAC,EAAE,CACR,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,KAAK,aAAa,KAC3E,aAAa,CAAC;QAEnB,IAAI,CAAC,EAAE,CACL,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,UAAU,KAC5D,UAAU,CAAC;KACjB;IAED,SAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACtD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { MessageChannel, parentPort } from 'node:worker_threads';
|
|
7
|
+
import { messageHandler } from './messageHandler.js';
|
|
8
|
+
import { register } from 'node:module';
|
|
9
|
+
import { register as register$1 } from 'tsx/esm/api';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { getPluginRoot } from '../../config/getPaths.js';
|
|
12
|
+
|
|
13
|
+
new MessageChannel();
|
|
14
|
+
if (!parentPort) {
|
|
15
|
+
throw new Error("This module must be run as a worker");
|
|
16
|
+
}
|
|
17
|
+
const reactLoaderChannel = new MessageChannel();
|
|
18
|
+
const cssLoaderChannel = new MessageChannel();
|
|
19
|
+
reactLoaderChannel.port2.on("message", (msg) => {
|
|
20
|
+
messageHandler(msg);
|
|
21
|
+
});
|
|
22
|
+
cssLoaderChannel.port2.on("message", (msg) => {
|
|
23
|
+
messageHandler(msg);
|
|
24
|
+
});
|
|
25
|
+
const loaderPath = "file://" + join(getPluginRoot(), "loader/react-loader.js");
|
|
26
|
+
const cssLoaderPath = "file://" + join(getPluginRoot(), "loader/css-loader.js");
|
|
27
|
+
console.log("[worker] Full loader path:", loaderPath);
|
|
28
|
+
register(loaderPath, {
|
|
29
|
+
parentURL: getPluginRoot(),
|
|
30
|
+
data: { port: reactLoaderChannel.port1 },
|
|
31
|
+
transferList: [reactLoaderChannel.port1]
|
|
32
|
+
});
|
|
33
|
+
register(cssLoaderPath, {
|
|
34
|
+
parentURL: getPluginRoot(),
|
|
35
|
+
data: { port: cssLoaderChannel.port1 },
|
|
36
|
+
transferList: [cssLoaderChannel.port1]
|
|
37
|
+
});
|
|
38
|
+
register$1();
|
|
39
|
+
parentPort.on("message", (message) => {
|
|
40
|
+
messageHandler(message);
|
|
41
|
+
});
|
|
42
|
+
parentPort.postMessage({ type: "READY", env: "development" });
|
|
43
|
+
//# sourceMappingURL=rsc-worker.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-worker.development.js","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"sourcesContent":["// no offical types for node:module available yet (23.7.0)\ndeclare module 'node:module' {\n export interface ImportAttributes {\n [key: string]: string | undefined;\n }\n\n export interface ResolveHookContext {\n conditions: string[];\n parentURL: string | undefined;\n importAttributes: ImportAttributes;\n }\n\n export interface LoadHookContext {\n conditions: string[];\n format: ModuleFormat | null | undefined;\n importAttributes: ImportAttributes;\n shortCircuit?: boolean;\n }\n\n export interface ResolveResult {\n url: string;\n shortCircuit: boolean;\n }\n\n export interface LoadResult {\n format: string;\n source: string | SharedArrayBuffer | Uint8Array;\n shortCircuit: boolean;\n }\n\n export interface HooksAPI {\n resolve?: (\n specifier: string,\n context: ResolveHookContext,\n nextResolve: (specifier: string, context: ResolveHookContext) => ResolveResult\n ) => ResolveResult;\n\n load?: (\n url: string,\n context: LoadHookContext,\n nextLoad: (url: string, context: LoadHookContext) => LoadResult\n ) => LoadResult;\n }\n\n export function registerHooks(hooks: HooksAPI): void;\n}\n//\nimport { parentPort, MessageChannel } from \"node:worker_threads\";\nimport { messageHandler } from \"./messageHandler.js\";\nimport { createLogger } from \"../../utils/logger.js\";\nimport { \n registerHooks,\n register,\n type ResolveHookContext,\n} from 'node:module';\nimport { register as registerTsx } from \"tsx/esm/api\";\nimport { join } from 'node:path';\nimport { getPluginRoot } from \"../../config/getPaths.js\";\n\nconst ports = new MessageChannel();\n// Initialize worker\nif (!parentPort) {\n throw new Error(\"This module must be run as a worker\");\n}\n\n// Create channels for each loader\nconst reactLoaderChannel = new MessageChannel();\nconst cssLoaderChannel = new MessageChannel();\n\n// Listen for messages from loaders\nreactLoaderChannel.port2.on('message', (msg) => {\n messageHandler(msg);\n});\n\ncssLoaderChannel.port2.on('message', (msg) => {\n messageHandler(msg);\n});\n\nconst loaderPath = 'file://' + join(getPluginRoot(), 'loader/react-loader.js');\nconst cssLoaderPath = 'file://' + join(getPluginRoot(), 'loader/css-loader.js');\nconsole.log('[worker] Full loader path:', loaderPath);\n\n// Register react-loader\nregister(loaderPath, {\n parentURL: getPluginRoot(),\n data: { port: reactLoaderChannel.port1 },\n transferList: [reactLoaderChannel.port1]\n});\nregister(cssLoaderPath, {\n parentURL: getPluginRoot(),\n data: { port: cssLoaderChannel.port1 },\n transferList: [cssLoaderChannel.port1]\n});\n\n// Register loaders\nregisterTsx();\n\n// Set up message handling\nparentPort.on(\"message\", (message) => {\n messageHandler(message);\n});\n\n// Signal ready\nparentPort.postMessage({ type: \"READY\", env: \"development\" });\n\n\n\n"],"names":["registerTsx"],"mappings":";;;;;;;;;;;;AA2Dc,IAAI,cAAe;AAEjC,IAAI,CAAC,UAAY,EAAA;AACf,EAAM,MAAA,IAAI,MAAM,qCAAqC,CAAA;AACvD;AAGA,MAAM,kBAAA,GAAqB,IAAI,cAAe,EAAA;AAC9C,MAAM,gBAAA,GAAmB,IAAI,cAAe,EAAA;AAG5C,kBAAA,CAAmB,KAAM,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,GAAQ,KAAA;AAC9C,EAAA,cAAA,CAAe,GAAG,CAAA;AACpB,CAAC,CAAA;AAED,gBAAA,CAAiB,KAAM,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,GAAQ,KAAA;AAC5C,EAAA,cAAA,CAAe,GAAG,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,UAAa,GAAA,SAAA,GAAY,IAAK,CAAA,aAAA,IAAiB,wBAAwB,CAAA;AAC7E,MAAM,aAAgB,GAAA,SAAA,GAAY,IAAK,CAAA,aAAA,IAAiB,sBAAsB,CAAA;AAC9E,OAAQ,CAAA,GAAA,CAAI,8BAA8B,UAAU,CAAA;AAGpD,QAAA,CAAS,UAAY,EAAA;AAAA,EACnB,WAAW,aAAc,EAAA;AAAA,EACzB,IAAM,EAAA,EAAE,IAAM,EAAA,kBAAA,CAAmB,KAAM,EAAA;AAAA,EACvC,YAAA,EAAc,CAAC,kBAAA,CAAmB,KAAK;AACzC,CAAC,CAAA;AACD,QAAA,CAAS,aAAe,EAAA;AAAA,EACtB,WAAW,aAAc,EAAA;AAAA,EACzB,IAAM,EAAA,EAAE,IAAM,EAAA,gBAAA,CAAiB,KAAM,EAAA;AAAA,EACrC,YAAA,EAAc,CAAC,gBAAA,CAAiB,KAAK;AACvC,CAAC,CAAA;AAGDA,UAAY,EAAA;AAGZ,UAAW,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,OAAY,KAAA;AACpC,EAAA,cAAA,CAAe,OAAO,CAAA;AACxB,CAAC,CAAA;AAGD,UAAA,CAAW,YAAY,EAAE,IAAA,EAAM,OAAS,EAAA,GAAA,EAAK,eAAe,CAAA"}
|
|
@@ -1,106 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { registerClientReference, registerServerReference
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
} from "react-server-dom-esm/server.node";
|
|
8
|
-
import { createRscStream } from "./createRscStream.js";
|
|
9
|
-
if (!parentPort) {
|
|
10
|
-
throw new Error("This module must be run as a worker");
|
|
11
|
-
}
|
|
12
|
-
// Track active renders
|
|
13
|
-
const activeRenders = new Map();
|
|
14
|
-
const activeStreams = new Map();
|
|
15
|
-
const activeWrites = new Map();
|
|
16
|
-
async function shutdown() {
|
|
17
|
-
console.log("[RSC Worker] Shutting down forcefully");
|
|
18
|
-
for (const stream of activeStreams.values()) {
|
|
19
|
-
stream.abort();
|
|
20
|
-
}
|
|
21
|
-
for (const writeStream of activeWrites.values()) {
|
|
22
|
-
writeStream.destroy();
|
|
23
|
-
}
|
|
24
|
-
process.exit(0);
|
|
25
|
-
}
|
|
26
|
-
function sendMessage(message) {
|
|
27
|
-
parentPort?.postMessage(message);
|
|
28
|
-
}
|
|
29
|
-
// Handle incoming messages
|
|
30
|
-
parentPort.on("message", async (message) => {
|
|
31
|
-
if (message.type === "SHUTDOWN") {
|
|
32
|
-
await shutdown();
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
switch (message.type) {
|
|
37
|
-
case "RSC_RENDER": {
|
|
38
|
-
const { id, pageImport, propsImport, outDir, moduleRootPath, moduleBaseURL, pipableStreamOptions } = message;
|
|
39
|
-
// Skip if already rendered
|
|
40
|
-
if (activeRenders.has(id))
|
|
41
|
-
return;
|
|
42
|
-
// Create render state
|
|
43
|
-
const renderState = {
|
|
44
|
-
id,
|
|
45
|
-
outDir,
|
|
46
|
-
moduleRootPath,
|
|
47
|
-
moduleBaseURL,
|
|
48
|
-
rscOutputPath: `${outDir}/${id}.rsc`,
|
|
49
|
-
componentImport: pageImport,
|
|
50
|
-
propsImport,
|
|
51
|
-
pipableStreamOptions
|
|
52
|
-
};
|
|
53
|
-
// Ensure output directory exists
|
|
54
|
-
await mkdir(dirname(renderState.rscOutputPath), { recursive: true });
|
|
55
|
-
const writeStream = createWriteStream(renderState.rscOutputPath);
|
|
56
|
-
// Create stream
|
|
57
|
-
const stream = createRscStream(renderState, writeStream, parentPort);
|
|
58
|
-
// Track active streams
|
|
59
|
-
activeRenders.set(id, renderState);
|
|
60
|
-
activeStreams.set(id, stream);
|
|
61
|
-
activeWrites.set(id, writeStream);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case "RSC_END": {
|
|
65
|
-
const { id } = message;
|
|
66
|
-
activeRenders.delete(id);
|
|
67
|
-
activeStreams.delete(id);
|
|
68
|
-
activeWrites.delete(id);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "CLIENT_REFERENCE": {
|
|
72
|
-
const { id, location, key } = message;
|
|
73
|
-
const ref = registerClientReference(id, location, key);
|
|
74
|
-
sendMessage({
|
|
75
|
-
type: "CLIENT_REFERENCE",
|
|
76
|
-
id,
|
|
77
|
-
location,
|
|
78
|
-
key,
|
|
79
|
-
ref
|
|
80
|
-
});
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case "SERVER_REFERENCE": {
|
|
84
|
-
const { id, location, key } = message;
|
|
85
|
-
const ref = registerServerReference(id, location, key);
|
|
86
|
-
sendMessage({
|
|
87
|
-
type: "SERVER_REFERENCE",
|
|
88
|
-
id,
|
|
89
|
-
location,
|
|
90
|
-
key,
|
|
91
|
-
ref
|
|
92
|
-
});
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
sendMessage({
|
|
99
|
-
type: "ERROR",
|
|
100
|
-
id: message.type === "RSC_RENDER" ? message.id : "",
|
|
101
|
-
error: error instanceof Error ? error.message : String(error)
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
// Signal ready
|
|
106
|
-
parentPort.postMessage({ type: "READY" });
|
|
1
|
+
await (process.env["NODE_ENV"] === "production"
|
|
2
|
+
? import("./rsc-worker.production.js")
|
|
3
|
+
: import("./rsc-worker.development.js"));
|
|
4
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-worker.production.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/rsc-worker.production.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { parentPort } from 'node:worker_threads';
|
|
7
|
+
import { messageHandler } from './messageHandler.js';
|
|
8
|
+
|
|
9
|
+
if (!parentPort) {
|
|
10
|
+
throw new Error("This module must be run as a worker");
|
|
11
|
+
}
|
|
12
|
+
parentPort.on("message", messageHandler);
|
|
13
|
+
parentPort.postMessage({ type: "READY", env: "production" });
|
|
14
|
+
//# sourceMappingURL=rsc-worker.production.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsc-worker.production.js","sources":["../../../../plugin/worker/rsc/rsc-worker.production.ts"],"sourcesContent":["import { parentPort } from \"node:worker_threads\";\nimport { messageHandler } from \"./messageHandler.js\";\n\n\nif (!parentPort) {\n throw new Error(\"This module must be run as a worker\");\n}\n\n// Handle incoming messages\nparentPort.on(\"message\", messageHandler);\n\n// Signal ready\nparentPort.postMessage({ type: \"READY\", env: \"production\" });"],"names":[],"mappings":";;;;;;;;AAIA,IAAI,CAAC,UAAY,EAAA;AACf,EAAM,MAAA,IAAI,MAAM,qCAAqC,CAAA;AACvD;AAGA,UAAW,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAGvC,UAAA,CAAW,YAAY,EAAE,IAAA,EAAM,OAAS,EAAA,GAAA,EAAK,cAAc,CAAA"}
|