vite-plugin-react-server 1.1.9 → 1.1.11
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 +208 -27
- package/dist/index.js.map +1 -1
- package/dist/package.json +34 -14
- package/dist/plugin/{css-collector-elements.d.ts → components/css-collector-elements.d.ts} +1 -1
- package/dist/plugin/components/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/components/css-collector-elements.js.map +1 -0
- package/dist/plugin/{css-collector.d.ts → components/css-collector.d.ts} +1 -1
- package/dist/plugin/components/css-collector.d.ts.map +1 -0
- package/dist/plugin/components/css-collector.js.map +1 -0
- package/dist/plugin/components/html.d.ts +4 -0
- package/dist/plugin/components/html.d.ts.map +1 -0
- package/dist/plugin/components/html.js +17 -0
- package/dist/plugin/components/html.js.map +1 -0
- package/dist/plugin/components/index.d.ts +5 -0
- package/dist/plugin/components/index.d.ts.map +1 -0
- package/dist/plugin/components.js +9 -3
- package/dist/plugin/components.js.map +1 -0
- package/dist/plugin/config/autoDiscover/index.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/index.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/index.js +8 -0
- package/dist/plugin/config/{resolveAutoDiscover.d.ts → autoDiscover/resolveAutoDiscover.d.ts} +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/{resolveAutoDiscover.js → autoDiscover/resolveAutoDiscover.js} +10 -9
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +10 -10
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +6 -4
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +8 -4
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/index.d.ts +1 -0
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +1 -0
- package/dist/plugin/config/resolveDevServerConfig.d.ts +2 -0
- package/dist/plugin/config/resolveDevServerConfig.d.ts.map +1 -0
- package/dist/plugin/config/resolveEnv.d.ts +13 -0
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -0
- package/dist/plugin/config/resolveEnv.js +120 -0
- package/dist/plugin/config/resolveEnv.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +34 -11
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
- package/dist/plugin/config/resolveUrlOption.js +1 -2
- package/dist/plugin/config/resolveUrlOption.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -69
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/config.js +17 -0
- package/dist/plugin/config.js.map +1 -0
- package/dist/plugin/env/index.d.ts +2 -0
- package/dist/plugin/env/index.d.ts.map +1 -0
- package/dist/plugin/env/index.js +1 -0
- package/dist/plugin/env/plugin.d.ts +30 -0
- package/dist/plugin/env/plugin.d.ts.map +1 -0
- package/dist/plugin/env/plugin.js +64 -0
- package/dist/plugin/env.js +45 -0
- package/dist/plugin/env.js.map +1 -0
- package/dist/plugin/error/toError.d.ts +6 -0
- package/dist/plugin/error/toError.d.ts.map +1 -0
- package/dist/plugin/error/toError.js +19 -0
- package/dist/plugin/error/toError.js.map +1 -0
- package/dist/plugin/file-preserver/plugin.d.ts +19 -0
- package/dist/plugin/file-preserver/plugin.d.ts.map +1 -0
- package/dist/plugin/file-preserver/plugin.js +108 -0
- package/dist/plugin/file-preserver.js +96 -0
- package/dist/plugin/file-preserver.js.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +10 -2
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createEventHandler.d.ts +1 -1
- package/dist/plugin/helpers/createRscStream.js +1 -1
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/formatMetrics.d.ts +3 -1
- package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/helpers/formatMetrics.js +22 -7
- package/dist/plugin/helpers/formatMetrics.js.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.js +2 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -1
- package/dist/plugin/helpers/index.d.ts +24 -0
- package/dist/plugin/helpers/index.d.ts.map +1 -0
- package/dist/plugin/helpers/index.js +31 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts +2 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +34 -9
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.js +26 -2
- package/dist/plugin/helpers/metrics.js.map +1 -1
- package/dist/plugin/helpers/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/helpers/moduleRefs.js.map +1 -0
- package/dist/plugin/helpers/requestInfo.d.ts +26 -0
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -0
- package/dist/plugin/helpers/requestInfo.js +66 -0
- package/dist/plugin/helpers/requestInfo.js.map +1 -0
- package/dist/plugin/helpers/requestToRoute.js.map +1 -1
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -0
- package/dist/plugin/{resolvePage.js → helpers/resolvePage.js} +19 -3
- package/dist/plugin/helpers/resolvePage.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js +7 -4
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
- package/dist/plugin/helpers/resolveProps.d.ts.map +1 -0
- package/dist/plugin/{resolveProps.js → helpers/resolveProps.js} +9 -6
- package/dist/plugin/helpers/resolveProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
- package/dist/plugin/helpers/stashReturnValue.js +19 -13
- package/dist/plugin/helpers/stashReturnValue.js.map +1 -0
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +0 -1
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/helpers.js +27 -0
- package/dist/plugin/helpers.js.map +1 -0
- package/dist/plugin/loader/createBuildLoader.js +1 -1
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +1 -7
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/css-loader.production.js.map +1 -1
- package/dist/plugin/loader/env-loader.development.d.ts +12 -0
- package/dist/plugin/loader/env-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/env-loader.development.js +60 -0
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +1 -8
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/metrics/formatMetrics.d.ts +6 -1
- package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/formatMetrics.js +21 -3
- package/dist/plugin/metrics/formatMetrics.js.map +1 -1
- package/dist/plugin/metrics.js +1 -1
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +2 -0
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +1 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +3 -0
- package/dist/plugin/plugin.server.js.map +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/process-env.d.ts +14 -0
- package/dist/plugin/process-env.d.ts.map +1 -0
- package/dist/plugin/process-env.js +1 -0
- package/dist/plugin/react-client/createMessageHandlers.d.ts +11 -0
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -0
- package/dist/plugin/react-client/createMessageHandlers.js +47 -0
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -0
- package/dist/plugin/react-client/createWorkerStream.d.ts +9 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +102 -70
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +19 -0
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -0
- package/dist/plugin/react-client/handleWorkerRscStream.js +47 -0
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -0
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +19 -5
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts +6 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +13 -5
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +2 -13
- package/dist/plugin/react-client/server.d.ts.map +1 -1
- package/dist/plugin/react-client/server.js +123 -121
- package/dist/plugin/react-client/server.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +18 -8
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts.map +1 -1
- package/dist/plugin/react-server/server.js +37 -23
- package/dist/plugin/react-server/server.js.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +9 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +58 -54
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
- package/dist/plugin/react-static/fileWriter.d.ts +1 -1
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -1
- package/dist/plugin/react-static/fileWriter.js.map +1 -1
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +21 -23
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPages.js.map +1 -1
- package/dist/plugin/root.d.ts +1 -0
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +3 -2
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +3 -12
- package/dist/plugin/transformer/plugin.client.js.map +1 -1
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +17 -24
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +1 -10
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.js +40 -38
- package/dist/plugin/types.d.ts +60 -15
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/utils/callServer.d.ts +1 -1
- package/dist/plugin/utils/callServer.d.ts.map +1 -1
- package/dist/plugin/utils/callServer.js +3 -17
- package/dist/plugin/utils/callServer.js.map +1 -1
- package/dist/plugin/utils/createCallServer.d.ts +2 -0
- package/dist/plugin/utils/createCallServer.d.ts.map +1 -0
- package/dist/plugin/utils/createCallServer.js +28 -0
- package/dist/plugin/utils/createCallServer.js.map +1 -0
- package/dist/plugin/utils/createReactFetcher.d.ts +3 -1
- package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
- package/dist/plugin/utils/createReactFetcher.js +11 -11
- package/dist/plugin/utils/createReactFetcher.js.map +1 -1
- package/dist/plugin/utils/env.d.ts +2 -0
- package/dist/plugin/utils/env.d.ts.map +1 -0
- package/dist/plugin/utils/env.js +9 -0
- package/dist/plugin/utils/env.js.map +1 -0
- package/dist/plugin/utils/envUrls.d.ts +9 -0
- package/dist/plugin/utils/envUrls.d.ts.map +1 -0
- package/dist/plugin/utils/envUrls.js +7 -0
- package/dist/plugin/utils/envUrls.node.d.ts +7 -0
- package/dist/plugin/utils/envUrls.node.d.ts.map +1 -0
- package/dist/plugin/utils/envUrls.node.js +11 -0
- package/dist/plugin/utils/envUrls.node.js.map +1 -0
- package/dist/plugin/utils/index.d.ts +2 -1
- package/dist/plugin/utils/index.d.ts.map +1 -1
- package/dist/plugin/utils/index.js +2 -1
- package/dist/plugin/utils/moduleBaseURL.d.ts +3 -0
- package/dist/plugin/utils/moduleBaseURL.d.ts.map +1 -0
- package/dist/plugin/utils/moduleBaseURL.js +4 -0
- package/dist/plugin/utils/urls.d.ts +130 -0
- package/dist/plugin/utils/urls.d.ts.map +1 -0
- package/dist/plugin/utils/urls.js +87 -0
- package/dist/plugin/utils/urls.js.map +1 -0
- package/dist/plugin/utils.js +2 -1
- package/dist/plugin/utils.js.map +1 -1
- package/dist/plugin/vendor/index.d.ts +2 -0
- package/dist/plugin/vendor/index.d.ts.map +1 -0
- package/dist/plugin/vendor/index.js +1 -0
- package/dist/plugin/vendor/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor/vendor.client.js.map +1 -0
- package/dist/plugin/vendor/vendor.d.ts +2 -0
- package/dist/plugin/vendor/vendor.d.ts.map +1 -0
- package/dist/plugin/vendor/vendor.js +15 -0
- package/dist/plugin/vendor/vendor.js.map +1 -0
- package/dist/plugin/vendor/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor/vendor.server.js.map +1 -0
- package/dist/plugin/vendor.js +7 -0
- package/dist/plugin/vendor.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +3 -0
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +37 -23
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +4 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts +2 -7
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +4 -4
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +42 -16
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +16 -5
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +16 -5
- 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/sendMessage.js +45 -43
- package/dist/plugin/worker/sendMessage.js.map +1 -0
- package/dist/plugin/worker/types.d.ts +32 -4
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -14
- package/plugin/{css-collector-elements.tsx → components/css-collector-elements.tsx} +1 -1
- package/plugin/{css-collector.tsx → components/css-collector.tsx} +1 -1
- package/plugin/{html.tsx → components/html.tsx} +1 -3
- package/{dist/plugin/components.d.ts → plugin/components/index.ts} +1 -1
- package/plugin/config/autoDiscover/index.ts +10 -0
- package/plugin/config/{resolveAutoDiscover.ts → autoDiscover/resolveAutoDiscover.ts} +16 -12
- package/plugin/config/autoDiscover/resolveBuildPages.ts +10 -11
- package/plugin/config/defaults.tsx +6 -4
- package/plugin/config/index.ts +1 -1
- package/plugin/config/resolveEnv.ts +187 -0
- package/plugin/config/resolveOptions.ts +60 -27
- package/plugin/config/resolveUrlOption.ts +2 -7
- package/plugin/config/resolveUserConfig.ts +145 -98
- package/plugin/env/index.ts +1 -0
- package/plugin/env/plugin.ts +78 -0
- package/plugin/error/toError.ts +19 -0
- package/plugin/file-preserver/plugin.ts +117 -0
- package/plugin/helpers/createCssProps.tsx +14 -6
- package/plugin/helpers/createRscStream.tsx +1 -1
- package/plugin/helpers/formatMetrics.ts +2 -2
- package/plugin/helpers/getRouteFiles.ts +3 -1
- package/plugin/helpers/index.ts +38 -0
- package/plugin/helpers/inputNormalizer.ts +66 -17
- package/plugin/helpers/requestInfo.ts +91 -0
- package/plugin/{resolvePage.ts → helpers/resolvePage.ts} +19 -4
- package/plugin/helpers/resolvePageAndProps.ts +7 -4
- package/plugin/{resolveProps.ts → helpers/resolveProps.ts} +8 -6
- package/plugin/helpers/serializeUserOptions.ts +1 -1
- package/plugin/helpers/tryManifest.ts +0 -1
- package/plugin/loader/createBuildLoader.ts +1 -1
- package/plugin/loader/css-loader.development.ts +2 -8
- package/plugin/loader/env-loader.development.ts +84 -0
- package/plugin/loader/react-loader.ts +1 -10
- package/plugin/metrics/formatMetrics.ts +29 -4
- package/plugin/plugin.client.ts +2 -0
- package/plugin/plugin.server.ts +3 -0
- package/plugin/plugin.ts +1 -3
- package/plugin/preserver/plugin.ts +1 -0
- package/plugin/process-env.ts +13 -0
- package/plugin/react-client/createMessageHandlers.ts +49 -0
- package/plugin/react-client/createWorkerStream.ts +130 -83
- package/plugin/react-client/handleWorkerRscStream.ts +57 -0
- package/plugin/react-client/plugin.ts +30 -17
- package/plugin/react-client/restartWorker.ts +15 -7
- package/plugin/react-client/server.ts +129 -164
- package/plugin/react-server/plugin.ts +26 -13
- package/plugin/react-server/server.ts +40 -35
- package/plugin/react-static/collectHtmlWorkerContent.ts +13 -1
- package/plugin/react-static/configurePreviewServer.ts +75 -62
- package/plugin/react-static/fileWriter.ts +1 -1
- package/plugin/react-static/plugin.ts +23 -30
- package/plugin/root.ts +7 -1
- package/plugin/transformer/plugin.client.ts +4 -12
- package/plugin/transformer/plugin.server.ts +18 -25
- package/plugin/transformer/upgradeCssModuleCode.ts +39 -39
- package/plugin/types/env.d.ts +7 -0
- package/plugin/types.ts +80 -29
- package/plugin/utils/callServer.ts +3 -24
- package/plugin/utils/createCallServer.ts +26 -0
- package/plugin/utils/createReactFetcher.ts +14 -12
- package/plugin/utils/env.ts +1 -0
- package/plugin/utils/envUrls.node.ts +19 -0
- package/plugin/utils/envUrls.ts +8 -0
- package/plugin/utils/index.ts +2 -1
- package/plugin/utils/moduleBaseURL.ts +7 -0
- package/plugin/utils/urls.ts +217 -0
- package/plugin/vendor/index.ts +1 -0
- package/plugin/vendor/vendor.ts +6 -0
- package/plugin/worker/createWorker.ts +41 -30
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +4 -1
- package/plugin/worker/html/html-worker.development.tsx +2 -1
- package/plugin/worker/html/html-worker.production.tsx +2 -1
- package/plugin/worker/rsc/handleRender.ts +6 -12
- package/plugin/worker/rsc/messageHandler.tsx +53 -20
- package/plugin/worker/rsc/rsc-worker.development.ts +23 -9
- package/plugin/worker/rsc/rsc-worker.production.ts +23 -7
- package/plugin/worker/types.ts +35 -4
- package/dist/plugin/components.d.ts.map +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +0 -1
- package/dist/plugin/config/resolveAutoDiscover.js.map +0 -1
- package/dist/plugin/copy.d.ts +0 -7
- package/dist/plugin/copy.d.ts.map +0 -1
- package/dist/plugin/copy.js +0 -30
- package/dist/plugin/css-collector-elements.d.ts.map +0 -1
- package/dist/plugin/css-collector-elements.js.map +0 -1
- package/dist/plugin/css-collector.d.ts.map +0 -1
- package/dist/plugin/css-collector.js.map +0 -1
- package/dist/plugin/getCondition.d.ts +0 -2
- package/dist/plugin/getCondition.d.ts.map +0 -1
- package/dist/plugin/html.d.ts +0 -4
- package/dist/plugin/html.d.ts.map +0 -1
- package/dist/plugin/html.js +0 -18
- package/dist/plugin/html.js.map +0 -1
- package/dist/plugin/manifest.d.ts +0 -6
- package/dist/plugin/manifest.d.ts.map +0 -1
- package/dist/plugin/manifest.js +0 -13
- package/dist/plugin/moduleRefs.d.ts.map +0 -1
- package/dist/plugin/moduleRefs.js.map +0 -1
- package/dist/plugin/resolvePage.d.ts.map +0 -1
- package/dist/plugin/resolvePage.js.map +0 -1
- package/dist/plugin/resolveProps.d.ts.map +0 -1
- package/dist/plugin/resolveProps.js.map +0 -1
- package/dist/plugin/utils/pageURL.d.ts +0 -2
- package/dist/plugin/utils/pageURL.d.ts.map +0 -1
- package/dist/plugin/utils/pageURL.js +0 -21
- package/dist/plugin/utils/pageURL.js.map +0 -1
- package/dist/plugin/vendor.client.d.ts.map +0 -1
- package/dist/plugin/vendor.client.js.map +0 -1
- package/dist/plugin/vendor.server.d.ts.map +0 -1
- package/dist/plugin/vendor.server.js.map +0 -1
- package/plugin/copy.ts +0 -39
- package/plugin/manifest.ts +0 -24
- package/plugin/utils/pageURL.ts +0 -28
- /package/dist/plugin/{css-collector-elements.js → components/css-collector-elements.js} +0 -0
- /package/dist/plugin/{css-collector.js → components/css-collector.js} +0 -0
- /package/{plugin/components.ts → dist/plugin/components/index.js} +0 -0
- /package/dist/plugin/{getCondition.js → config/resolveDevServerConfig.js} +0 -0
- /package/dist/plugin/{moduleRefs.d.ts → helpers/moduleRefs.d.ts} +0 -0
- /package/dist/plugin/{moduleRefs.js → helpers/moduleRefs.js} +0 -0
- /package/dist/plugin/{resolvePage.d.ts → helpers/resolvePage.d.ts} +0 -0
- /package/dist/plugin/{resolveProps.d.ts → helpers/resolveProps.d.ts} +0 -0
- /package/dist/plugin/{vendor.client.d.ts → vendor/vendor.client.d.ts} +0 -0
- /package/dist/plugin/{vendor.client.js → vendor/vendor.client.js} +0 -0
- /package/dist/plugin/{vendor.server.d.ts → vendor/vendor.server.d.ts} +0 -0
- /package/dist/plugin/{vendor.server.js → vendor/vendor.server.js} +0 -0
- /package/plugin/{getCondition.ts → config/resolveDevServerConfig.tsx} +0 -0
- /package/plugin/{moduleRefs.ts → helpers/moduleRefs.ts} +0 -0
- /package/plugin/{vendor.client.ts → vendor/vendor.client.ts} +0 -0
- /package/plugin/{vendor.server.ts → vendor/vendor.server.ts} +0 -0
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@ A Vite plugin that enables React Server Components (RSC) streaming and static HT
|
|
|
5
5
|
## Example Projects
|
|
6
6
|
|
|
7
7
|
- [The official demo](https://github.com/nicobrinkkemper/vite-plugin-react-server-demo-official)
|
|
8
|
+
- [Github Pages](https://nicobrinkkemper.github.io/vite-plugin-react-server-demo-official/)
|
|
8
9
|
- [The mmcelebration.com project](https://github.com/nicobrinkkemper/mmc)
|
|
10
|
+
- [Github Pages](https://nicobrinkkemper.github.io/mmc/)
|
|
9
11
|
|
|
10
12
|
## Installation
|
|
11
13
|
|
|
@@ -15,7 +17,7 @@ npm install -D vite-plugin-react-server
|
|
|
15
17
|
|
|
16
18
|
## Open Source and Work in Progress
|
|
17
19
|
|
|
18
|
-
This project uses the latest
|
|
20
|
+
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:
|
|
19
21
|
|
|
20
22
|
```sh
|
|
21
23
|
npm install -D patch-package react@experimental react-dom@experimental react-server-dom-esm
|
|
@@ -50,29 +52,163 @@ This ensures the patch is applied after every `npm install`. If errors arise rel
|
|
|
50
52
|
This plugin uses environment detection to determine the execution context. It achieves this by checking the `NODE_OPTIONS` environment variable:
|
|
51
53
|
|
|
52
54
|
```typescript
|
|
53
|
-
import { getCondition } from "vite-plugin-react-server"
|
|
55
|
+
import { getCondition } from "vite-plugin-react-server/config";
|
|
54
56
|
|
|
55
|
-
if(getCondition() !==
|
|
56
|
-
throw new Error(
|
|
57
|
+
if (getCondition() !== "react-server") {
|
|
58
|
+
throw new Error("-10 poision damage");
|
|
57
59
|
}
|
|
58
60
|
```
|
|
61
|
+
|
|
59
62
|
Alternatively, you can pass the argument for the `react-` prefix to just get client or server back.
|
|
60
63
|
|
|
61
64
|
```typescript
|
|
62
|
-
import { getCondition } from "vite-plugin-react-server"
|
|
65
|
+
import { getCondition } from "vite-plugin-react-server/config";
|
|
63
66
|
|
|
64
|
-
import(`plugin.${getCondition(
|
|
67
|
+
import(`plugin.${getCondition("")}.js`);
|
|
65
68
|
```
|
|
66
69
|
|
|
67
70
|
The main entry point adapts based on the environment:
|
|
68
71
|
|
|
69
72
|
- **Client Mode** (default) → Does not require the react-server condition, uses a worker thread for RSC requests
|
|
73
|
+
Benefits:
|
|
74
|
+
- log errors to console
|
|
75
|
+
- onMetric event for each page
|
|
76
|
+
- worker thread
|
|
70
77
|
- **Server Mode** (`NODE_OPTIONS="--conditions react-server"`) → Does not need worker thread for RSC requests
|
|
78
|
+
- Direct pipeline from vite to react
|
|
71
79
|
|
|
72
80
|
### Custom composition
|
|
73
81
|
|
|
74
82
|
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.
|
|
75
83
|
|
|
84
|
+
### Page & prop setup
|
|
85
|
+
|
|
86
|
+
The minimal config is
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// vite.config.tsx
|
|
90
|
+
import type { StreamPluginOptions } from "vite-plugin-react-server/types";
|
|
91
|
+
import { join } from "node:path";
|
|
92
|
+
import { defineConfig } from "vite";
|
|
93
|
+
import { vitePluginReactServer } from "vite-plugin-react-server";
|
|
94
|
+
import { config } from "./vite.react.config.js";
|
|
95
|
+
|
|
96
|
+
export default defineConfig(() => {
|
|
97
|
+
return {
|
|
98
|
+
plugins: vitePluginReactServer({
|
|
99
|
+
moduleBase: "src",
|
|
100
|
+
Page: "src/page.tsx",
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
And our Page file.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
// src/page.tsx
|
|
110
|
+
import React from "react";
|
|
111
|
+
export function Page({ url }) {
|
|
112
|
+
return <div>You are on {url}</div>;
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Of course we need a client file as well, and the vite index.html pointing to it,
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import React, { use } from "react";
|
|
120
|
+
import { createRoot } from "react-dom/client";
|
|
121
|
+
import { createReactFetcher } from "vite-plugin-react-server/utils";
|
|
122
|
+
// src/client.tsx
|
|
123
|
+
const Shell: React.FC<{
|
|
124
|
+
data: React.Usable<React.ReactNode>;
|
|
125
|
+
}> = ({ data: initialServerData }) => {
|
|
126
|
+
const content = use(initialServerData);
|
|
127
|
+
return content as React.ReactNode;
|
|
128
|
+
};
|
|
129
|
+
// Initialize the app
|
|
130
|
+
const rootElement = document.getElementById("root");
|
|
131
|
+
if (!rootElement) throw new Error("Root element not found");
|
|
132
|
+
|
|
133
|
+
const intitalData = createReactFetcher();
|
|
134
|
+
|
|
135
|
+
createRoot(rootElement).render(<Shell data={intitalData} />);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
index.html for completeness sake
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<!DOCTYPE html>
|
|
142
|
+
<html lang="en">
|
|
143
|
+
<head>
|
|
144
|
+
<meta charset="utf-8" />
|
|
145
|
+
<body>
|
|
146
|
+
<div id="root"></div>
|
|
147
|
+
<script type="module" src="/src/client.tsx"></script>
|
|
148
|
+
</body>
|
|
149
|
+
</html>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
By default, without any prop configurations, the Page receives a normalized url.
|
|
153
|
+
|
|
154
|
+
With custom "get prop" function, we can enrich the props with more information.
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import React from "react";
|
|
158
|
+
|
|
159
|
+
export const props = (url) => ({ title: "Hello World", file: import.meta.url, url });
|
|
160
|
+
|
|
161
|
+
export type Props = ReturnType<typeof props>
|
|
162
|
+
|
|
163
|
+
export function Page({ file, title, url }: Props) {
|
|
164
|
+
return <>
|
|
165
|
+
<title>{title}<title>
|
|
166
|
+
<div>This file is here: {file}</div>;
|
|
167
|
+
<div>You are on: {url}</div>;
|
|
168
|
+
</>
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
You can also define a router specifically for the props file.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
{
|
|
176
|
+
moduleBase: "src",
|
|
177
|
+
Page: "src/page.tsx",
|
|
178
|
+
// define the props router
|
|
179
|
+
props: "src/props.ts",
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Move prop lines from `src/page.tsx` to `src/props.ts`
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
export const props = (url) => ({
|
|
187
|
+
title: "Hello World",
|
|
188
|
+
file: import.meta.url,
|
|
189
|
+
url,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export type Props = ReturnType<typeof props>;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
We can also make a static build for these pages, which will render them to index.html and headless index.rsc files, which can be used to make a static RSC site.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
{
|
|
199
|
+
moduleBase: "src",
|
|
200
|
+
Page: "src/page.tsx",
|
|
201
|
+
props: "src/props.ts"
|
|
202
|
+
// define the routes we want to render
|
|
203
|
+
build: [
|
|
204
|
+
pages: ['/', '/404']
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
And that's how you can work with react server components using a familiar vite workflow.
|
|
210
|
+
If your app grows and you need more control, see the [docs](./docs) - check out the source code - and have fun building.
|
|
211
|
+
|
|
76
212
|
### Worker support
|
|
77
213
|
|
|
78
214
|
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 plugin without the `react-server` condition. If you don't want to use the `html-worker` simply don't configure the `build.pages` option.
|
|
@@ -83,9 +219,6 @@ Both workers can be customized using the `htmlWorkerPath` and `rscWorkerPath` re
|
|
|
83
219
|
|
|
84
220
|
Keep in mind that, using your custom worker means interacting with the message system of this plugin during development/static generation process.
|
|
85
221
|
|
|
86
|
-
For more information on creating your custom workers, see [docs](/docs)
|
|
87
|
-
|
|
88
|
-
|
|
89
222
|
## Plugin Usage
|
|
90
223
|
|
|
91
224
|
```ts
|
|
@@ -96,17 +229,13 @@ import type { StreamPluginOptions } from "vite-plugin-react-server/server";
|
|
|
96
229
|
|
|
97
230
|
const createRouter = (file: "props.ts" | "page.tsx") => (url: string) => {
|
|
98
231
|
switch (url) {
|
|
232
|
+
case "/":
|
|
233
|
+
return `src/page/${file}`;
|
|
99
234
|
case "/bidoof":
|
|
100
|
-
case "/bidoof/index.rsc":
|
|
101
235
|
return `src/page/bidoof/${file}`;
|
|
102
236
|
case "/404":
|
|
103
|
-
case "/404/index.rsc":
|
|
104
|
-
return `src/page/404/${file}`;
|
|
105
|
-
case "/":
|
|
106
|
-
case "/index.rsc":
|
|
107
|
-
return `src/page/${file}`;
|
|
108
237
|
default:
|
|
109
|
-
|
|
238
|
+
return `src/page/404/${file}`;
|
|
110
239
|
}
|
|
111
240
|
};
|
|
112
241
|
|
|
@@ -116,7 +245,7 @@ export const config = {
|
|
|
116
245
|
props: createRouter("props.ts"),
|
|
117
246
|
Html: Html,
|
|
118
247
|
build: {
|
|
119
|
-
pages: ["/", "/bidoof", "/404"
|
|
248
|
+
pages: ["/", "/bidoof", "/404"],
|
|
120
249
|
},
|
|
121
250
|
} satisfies StreamPluginOptions;
|
|
122
251
|
|
|
@@ -125,34 +254,52 @@ export default defineConfig({
|
|
|
125
254
|
});
|
|
126
255
|
```
|
|
127
256
|
|
|
257
|
+
This will mirror your directory structure for new static routes. If you need to handle
|
|
258
|
+
dynamic requests, like pointing /:theme/ to a certain folder, you need to parse this yourself
|
|
259
|
+
using code.
|
|
260
|
+
|
|
261
|
+
### Async build pages
|
|
262
|
+
|
|
263
|
+
If you have a large amount of pages that needs async operations to fetch, you can pass a async function to build pages.
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
build:{
|
|
267
|
+
pages: async ()=>await import('my-pages')
|
|
268
|
+
}
|
|
269
|
+
```
|
|
128
270
|
### Built-in React Server Components
|
|
129
271
|
|
|
130
|
-
This plugin
|
|
131
|
-
|
|
272
|
+
This plugin built-in React Component that can be configured through the options to be your own component. Direct server component config inputs are not yet supported through worker threads.
|
|
273
|
+
|
|
274
|
+
- Html - used as the wrapper for production pages (use vite's `index.html` for the development wrapper and entry point for client files & global css)
|
|
132
275
|
- CssCollector - used to emit `<link>` and `<style>` tags based on `css` config
|
|
133
276
|
|
|
277
|
+
Defining your custom Html React server component will affect the final production output.
|
|
278
|
+
|
|
134
279
|
#### Build Steps
|
|
135
280
|
|
|
136
281
|
```sh
|
|
137
282
|
vite build
|
|
138
283
|
```
|
|
284
|
+
|
|
139
285
|
Targets browsers, outputs to `dist/static`.
|
|
140
286
|
|
|
141
287
|
```sh
|
|
142
288
|
vite build --ssr
|
|
143
289
|
```
|
|
290
|
+
|
|
144
291
|
Targets non-`react-server` node environment, used for server-side-rendering, outputs to `dist/client`.
|
|
145
292
|
|
|
146
293
|
```sh
|
|
147
294
|
NODE_OPTIONS="--conditions=react-server" vite build
|
|
148
295
|
```
|
|
296
|
+
|
|
149
297
|
Targets `react-server`-only environment, outputs to `dist/server`. In this case, `ssr` is implied and defaults to true.
|
|
150
298
|
|
|
151
299
|
---
|
|
152
300
|
|
|
153
301
|
### vite-plugin-react-server
|
|
154
302
|
|
|
155
|
-
|
|
156
303
|
```ts
|
|
157
304
|
import { defineConfig, Plugin } from "vite";
|
|
158
305
|
import { vitePluginReactServer } from "vite-plugin-react-server";
|
|
@@ -168,17 +315,21 @@ export default defineConfig({
|
|
|
168
315
|
```sh
|
|
169
316
|
NODE_OPTIONS="--conditions=react-server" vite
|
|
170
317
|
```
|
|
171
|
-
|
|
318
|
+
|
|
319
|
+
A direct server pipeline that doesn't require a `rsc-worker`.
|
|
172
320
|
|
|
173
321
|
To develop the app using the `rsc-worker`, simply run
|
|
322
|
+
|
|
174
323
|
```sh
|
|
175
324
|
vite
|
|
176
325
|
```
|
|
177
|
-
|
|
326
|
+
|
|
327
|
+
without the `react-server` condition. This will work a little bit differently under the hood, it can provide additional development support like error logging, metric events and custom rsc worker development.
|
|
178
328
|
|
|
179
329
|
## Static Site Generation
|
|
180
330
|
|
|
181
331
|
Single-out the static generation step by only inluding the static plugin. Expects client and server folders to be there.
|
|
332
|
+
|
|
182
333
|
```ts
|
|
183
334
|
import { defineConfig, Plugin } from "vite";
|
|
184
335
|
import { reactStaticPlugin } from "vite-plugin-react-server/static";
|
|
@@ -209,43 +360,57 @@ This plugin is included by default when the `react-server` condition is set.
|
|
|
209
360
|
```ts
|
|
210
361
|
const config = {
|
|
211
362
|
moduleBase: "src",
|
|
212
|
-
}
|
|
363
|
+
};
|
|
213
364
|
```
|
|
365
|
+
|
|
214
366
|
Defines the root directory for project modules. This can be customized.
|
|
215
367
|
|
|
216
368
|
### moduleBasePath
|
|
217
369
|
|
|
218
370
|
```ts
|
|
219
|
-
moduleBasePath: "",
|
|
371
|
+
moduleBasePath: "/",
|
|
220
372
|
```
|
|
373
|
+
|
|
221
374
|
Passed as the second argument to `renderToPipeableStream` for server-side rendering.
|
|
222
375
|
|
|
223
376
|
### moduleBaseURL
|
|
224
377
|
|
|
225
378
|
```ts
|
|
226
|
-
moduleBaseURL: "
|
|
379
|
+
moduleBaseURL: "/",
|
|
227
380
|
```
|
|
381
|
+
|
|
228
382
|
Defines asset URL resolution for CSS collectors and bootstrapModule.
|
|
229
383
|
|
|
384
|
+
```ts
|
|
385
|
+
publicOrigin: "https://github.com",
|
|
386
|
+
```
|
|
387
|
+
|
|
230
388
|
### Page and props Mapping
|
|
231
389
|
|
|
232
390
|
```ts
|
|
233
|
-
Page: (id) => join(id.replace(
|
|
391
|
+
Page: (id) => join(id.replace("index.rsc", ""), "page.tsx");
|
|
234
392
|
```
|
|
393
|
+
|
|
235
394
|
Defines how pages are mapped to file paths.
|
|
395
|
+
|
|
236
396
|
```ts
|
|
237
|
-
props: (id) => join(id.replace(
|
|
397
|
+
props: (id) => join(id.replace("index.rsc", ""), "props.ts");
|
|
238
398
|
```
|
|
399
|
+
|
|
239
400
|
Defines how to load the initial props of the page file.
|
|
240
401
|
|
|
241
402
|
If you do not want prop files, just don't define it.
|
|
403
|
+
|
|
242
404
|
```ts
|
|
243
405
|
pageExportName: 'Page',
|
|
244
406
|
```
|
|
407
|
+
|
|
245
408
|
Changes the default name "Page"
|
|
409
|
+
|
|
246
410
|
```ts
|
|
247
411
|
propsExportName: 'props',
|
|
248
412
|
```
|
|
413
|
+
|
|
249
414
|
Changes the default name "props"
|
|
250
415
|
|
|
251
416
|
---
|
|
@@ -272,15 +437,31 @@ Changes the default name "props"
|
|
|
272
437
|
export const Page = ({ name }) => {
|
|
273
438
|
return <div>Hello {name}</div>;
|
|
274
439
|
};
|
|
440
|
+
// src/async-page.tsx
|
|
441
|
+
export const Page = async ({ name }) => {
|
|
442
|
+
return <div>Hello {name}</div>;
|
|
443
|
+
};
|
|
275
444
|
```
|
|
276
445
|
|
|
277
446
|
### Sample Props File
|
|
278
447
|
|
|
448
|
+
All of the below are valid
|
|
449
|
+
|
|
279
450
|
```ts
|
|
280
451
|
// src/my-props.ts
|
|
281
452
|
export const props = {
|
|
282
453
|
name: "John Doe",
|
|
283
454
|
};
|
|
455
|
+
export const props = (url)=>{
|
|
456
|
+
name: "John Doe",
|
|
457
|
+
};
|
|
458
|
+
export const props = async (url)=>{
|
|
459
|
+
name: "John Doe",
|
|
460
|
+
}
|
|
461
|
+
// enum bonus
|
|
462
|
+
export const props = ['key']; // -> {key: "key"}
|
|
463
|
+
// Object.fromEntries()
|
|
464
|
+
export const props = [['key',{value: 'some value'}]]
|
|
284
465
|
```
|
|
285
466
|
|
|
286
467
|
## Contributions
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../index.ts"],"sourcesContent":["\"use strict\";\n\nconst condition = process.env['NODE_OPTIONS']?.match(/--conditions[= ]react-server/) ? 'server' : 'client'\n\nexport const vitePluginReactServer = await import(`./plugin/react-server/plugin.${condition}.js`).then(m => {\n if(!('vitePluginReactServer' in m)){\n throw new Error(`Could not find vitePluginReactServer in ./plugin/react-server/plugin.${condition}.js`);\n }\n return m['vitePluginReactServer']\n})\n\n// types\nexport type * from './plugin/types.js'"],"names":[],"mappings":";;;;;;;AAEA,MAAM,SAAA,GAAY,QAAQ,GAAI,CAAA,cAAc,GAAG,KAAM,CAAA,8BAA8B,IAAI,QAAW,GAAA,QAAA;AAE3F,MAAM,wBAAwB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../index.ts"],"sourcesContent":["\"use strict\";\n\nconst condition = process.env['NODE_OPTIONS']?.match(/--conditions[= ]react-server/) ? 'server' : 'client'\n\nexport const vitePluginReactServer = await import(`./plugin/react-server/plugin.${condition}.js`).then(m => {\n if(!('vitePluginReactServer' in m)){\n throw new Error(`Could not find vitePluginReactServer in ./plugin/react-server/plugin.${condition}.js`);\n }\n return m['vitePluginReactServer']\n})\n\n// types\nexport type * from './plugin/types.js'"],"names":[],"mappings":";;;;;;;AAEA,MAAM,SAAA,GAAY,QAAQ,GAAI,CAAA,cAAc,GAAG,KAAM,CAAA,8BAA8B,IAAI,QAAW,GAAA,QAAA;AAE3F,MAAM,wBAAwB,MAAM,oCAAA,mCAAA,GAAA,CAAA,6BAAA,EAAA,SAAA,CAAA,GAAA,CAAA,EAAA,CAAA,CAAgD,CAAO,KAAK,CAAK,CAAA,KAAA;AAC1G,EAAG,IAAA,EAAE,2BAA2B,CAAG,CAAA,EAAA;AACjC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAwE,qEAAA,EAAA,SAAS,CAAK,GAAA,CAAA,CAAA;AAAA;AAExG,EAAA,OAAO,EAAE,uBAAuB,CAAA;AAClC,CAAC;;;;"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Vite plugin for React Server Components (RSC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/plugin/index.js",
|
|
@@ -25,10 +25,14 @@
|
|
|
25
25
|
"./package.json": "./package.json",
|
|
26
26
|
"./patch": "./scripts/patch.mjs",
|
|
27
27
|
"./check-react-version": "./scripts/check-react-version.mjs",
|
|
28
|
-
"./components": "./dist/plugin/components.js",
|
|
28
|
+
"./components": "./dist/plugin/components/index.js",
|
|
29
29
|
"./types": "./dist/plugin/types.js",
|
|
30
30
|
"./utils": "./dist/plugin/utils/index.js",
|
|
31
|
-
"./metrics": "./dist/plugin/metrics/index.js"
|
|
31
|
+
"./metrics": "./dist/plugin/metrics/index.js",
|
|
32
|
+
"./env": "./dist/plugin/env/plugin.js",
|
|
33
|
+
"./config": "./dist/plugin/config/index.js",
|
|
34
|
+
"./vendor": "./dist/plugin/vendor/index.js",
|
|
35
|
+
"./file-preserver": "./dist/plugin/file-preserver/plugin.js"
|
|
32
36
|
},
|
|
33
37
|
"typesVersions": {
|
|
34
38
|
"*": {
|
|
@@ -48,13 +52,25 @@
|
|
|
48
52
|
"./dist/plugin/worker/worker.d.ts"
|
|
49
53
|
],
|
|
50
54
|
"components": [
|
|
51
|
-
"./dist/plugin/components.d.ts"
|
|
55
|
+
"./dist/plugin/components/index.d.ts"
|
|
52
56
|
],
|
|
53
57
|
"utils": [
|
|
54
58
|
"./dist/plugin/utils/index.d.ts"
|
|
55
59
|
],
|
|
56
60
|
"metrics": [
|
|
57
61
|
"./dist/plugin/metrics/index.d.ts"
|
|
62
|
+
],
|
|
63
|
+
"config": [
|
|
64
|
+
"./dist/plugin/config/index.d.ts"
|
|
65
|
+
],
|
|
66
|
+
"env": [
|
|
67
|
+
"./dist/plugin/env/plugin.d.ts"
|
|
68
|
+
],
|
|
69
|
+
"vendor": [
|
|
70
|
+
"./dist/plugin/vendor/index.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"file-preserver": [
|
|
73
|
+
"./dist/plugin/file-preserver/plugin.d.ts"
|
|
58
74
|
]
|
|
59
75
|
}
|
|
60
76
|
},
|
|
@@ -70,18 +86,22 @@
|
|
|
70
86
|
"prepublishOnly": "npm run build",
|
|
71
87
|
"lint": "eslint ./src --fix",
|
|
72
88
|
"setup:test-fixtures": "npx tsx test/setup.ts",
|
|
73
|
-
"test:server": "
|
|
74
|
-
"test:client": "
|
|
89
|
+
"test:server": "NODE_ENV=development NODE_OPTIONS='--conditions react-server' vitest run test/server",
|
|
90
|
+
"test:client": "NODE_ENV=development vitest run test/client",
|
|
75
91
|
"test:build": "npm run setup:test-fixtures && npm test test/server/build.test.ts",
|
|
92
|
+
"test:unit": "vitest run test/unit",
|
|
76
93
|
"test:llm": "rm -f build.log && npm run test:build 2>&1 | tee build.log",
|
|
77
|
-
"test:streams": "npm run build &&
|
|
78
|
-
"test:renders": "npm run build &&
|
|
79
|
-
"test:html-worker": "npm run build &&
|
|
80
|
-
"test:large-html": "npm run build &&
|
|
81
|
-
"test:metrics": "npm run build &&
|
|
82
|
-
"test:hooks": "npm run build &&
|
|
83
|
-
"test:inline-css": "npm run build &&
|
|
84
|
-
"test": "npm run build &&
|
|
94
|
+
"test:streams": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderStreams.test.ts",
|
|
95
|
+
"test:renders": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/renderPages.test.ts",
|
|
96
|
+
"test:html-worker": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/rscToHtmlStream.test.ts",
|
|
97
|
+
"test:large-html": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/large-html.test.ts --reporter=verbose",
|
|
98
|
+
"test:metrics": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/metrics.test.ts --reporter=verbose",
|
|
99
|
+
"test:hooks": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/hooks.test.ts --reporter=verbose",
|
|
100
|
+
"test:inline-css": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/inline-css.test.ts --reporter=verbose",
|
|
101
|
+
"test:dev-server-env": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/dev-server-env.test.ts --reporter=verbose",
|
|
102
|
+
"test:rsc-server": "npm run build && NODE_OPTIONS='--conditions react-server' vitest run test/server/rsc-server.test.ts --reporter=verbose",
|
|
103
|
+
"test:client-env": "npm run build && vitest run test/client/dev-client-server-env.test.ts --reporter=verbose",
|
|
104
|
+
"test": "npm run build && npm run test:server && npm run test:client && npm run test:unit",
|
|
85
105
|
"test:coverage": "npm run setup:test-fixtures && vitest run --coverage",
|
|
86
106
|
"test:ui": "npm run setup:test-fixtures && vitest --ui",
|
|
87
107
|
"experimental:clean-install": "npm install react-server-dom-esm react@experimental react-dom@experimental react-server-dom-esm --save-peer",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CssCollectorProps } from "
|
|
2
|
+
import type { CssCollectorProps } from "../types.js";
|
|
3
3
|
export declare const CssCollectorElements: ({ cssFiles, }: Pick<CssCollectorProps, "cssFiles">) => React.JSX.Element[];
|
|
4
4
|
//# sourceMappingURL=css-collector-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-collector-elements.d.ts","sourceRoot":"","sources":["../../../plugin/components/css-collector-elements.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,aAAa,CAAC;AAGjE,eAAO,MAAM,oBAAoB,kBAE9B,IAAI,CACL,iBAAiB,EACjB,UAAU,CACX,wBAWG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-collector-elements.js","sources":["../../../plugin/components/css-collector-elements.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CssCollectorProps, CssContent } from \"../types.js\";\n\n// Create link elements for each CSS file\nexport const CssCollectorElements = ({\n cssFiles,\n}: Pick<\n CssCollectorProps,\n \"cssFiles\"\n>) =>\n Array.from(cssFiles?.values() ?? []).map((cssFile: CssContent) => {\n // Emit style tag for inline CSS\n const { as: As, id, children, precedence, type, ...rest } = cssFile;\n if(As !== \"link\" && (typeof children === \"string\" || React.isValidElement(children))) {\n // style tag\n // since we can't bubble up the style tags, we need to be creative\n return <As {...rest} type={type ?? \"text/css\"} key={cssFile.id}>{children}</As>;\n }\n // link tag\n return <As {...rest} key={cssFile.id} precedence={precedence} />;\n });\n"],"names":["React"],"mappings":";;;;;;;AAIO,MAAM,uBAAuB,CAAC;AAAA,EACnC;AACF,CAIE,KAAA,KAAA,CAAM,IAAK,CAAA,QAAA,EAAU,MAAO,EAAA,IAAK,EAAE,CAAA,CAAE,GAAI,CAAA,CAAC,OAAwB,KAAA;AAEhE,EAAM,MAAA,EAAE,IAAI,EAAI,EAAA,EAAA,EAAI,UAAU,UAAY,EAAA,IAAA,EAAM,GAAG,IAAA,EAAS,GAAA,OAAA;AAC5D,EAAG,IAAA,EAAA,KAAO,WAAW,OAAO,QAAA,KAAa,YAAYA,cAAM,CAAA,cAAA,CAAe,QAAQ,CAAI,CAAA,EAAA;AAGpF,IAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,EAAI,EAAA,EAAA,GAAG,IAAM,EAAA,IAAA,EAAM,QAAQ,UAAY,EAAA,GAAA,EAAK,OAAQ,CAAA,EAAA,EAAA,EAAK,QAAS,CAAA;AAAA;AAG5E,EAAA,oDAAQ,EAAI,EAAA,EAAA,GAAG,MAAM,GAAK,EAAA,OAAA,CAAQ,IAAI,UAAwB,EAAA,CAAA;AAChE,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CssCollectorProps } from "
|
|
2
|
+
import type { CssCollectorProps } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* A component that emits <link> tags for CSS files during streaming.
|
|
5
5
|
* The high precedence ensures they bubble up to the document head.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-collector.d.ts","sourceRoot":"","sources":["../../../plugin/components/css-collector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAe,EACf,QAAoB,EACpB,EAAE,EAAE,EAAmB,EACvB,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC,qBAezD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-collector.js","sources":["../../../plugin/components/css-collector.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CssCollectorProps } from \"../types.js\";\nimport { CssCollectorElements } from \"./css-collector-elements.js\";\n\n/**\n * A component that emits <link> tags for CSS files during streaming.\n * The high precedence ensures they bubble up to the document head.\n */\nexport function CssCollector({\n children = null,\n cssFiles = new Map(),\n as: As = React.Fragment,\n ...props\n}: Pick<CssCollectorProps, \"children\" | \"cssFiles\" | \"as\">) {\n if (As === React.Fragment) {\n return (\n <>\n {children}\n <CssCollectorElements cssFiles={cssFiles} />\n </>\n );\n }\n return (\n <As {...props}>\n {children}\n <CssCollectorElements cssFiles={cssFiles} />\n </As>\n );\n}\n"],"names":["React"],"mappings":";;;;;;;;AAQO,SAAS,YAAa,CAAA;AAAA,EAC3B,QAAW,GAAA,IAAA;AAAA,EACX,QAAA,uBAAe,GAAI,EAAA;AAAA,EACnB,EAAA,EAAI,KAAKA,cAAM,CAAA,QAAA;AAAA,EACf,GAAG;AACL,CAA4D,EAAA;AAC1D,EAAI,IAAA,EAAA,KAAOA,eAAM,QAAU,EAAA;AACzB,IAAA,uBAEKA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAA,QAAA,kBACAA,cAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,UAAoB,CAC5C,CAAA;AAAA;AAGJ,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAC,MAAI,GAAG,KAAA,EAAA,EACL,0BACAA,cAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,UAAoB,CAC5C,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../plugin/components/html.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,IAAI,qDAKd,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,sBAWpC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import React__default from 'react';
|
|
7
|
+
import { CssCollectorElements } from './css-collector-elements.js';
|
|
8
|
+
|
|
9
|
+
const Html = ({
|
|
10
|
+
children,
|
|
11
|
+
CssCollector,
|
|
12
|
+
cssFiles,
|
|
13
|
+
globalCss
|
|
14
|
+
}) => /* @__PURE__ */ React__default.createElement("html", null, /* @__PURE__ */ React__default.createElement("head", null, /* @__PURE__ */ React__default.createElement(CssCollectorElements, { cssFiles: globalCss })), /* @__PURE__ */ React__default.createElement("body", null, /* @__PURE__ */ React__default.createElement(CssCollector, { as: "div", id: "root", cssFiles }, children)));
|
|
15
|
+
|
|
16
|
+
export { Html };
|
|
17
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sources":["../../../plugin/components/html.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HtmlProps } from \"../types.js\";\nimport { CssCollectorElements } from \"./css-collector-elements.js\";\nexport const Html = ({\n children,\n CssCollector,\n cssFiles,\n globalCss,\n}: React.PropsWithChildren<HtmlProps>) => (\n <html>\n <head>\n <CssCollectorElements cssFiles={globalCss} />\n </head>\n <body>\n <CssCollector as={\"div\"} id=\"root\" cssFiles={cssFiles}>\n {children}\n </CssCollector>\n </body>\n </html>\n);\n"],"names":["React"],"mappings":";;;;;;;;AAGO,MAAM,OAAO,CAAC;AAAA,EACnB,QAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CACE,qBAAAA,cAAA,CAAA,aAAA,CAAC,8BACEA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,+CACE,oBAAqB,EAAA,EAAA,QAAA,EAAU,WAAW,CAC7C,CAAA,+CACC,MACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,gBAAa,EAAI,EAAA,KAAA,EAAO,IAAG,MAAO,EAAA,QAAA,EAAA,EAChC,QACH,CACF,CACF;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Html } from "./html.js";
|
|
2
|
+
export { CssCollector } from "./css-collector.js";
|
|
3
|
+
export { CssCollectorElements } from "./css-collector-elements.js";
|
|
4
|
+
export type { HtmlProps, CssCollectorProps, CssCollectorElementsProps } from "../types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
export { Html } from './components/html.js';
|
|
7
|
+
export { CssCollector } from './components/css-collector.js';
|
|
8
|
+
export { CssCollectorElements } from './components/css-collector-elements.js';
|
|
9
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../plugin/config/autoDiscover/index.ts"],"names":[],"mappings":"AACA,cAAc,0BAA0B,CAAC;AAGzC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Main auto-discovery resolver
|
|
2
|
+
export * from "./resolveAutoDiscover.js";
|
|
3
|
+
// Build page resolution
|
|
4
|
+
export * from "./resolveBuildPages.js";
|
|
5
|
+
// File discovery utilities
|
|
6
|
+
export * from "./customWorkerFiles.js";
|
|
7
|
+
export * from "./pageAndPropFiles.js";
|
|
8
|
+
export * from "./createGlobAutoDiscover.js";
|
package/dist/plugin/config/{resolveAutoDiscover.d.ts → autoDiscover/resolveAutoDiscover.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigEnv, UserConfig } from "vite";
|
|
2
|
-
import type { ResolvedUserOptions, AutoDiscoveredFiles } from "
|
|
2
|
+
import type { ResolvedUserOptions, AutoDiscoveredFiles } from "../../types.js";
|
|
3
3
|
type ResolveAutoDiscoverProps = {
|
|
4
4
|
config: UserConfig;
|
|
5
5
|
configEnv: ConfigEnv;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveAutoDiscover.d.ts","sourceRoot":"","sources":["../../../../plugin/config/autoDiscover/resolveAutoDiscover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAe/E,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,mBAAmB,CAAC;IACjC,SAAS,EAAE,cAAc,GAAG,cAAc,CAAC;CAC5C,CAAC;AAEF,KAAK,yBAAyB,GAC1B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,CAAC,EAAE,KAAK,CAAC;CAC7B,CAAC;AAEN,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAqI/D"}
|