vite-plugin-react-server 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -76
- package/bin/patch.mjs +27 -20
- package/dist/_virtual/dynamic-import-helper.js +24 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- 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 +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -14
- package/dist/plugin/components.d.ts +1 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +18 -14
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +42 -21
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getCondition.d.ts +1 -1
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +2 -2
- package/dist/plugin/config/getCondition.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/index.d.ts +0 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscover.js +128 -0
- package/dist/plugin/config/resolveAutoDiscover.js.map +1 -0
- 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 +109 -77
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +0 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +6 -8
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
- package/dist/plugin/config/resolveUrlOption.js +37 -0
- package/dist/plugin/config/resolveUrlOption.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -132
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy.d.ts +7 -0
- package/dist/plugin/copy.d.ts.map +1 -0
- package/dist/plugin/copy.js +30 -0
- package/dist/plugin/css-collector-elements.d.ts +4 -0
- package/dist/plugin/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/css-collector-elements.js +19 -0
- package/dist/plugin/css-collector-elements.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +2 -8
- package/dist/plugin/css-collector.d.ts.map +1 -1
- package/dist/plugin/css-collector.js +9 -36
- package/dist/plugin/css-collector.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts +3 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
- package/dist/plugin/helpers/cleanObject.js +47 -0
- package/dist/plugin/helpers/cleanObject.js.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js +44 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
- package/dist/plugin/helpers/createCssProps.d.ts +25 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
- package/dist/plugin/helpers/createCssProps.js +57 -0
- package/dist/plugin/helpers/createCssProps.js.map +1 -0
- package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createEventHandler.js +36 -0
- package/dist/plugin/helpers/createEventHandler.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +7 -13
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +54 -96
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +12 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +105 -51
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
- package/dist/plugin/helpers/defaultFileWriter.js +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +30 -22
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.js +36 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +38 -32
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.d.ts +11 -0
- package/dist/plugin/helpers/metrics.d.ts.map +1 -0
- package/dist/plugin/helpers/metrics.js +35 -0
- package/dist/plugin/helpers/metrics.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +182 -0
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.js +14 -0
- package/dist/plugin/helpers/tryManifest.d.ts +5 -3
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +16 -7
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +2 -3
- package/dist/plugin/html.d.ts.map +1 -1
- package/dist/plugin/html.js +7 -1
- package/dist/plugin/html.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +98 -33
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts +57 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.development.js +81 -0
- package/dist/plugin/loader/css-loader.development.js.map +1 -0
- package/dist/plugin/loader/css-loader.production.d.ts +31 -0
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.production.js +45 -0
- package/dist/plugin/loader/css-loader.production.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +2 -0
- package/dist/plugin/loader/index.d.ts.map +1 -0
- package/dist/plugin/loader/index.js +1 -0
- package/dist/plugin/loader/plugin.d.ts +22 -0
- package/dist/plugin/loader/plugin.d.ts.map +1 -0
- package/dist/plugin/loader/plugin.js +27 -0
- package/dist/plugin/loader/react-loader.d.ts +3 -7
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +85 -30
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/loader/temporaryReferences.js +11 -0
- package/dist/plugin/loader/temporaryReferences.js.map +1 -0
- package/dist/plugin/moduleRefs.d.ts +7 -0
- package/dist/plugin/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/moduleRefs.js +17 -0
- package/dist/plugin/moduleRefs.js.map +1 -0
- package/dist/plugin/plugin.client.d.ts +3 -0
- package/dist/plugin/plugin.client.d.ts.map +1 -0
- package/dist/plugin/plugin.client.js +19 -0
- package/dist/plugin/plugin.client.js.map +1 -0
- package/dist/plugin/plugin.d.ts +1 -5
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +3 -9
- package/dist/plugin/plugin.server.d.ts +3 -0
- package/dist/plugin/plugin.server.d.ts.map +1 -0
- package/dist/plugin/plugin.server.js +28 -0
- package/dist/plugin/plugin.server.js.map +1 -0
- package/dist/plugin/preserver/plugin.js +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +1 -2
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +1 -19
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +60 -219
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +27 -0
- package/dist/plugin/react-client/server.d.ts.map +1 -0
- package/dist/plugin/react-client/server.js +197 -0
- package/dist/plugin/react-client/server.js.map +1 -0
- package/dist/plugin/react-server/index.d.ts +1 -2
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +1 -21
- package/dist/plugin/react-server/plugin.d.ts +0 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +60 -186
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts +9 -0
- package/dist/plugin/react-server/server.d.ts.map +1 -0
- package/dist/plugin/react-server/server.js +120 -0
- package/dist/plugin/react-server/server.js.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectRscContent.js +49 -0
- package/dist/plugin/react-static/collectRscContent.js.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.js +67 -0
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
- package/dist/plugin/react-static/fileWriter.d.ts +23 -0
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
- package/dist/plugin/react-static/fileWriter.js +65 -0
- package/dist/plugin/react-static/fileWriter.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +15 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +248 -149
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +3 -0
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.js +116 -0
- package/dist/plugin/react-static/renderPage.js.map +1 -0
- package/dist/plugin/react-static/renderPages.d.ts +3 -0
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPages.js +125 -0
- package/dist/plugin/react-static/renderPages.js.map +1 -0
- package/dist/plugin/react-static/renderStreams.d.ts +26 -0
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
- package/dist/plugin/react-static/renderStreams.js +27 -0
- package/dist/plugin/react-static/renderStreams.js.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
- package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
- package/dist/plugin/react-static/streamHandler.d.ts +2 -0
- package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
- package/dist/plugin/react-static/streamHandler.js +1 -0
- package/dist/plugin/react-static/types.d.ts +11 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/resolvePage.d.ts +26 -9
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +41 -39
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts +40 -7
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +100 -75
- package/dist/plugin/resolveProps.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 +1 -0
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/index.d.ts +2 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +2 -1
- package/dist/plugin/transformer/plugin.client.d.ts +4 -0
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.client.js +83 -0
- package/dist/plugin/transformer/plugin.client.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts +1 -27
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +3 -87
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +4 -0
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +76 -0
- package/dist/plugin/transformer/plugin.server.js.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
- package/dist/plugin/types/css-tracking.d.ts +6 -0
- package/dist/plugin/types/css-tracking.d.ts.map +1 -0
- package/dist/plugin/types/css-tracking.js +1 -0
- package/dist/plugin/types.d.ts +372 -86
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/vendor.client.d.ts +4 -0
- package/dist/plugin/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor.client.js +16 -0
- package/dist/plugin/vendor.client.js.map +1 -0
- package/dist/plugin/vendor.server.d.ts +4 -0
- package/dist/plugin/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor.server.js +16 -0
- package/dist/plugin/vendor.server.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +25 -7
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +108 -33
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +3 -17
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +12 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +87 -84
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/types.d.ts +18 -0
- package/dist/plugin/worker/html/types.d.ts.map +1 -0
- package/dist/plugin/worker/html/types.js +1 -0
- package/dist/plugin/worker/registerLoaders.d.ts +9 -0
- package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
- package/dist/plugin/worker/registerLoaders.js +45 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRender.js +147 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +47 -112
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +73 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +40 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +3 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
- package/dist/plugin/worker/sendMessage.js +48 -0
- package/dist/plugin/worker/types.d.ts +218 -76
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/plugin/components.ts +1 -1
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
- package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
- package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
- package/plugin/config/defaults.tsx +38 -29
- package/plugin/config/getCondition.ts +7 -3
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/index.ts +0 -1
- package/plugin/config/resolveAutoDiscover.ts +177 -0
- package/plugin/config/resolveOptions.ts +220 -118
- package/plugin/config/resolvePages.ts +5 -7
- package/plugin/config/resolveUrlOption.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +116 -166
- package/plugin/copy.ts +39 -0
- package/plugin/css-collector-elements.tsx +21 -0
- package/plugin/css-collector.tsx +20 -53
- package/plugin/helpers/cleanObject.ts +50 -0
- package/plugin/helpers/collectBundleManifestCss.ts +160 -0
- package/plugin/helpers/collectManifestCss.ts +61 -0
- package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
- package/plugin/helpers/createCssProps.tsx +85 -0
- package/plugin/helpers/createEventHandler.ts +44 -0
- package/plugin/helpers/createHandler.ts +57 -126
- package/plugin/helpers/createRscStream.tsx +156 -0
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/getBundleManifest.ts +42 -37
- package/plugin/helpers/getRouteFiles.ts +47 -0
- package/plugin/helpers/inputNormalizer.ts +16 -10
- package/plugin/helpers/metrics.ts +64 -0
- package/plugin/helpers/resolvePageAndProps.ts +81 -0
- package/plugin/helpers/serializeUserOptions.ts +209 -0
- package/plugin/helpers/stashReturnValue.ts +16 -0
- package/plugin/helpers/tryManifest.ts +35 -18
- package/plugin/html.tsx +14 -3
- package/plugin/index.ts +5 -2
- package/plugin/loader/createBuildLoader.ts +152 -47
- package/plugin/loader/css-loader.development.ts +157 -0
- package/plugin/loader/css-loader.production.ts +86 -0
- package/plugin/loader/index.ts +1 -0
- package/plugin/loader/plugin.ts +33 -0
- package/plugin/loader/react-loader.ts +109 -41
- package/plugin/loader/temporaryReferences.ts +3 -0
- package/plugin/moduleRefs.ts +11 -0
- package/plugin/plugin.client.ts +12 -0
- package/plugin/plugin.server.ts +25 -0
- package/plugin/plugin.ts +5 -9
- package/plugin/preserver/plugin.ts +1 -1
- package/plugin/react-client/index.ts +1 -12
- package/plugin/react-client/plugin.ts +70 -259
- package/plugin/react-client/server.ts +276 -0
- package/plugin/react-server/index.ts +1 -14
- package/plugin/react-server/plugin.ts +69 -220
- package/plugin/react-server/server.ts +128 -0
- package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
- package/plugin/react-static/collectRscContent.ts +77 -0
- package/plugin/react-static/configurePreviewServer.ts +68 -0
- package/plugin/react-static/fileWriter.ts +103 -0
- package/plugin/react-static/plugin.ts +308 -181
- package/plugin/react-static/renderPage.ts +151 -0
- package/plugin/react-static/renderPages.ts +154 -0
- package/plugin/react-static/renderStreams.ts +48 -0
- package/plugin/react-static/rscToHtmlStream.ts +85 -0
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/react-static/types.ts +10 -0
- package/plugin/resolvePage.ts +67 -57
- package/plugin/resolveProps.ts +148 -104
- package/plugin/root.ts +1 -1
- package/plugin/transformer/index.ts +2 -1
- package/plugin/transformer/plugin.client.ts +109 -0
- package/plugin/transformer/plugin.server.ts +98 -0
- package/plugin/transformer/plugin.ts +2 -115
- package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
- package/plugin/types/css-tracking.ts +5 -0
- package/plugin/types/react-server-dom-esm.d.ts +54 -0
- package/plugin/types.ts +508 -97
- package/plugin/vendor.client.ts +12 -0
- package/plugin/vendor.server.ts +12 -0
- package/plugin/worker/createWorker.ts +158 -53
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -75
- package/plugin/worker/html/html-worker.production.tsx +18 -7
- package/plugin/worker/html/messageHandler.tsx +126 -0
- package/plugin/worker/html/types.ts +19 -0
- package/plugin/worker/registerLoaders.ts +54 -0
- package/plugin/worker/rsc/handleRender.ts +180 -0
- package/plugin/worker/rsc/messageHandler.tsx +58 -132
- package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
- package/plugin/worker/rsc/state.ts +79 -2
- package/plugin/worker/sendMessage.ts +49 -0
- package/plugin/worker/types.ts +299 -100
- package/scripts/check-react-version.mjs +60 -48
- package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
- package/tsconfig.json +7 -2
- package/dist/plugin/assertServerCondition.d.ts +0 -6
- package/dist/plugin/assertServerCondition.d.ts.map +0 -1
- package/dist/plugin/assertServerCondition.js +0 -13
- package/dist/plugin/checkFilesExist.d.ts +0 -3
- package/dist/plugin/checkFilesExist.d.ts.map +0 -1
- package/dist/plugin/checkFilesExist.js +0 -67
- package/dist/plugin/checkFilesExist.js.map +0 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
- package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
- package/dist/plugin/collect-manifest-client-files.js +0 -131
- package/dist/plugin/collect-manifest-client-files.js.map +0 -1
- package/dist/plugin/config/getWorkerPath.d.ts +0 -2
- package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
- package/dist/plugin/config/getWorkerPath.js +0 -4
- package/dist/plugin/copy-dir.d.ts +0 -4
- package/dist/plugin/copy-dir.d.ts.map +0 -1
- package/dist/plugin/copy-dir.js +0 -25
- package/dist/plugin/copy-dir.js.map +0 -1
- package/dist/plugin/css-collector-inline.d.ts +0 -10
- package/dist/plugin/css-collector-inline.d.ts.map +0 -1
- package/dist/plugin/css-collector-inline.js +0 -55
- package/dist/plugin/css-collector-inline.js.map +0 -1
- package/dist/plugin/loader/css-loader.d.ts +0 -16
- package/dist/plugin/loader/css-loader.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.js +0 -70
- package/dist/plugin/loader/css-loader.js.map +0 -1
- package/dist/plugin/react-client/index.js.map +0 -1
- package/dist/plugin/react-server/index.js.map +0 -1
- package/dist/plugin/worker/html/renderPages.d.ts +0 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
- package/dist/plugin/worker/html/renderPages.js +0 -241
- package/dist/plugin/worker/html/renderPages.js.map +0 -1
- package/plugin/assertServerCondition.ts +0 -12
- package/plugin/checkFilesExist.ts +0 -66
- package/plugin/collect-manifest-client-files.ts +0 -167
- package/plugin/config/getWorkerPath.ts +0 -5
- package/plugin/copy-dir.ts +0 -27
- package/plugin/css-collector-inline.tsx +0 -60
- package/plugin/helpers/createRscStream.ts +0 -109
- package/plugin/loader/css-loader.ts +0 -94
- package/plugin/worker/html/messageHandler.ts +0 -130
- package/plugin/worker/html/renderPages.ts +0 -293
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
package/plugin/types.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
NormalizedOutputOptions,
|
|
3
|
+
OutputBundle,
|
|
4
|
+
PreRenderedChunk,
|
|
5
|
+
} from "rollup";
|
|
2
6
|
import type { PreRenderedAsset } from "rollup";
|
|
3
7
|
import type {
|
|
4
8
|
UserConfig,
|
|
@@ -7,14 +11,91 @@ import type {
|
|
|
7
11
|
AliasOptions,
|
|
8
12
|
Connect,
|
|
9
13
|
ResolveOptions,
|
|
14
|
+
Manifest,
|
|
15
|
+
Logger,
|
|
10
16
|
} from "vite";
|
|
11
|
-
import type {
|
|
17
|
+
import type { ReactServerDomEsmOptions } from "./worker/types.js";
|
|
18
|
+
import type React from "react";
|
|
19
|
+
import type { PassThrough, Transform } from "stream";
|
|
20
|
+
import type { MessagePort } from "node:worker_threads";
|
|
21
|
+
import type { PropsWithChildren } from "react";
|
|
22
|
+
import { Readable } from "node:stream";
|
|
23
|
+
|
|
24
|
+
export type OnEvent = (event: PluginEvent) => void;
|
|
25
|
+
|
|
26
|
+
export type Serializable =
|
|
27
|
+
| string
|
|
28
|
+
| number
|
|
29
|
+
| boolean
|
|
30
|
+
| null
|
|
31
|
+
| undefined
|
|
32
|
+
| Serializable[]
|
|
33
|
+
| SerializableRecord;
|
|
34
|
+
export type SerializableRecord = {
|
|
35
|
+
[key: string]: Serializable | SerializableRecord;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Track HMR state
|
|
39
|
+
export type HmrState = {
|
|
40
|
+
timestamp: number;
|
|
41
|
+
invalidated: boolean;
|
|
42
|
+
routes: string[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type RenderPageResult =
|
|
46
|
+
| {
|
|
47
|
+
type: "skip";
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
type: "error";
|
|
51
|
+
error: Error;
|
|
52
|
+
}
|
|
53
|
+
| {
|
|
54
|
+
type: "success";
|
|
55
|
+
html: PassThrough;
|
|
56
|
+
rsc: PassThrough;
|
|
57
|
+
metrics: {
|
|
58
|
+
rscFull: StreamMetrics;
|
|
59
|
+
rscHeadless: StreamMetrics;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type AutoDiscoveredFiles = ResolvedBuildPages & {
|
|
64
|
+
workerPaths: Record<string, string>;
|
|
65
|
+
serverEntry: Record<string, string> | null;
|
|
66
|
+
clientEntry: Record<string, string>;
|
|
67
|
+
inputs: Record<string, string>;
|
|
68
|
+
staticManifest: Manifest;
|
|
69
|
+
};
|
|
70
|
+
export type FileWriterOptions = Pick<
|
|
71
|
+
CreateHandlerOptions,
|
|
72
|
+
"onEvent" | "route" | "build"
|
|
73
|
+
>;
|
|
12
74
|
|
|
13
75
|
// Input can be a string path, React component, tuple, or array
|
|
14
76
|
export type NormalizerInput = unknown;
|
|
15
77
|
|
|
16
78
|
export type InputNormalizer = (input: NormalizerInput) => [string, string];
|
|
17
79
|
|
|
80
|
+
export interface HtmlContent {
|
|
81
|
+
raw: string;
|
|
82
|
+
transformed?: string;
|
|
83
|
+
assets?: string[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface PartialPageData {
|
|
87
|
+
route: string;
|
|
88
|
+
html?: {
|
|
89
|
+
raw: string;
|
|
90
|
+
transformed?: string;
|
|
91
|
+
assets?: string[];
|
|
92
|
+
};
|
|
93
|
+
rsc?: {
|
|
94
|
+
modules: any[];
|
|
95
|
+
content: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
18
99
|
export type InputNormalizerWorker = (
|
|
19
100
|
input: NormalizerInput
|
|
20
101
|
) => Promise<[string, string]>;
|
|
@@ -23,7 +104,7 @@ export type ResolvedUserConfig = Required<
|
|
|
23
104
|
Pick<UserConfig, "root" | "mode" | "build" | "resolve">
|
|
24
105
|
> &
|
|
25
106
|
Omit<UserConfig, "root" | "mode" | "build" | "resolve"> & {
|
|
26
|
-
resolve:
|
|
107
|
+
resolve: ResolveOptions;
|
|
27
108
|
} & {
|
|
28
109
|
build: NonNullable<
|
|
29
110
|
Required<
|
|
@@ -52,6 +133,10 @@ export type ResolvedUserConfig = Required<
|
|
|
52
133
|
>;
|
|
53
134
|
};
|
|
54
135
|
|
|
136
|
+
export type SerializedUserConfig = Extract<
|
|
137
|
+
ResolvedUserConfig,
|
|
138
|
+
SerializableRecord
|
|
139
|
+
>;
|
|
55
140
|
// Client plugin options
|
|
56
141
|
export interface StreamPluginOptionsClient {
|
|
57
142
|
outDir?: string;
|
|
@@ -65,33 +150,42 @@ export interface StreamPluginOptionsClient {
|
|
|
65
150
|
cssFiles?: AliasOptions;
|
|
66
151
|
}
|
|
67
152
|
|
|
68
|
-
export type ResolvedUserOptions<
|
|
153
|
+
export type ResolvedUserOptions<
|
|
154
|
+
InlineCSS extends boolean | undefined = boolean | undefined
|
|
155
|
+
> = Required<
|
|
69
156
|
Pick<
|
|
70
157
|
StreamPluginOptions,
|
|
71
158
|
| "moduleBase"
|
|
72
159
|
| "moduleBasePath"
|
|
73
160
|
| "moduleBaseURL"
|
|
161
|
+
| "moduleRootPath"
|
|
74
162
|
| "projectRoot"
|
|
75
163
|
| "build"
|
|
76
164
|
| "Page"
|
|
77
|
-
| "props"
|
|
78
165
|
| "Html"
|
|
79
166
|
| "CssCollector"
|
|
80
167
|
| "pageExportName"
|
|
81
168
|
| "propsExportName"
|
|
82
|
-
| "collectCss"
|
|
83
|
-
| "collectAssets"
|
|
84
|
-
| "inlineCss"
|
|
85
169
|
| "htmlWorkerPath"
|
|
86
170
|
| "rscWorkerPath"
|
|
87
171
|
| "loaderPath"
|
|
88
172
|
| "clientEntry"
|
|
89
173
|
| "serverEntry"
|
|
90
174
|
| "moduleBaseExceptions"
|
|
91
|
-
| "
|
|
175
|
+
| "pipeableStreamOptions"
|
|
176
|
+
| "onMetrics"
|
|
177
|
+
| "onEvent"
|
|
178
|
+
| "css"
|
|
179
|
+
| "normalizer"
|
|
92
180
|
>
|
|
93
181
|
> & {
|
|
182
|
+
props:
|
|
183
|
+
| undefined
|
|
184
|
+
| string
|
|
185
|
+
| ((url: string) => string)
|
|
186
|
+
| ((url: string) => Promise<string>);
|
|
94
187
|
build: NonNullable<Required<StreamPluginOptions<InlineCSS>["build"]>>;
|
|
188
|
+
css: NonNullable<Required<StreamPluginOptions<InlineCSS>["css"]>>;
|
|
95
189
|
autoDiscover: {
|
|
96
190
|
modulePattern: (path: string) => boolean;
|
|
97
191
|
cssPattern: (path: string) => boolean;
|
|
@@ -99,9 +193,14 @@ export type ResolvedUserOptions<InlineCSS extends boolean = boolean> = Required<
|
|
|
99
193
|
clientComponents: (path: string) => boolean;
|
|
100
194
|
propsPattern: (path: string) => boolean;
|
|
101
195
|
pagePattern: (path: string) => boolean;
|
|
196
|
+
htmlPattern: (path: string) => boolean;
|
|
197
|
+
rscPattern: (path: string) => boolean;
|
|
102
198
|
serverFunctions: (path: string) => boolean;
|
|
103
199
|
cssModulePattern: (path: string) => boolean;
|
|
104
200
|
vendorPattern: (path: string) => boolean;
|
|
201
|
+
nodeOnly: (path: string) => boolean;
|
|
202
|
+
dotFiles: (path: string) => boolean;
|
|
203
|
+
virtualPattern: (path: string) => boolean;
|
|
105
204
|
};
|
|
106
205
|
};
|
|
107
206
|
|
|
@@ -118,16 +217,141 @@ export type createBuildConfigFn<C extends "react-client" | "react-server"> =
|
|
|
118
217
|
? Promise<InlineConfig>
|
|
119
218
|
: Promise<InlineConfig>;
|
|
120
219
|
|
|
121
|
-
export interface
|
|
220
|
+
export interface StreamMetrics {
|
|
221
|
+
chunks: number;
|
|
222
|
+
bytes: number;
|
|
223
|
+
backpressureCount: number;
|
|
224
|
+
drainCount: number;
|
|
225
|
+
errorCount: number;
|
|
226
|
+
duration: number;
|
|
227
|
+
startTime: number;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface RenderMetrics {
|
|
231
|
+
route: string;
|
|
232
|
+
htmlSize: number;
|
|
233
|
+
rscSize: number;
|
|
234
|
+
processingTime: number;
|
|
235
|
+
chunks: number;
|
|
236
|
+
chunkRate: number;
|
|
237
|
+
memoryUsage: NodeJS.MemoryUsage;
|
|
238
|
+
streamMetrics: StreamMetrics;
|
|
239
|
+
htmlSizes: Map<string, number>;
|
|
240
|
+
rscSizes: Map<string, number>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface CssCollectorOptions {
|
|
244
|
+
inlineCss?: boolean;
|
|
245
|
+
purgeCss?: boolean;
|
|
246
|
+
inlineThreshold?: number;
|
|
247
|
+
inlinePatterns?: RegExp[];
|
|
248
|
+
linkPatterns?: RegExp[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type FileWriteEvent = {
|
|
252
|
+
type: "file.write";
|
|
253
|
+
data: {
|
|
254
|
+
path: string;
|
|
255
|
+
fileType: "html" | "rsc";
|
|
256
|
+
route: string;
|
|
257
|
+
stream: Readable;
|
|
258
|
+
onComplete: () => Promise<void>;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export type FileWriteDoneEvent = {
|
|
263
|
+
type: "file.write.done";
|
|
264
|
+
data: {
|
|
265
|
+
route: string;
|
|
266
|
+
fileType: "html" | "rsc";
|
|
267
|
+
content: string;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export type RouteProcessEvent = {
|
|
272
|
+
type: "route.process";
|
|
273
|
+
data: {
|
|
274
|
+
route: string;
|
|
275
|
+
pagePath: string;
|
|
276
|
+
propsPath?: string | undefined;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export type RouteErrorEvent = {
|
|
281
|
+
type: "route.error";
|
|
282
|
+
data: {
|
|
283
|
+
route: string;
|
|
284
|
+
error: any;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export type RoutePostponeEvent = {
|
|
289
|
+
type: "route.postpone";
|
|
290
|
+
data: {
|
|
291
|
+
route: string;
|
|
292
|
+
reason: string;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export type PropsLoadEvent = {
|
|
297
|
+
type: "props.load";
|
|
298
|
+
data: {
|
|
299
|
+
route: string;
|
|
300
|
+
propsPath: string;
|
|
301
|
+
props: any;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export type CssProcessEvent = {
|
|
306
|
+
type: "css.process";
|
|
307
|
+
data: CssContent;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export type BuildStartEvent = {
|
|
311
|
+
type: "build.start";
|
|
312
|
+
data: {
|
|
313
|
+
pages: string[];
|
|
314
|
+
files: AutoDiscoveredFiles;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export type BuildWriteBundleEvent = {
|
|
319
|
+
type: "build.writeBundle";
|
|
320
|
+
data: {
|
|
321
|
+
pages: string[];
|
|
322
|
+
options: NormalizedOutputOptions;
|
|
323
|
+
bundle: OutputBundle;
|
|
324
|
+
manifest: Manifest | undefined;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export type PluginEvent =
|
|
329
|
+
| FileWriteEvent
|
|
330
|
+
| FileWriteDoneEvent
|
|
331
|
+
| RouteProcessEvent
|
|
332
|
+
| RouteErrorEvent
|
|
333
|
+
| RoutePostponeEvent
|
|
334
|
+
| PropsLoadEvent
|
|
335
|
+
| CssProcessEvent
|
|
336
|
+
| BuildStartEvent
|
|
337
|
+
| BuildWriteBundleEvent;
|
|
338
|
+
|
|
339
|
+
export type PluginEventType = PluginEvent["type"];
|
|
340
|
+
|
|
341
|
+
export interface StreamPluginOptions<
|
|
342
|
+
InlineCSS extends boolean | undefined = boolean | undefined
|
|
343
|
+
> {
|
|
122
344
|
projectRoot?: string;
|
|
123
345
|
moduleBase: string;
|
|
124
346
|
moduleBasePath?: string;
|
|
125
347
|
moduleBaseURL?: string;
|
|
348
|
+
moduleRootPath?: string;
|
|
126
349
|
clientEntry?: string;
|
|
127
350
|
serverEntry?: string;
|
|
128
351
|
// Auto-discovery (zero-config)
|
|
129
352
|
autoDiscover?:
|
|
130
353
|
| {
|
|
354
|
+
moduleExtension?: RegExp;
|
|
131
355
|
// default: /\.(m|c)?(j|t)sx?$/
|
|
132
356
|
modulePattern?: string | RegExp | ((path: string) => boolean);
|
|
133
357
|
// default: [Pp]age.tsx
|
|
@@ -148,56 +372,107 @@ export interface StreamPluginOptions<InlineCSS extends boolean = boolean> {
|
|
|
148
372
|
cssModulePattern?: string | RegExp | ((path: string) => boolean);
|
|
149
373
|
// default: /node_modules|(_virtual)/
|
|
150
374
|
vendorPattern?: string | RegExp | ((path: string) => boolean);
|
|
375
|
+
// default: /\.node\.js$/
|
|
376
|
+
nodeOnly?: string | RegExp | ((path: string) => boolean);
|
|
377
|
+
// default: /\.node\.js$/
|
|
378
|
+
dotFiles?: string | RegExp | ((path: string) => boolean);
|
|
379
|
+
// default: /^\/_virtual\//
|
|
380
|
+
virtualPattern?: string | RegExp | ((path: string) => boolean);
|
|
381
|
+
// default: /\.rsc$/
|
|
382
|
+
rscPattern?: string | RegExp | ((path: string) => boolean);
|
|
151
383
|
}
|
|
152
384
|
| undefined;
|
|
153
385
|
// Manual configuration
|
|
154
|
-
Page: string | ((url: string) => string);
|
|
155
|
-
props?:
|
|
386
|
+
Page: string | ((url: string) => string) | ((url: string) => Promise<string>);
|
|
387
|
+
props?:
|
|
388
|
+
| undefined
|
|
389
|
+
| string
|
|
390
|
+
| ((url: string) => string)
|
|
391
|
+
| ((url: string) => Promise<string>);
|
|
156
392
|
// Escape hatches
|
|
157
393
|
htmlWorkerPath?: string;
|
|
158
394
|
rscWorkerPath?: string;
|
|
159
395
|
loaderPath?: string;
|
|
160
396
|
pageExportName?: string;
|
|
161
397
|
propsExportName?: string;
|
|
162
|
-
Html?: React.FC<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
url: string;
|
|
167
|
-
children: React.ReactNode;
|
|
168
|
-
}>;
|
|
169
|
-
CssCollector?: InlineCSS extends true ? React.FC<React.PropsWithChildren<InlineCssCollectorProps>> : React.FC<React.PropsWithChildren<CssCollectorProps>>;
|
|
170
|
-
collectCss?: boolean;
|
|
171
|
-
collectAssets?: boolean;
|
|
172
|
-
inlineCss?: InlineCSS;
|
|
398
|
+
Html?: React.FC<PropsWithChildren<HtmlProps>>;
|
|
399
|
+
CssCollector?: React.FC<
|
|
400
|
+
React.PropsWithChildren<CssCollectorProps<InlineCSS>>
|
|
401
|
+
>;
|
|
173
402
|
build?: BuildConfig;
|
|
403
|
+
css?: CssCollectorOptions;
|
|
174
404
|
moduleBaseExceptions?: string[];
|
|
175
|
-
|
|
405
|
+
pipeableStreamOptions?: ReactServerDomEsmOptions;
|
|
406
|
+
onMetrics?: (metrics: RenderMetrics) => void;
|
|
407
|
+
onEvent?: (event: PluginEvent) => void;
|
|
408
|
+
normalizer?: InputNormalizer;
|
|
176
409
|
}
|
|
177
410
|
|
|
178
|
-
export
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
route
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
411
|
+
export type MultiPageHandlerOptions = Omit<
|
|
412
|
+
CreateHandlerOptions,
|
|
413
|
+
| "pagePath"
|
|
414
|
+
| "route"
|
|
415
|
+
| "cssFiles"
|
|
416
|
+
| "propsPath"
|
|
417
|
+
| "pageProps"
|
|
418
|
+
| "PageComponent"
|
|
419
|
+
>;
|
|
420
|
+
|
|
421
|
+
export type CreateHandlerOptions<
|
|
422
|
+
T = unknown,
|
|
423
|
+
C extends React.ComponentType<T> = React.ComponentType<T>,
|
|
424
|
+
InlineCSS extends boolean | undefined = undefined
|
|
425
|
+
> = Pick<
|
|
426
|
+
ResolvedUserOptions<InlineCSS>,
|
|
427
|
+
| "autoDiscover"
|
|
428
|
+
| "css"
|
|
429
|
+
| "pageExportName"
|
|
430
|
+
| "propsExportName"
|
|
431
|
+
| "Html"
|
|
432
|
+
| "CssCollector"
|
|
433
|
+
| "moduleBase"
|
|
434
|
+
| "moduleRootPath"
|
|
435
|
+
| "moduleBasePath"
|
|
436
|
+
| "moduleBaseURL"
|
|
437
|
+
| "pipeableStreamOptions"
|
|
438
|
+
| "onEvent"
|
|
439
|
+
| "onMetrics"
|
|
440
|
+
| "projectRoot"
|
|
441
|
+
> & {
|
|
442
|
+
logger: Logger;
|
|
443
|
+
loader: ModuleLoader;
|
|
444
|
+
pagePath: string;
|
|
187
445
|
propsPath?: string;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
446
|
+
pageProps?: T;
|
|
447
|
+
PageComponent?: C;
|
|
448
|
+
route: string;
|
|
449
|
+
manifest: Manifest;
|
|
450
|
+
worker?: any;
|
|
451
|
+
importedCss?: Set<string>;
|
|
452
|
+
cssFiles: Map<string, CssContent>;
|
|
453
|
+
globalCss: Map<string, CssContent>;
|
|
454
|
+
build: Pick<
|
|
455
|
+
ResolvedUserOptions["build"],
|
|
456
|
+
| "outDir"
|
|
457
|
+
| "pages"
|
|
458
|
+
| "server"
|
|
459
|
+
| "static"
|
|
460
|
+
| "client"
|
|
461
|
+
| "rscOutputPath"
|
|
462
|
+
| "htmlOutputPath"
|
|
463
|
+
>;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
export interface ResolvePageOptions {
|
|
467
|
+
pagePath: string;
|
|
468
|
+
pageExportName: string;
|
|
469
|
+
url: string;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export interface ResolvePropsOptions {
|
|
473
|
+
propsPath: string;
|
|
474
|
+
propsExportName: string;
|
|
475
|
+
url: string;
|
|
201
476
|
}
|
|
202
477
|
|
|
203
478
|
export type ModuleLoader = (
|
|
@@ -225,19 +500,6 @@ export type StreamResult =
|
|
|
225
500
|
| { type: "error"; error: unknown }
|
|
226
501
|
| { type: "skip" };
|
|
227
502
|
|
|
228
|
-
export interface RscStreamOptions {
|
|
229
|
-
Page: React.ComponentType;
|
|
230
|
-
props: any;
|
|
231
|
-
Html: any;
|
|
232
|
-
logger?: Console | import("vite").Logger;
|
|
233
|
-
cssFiles?: string[];
|
|
234
|
-
htmlProps: any;
|
|
235
|
-
route: string;
|
|
236
|
-
url: string;
|
|
237
|
-
pipableStreamOptions?: PipeableStreamOptions;
|
|
238
|
-
moduleBasePath: string;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
503
|
export interface RouteConfig {
|
|
242
504
|
path: string;
|
|
243
505
|
// Define page/props paths using patterns
|
|
@@ -268,9 +530,11 @@ export interface BuildConfig {
|
|
|
268
530
|
outDir?: string;
|
|
269
531
|
hash?: string;
|
|
270
532
|
preserveModulesRoot?: boolean;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
533
|
+
rscOutputPath?: string; // defaults: `index.rsc`
|
|
534
|
+
htmlOutputPath?: string; // defaults: `index.html`
|
|
535
|
+
entryFile?: (n: PreRenderedChunk, ssr: boolean) => string;
|
|
536
|
+
chunkFile?: (n: PreRenderedChunk, ssr: boolean) => string;
|
|
537
|
+
assetFile?: (n: PreRenderedAsset, ssr: boolean) => string;
|
|
274
538
|
}
|
|
275
539
|
|
|
276
540
|
export interface RscResolver {
|
|
@@ -343,16 +607,17 @@ export interface BuildTiming {
|
|
|
343
607
|
buildEnd?: number;
|
|
344
608
|
renderStart?: number;
|
|
345
609
|
renderEnd?: number;
|
|
610
|
+
closeBundle?: number;
|
|
611
|
+
render?: number;
|
|
346
612
|
total?: number;
|
|
347
613
|
}
|
|
348
614
|
|
|
349
|
-
export type
|
|
615
|
+
export type ResolvedBuildPages = {
|
|
350
616
|
propsMap: Map<string, string>;
|
|
351
|
-
propsSet: Set<string>;
|
|
352
617
|
pageMap: Map<string, string>;
|
|
353
|
-
|
|
354
|
-
urlMap: Map<string, {props
|
|
355
|
-
errors:
|
|
618
|
+
routeMap: Map<string, string[]>;
|
|
619
|
+
urlMap: Map<string, { props?: string; page: string }>;
|
|
620
|
+
errors: Error[];
|
|
356
621
|
};
|
|
357
622
|
|
|
358
623
|
// Add strict type checking for worker messages
|
|
@@ -361,7 +626,11 @@ export type WorkerMessage =
|
|
|
361
626
|
| { type: "ERROR"; error: string | Error }
|
|
362
627
|
| { type: "RSC_CHUNK"; id: string; chunk: Buffer }
|
|
363
628
|
| { type: "RSC_END"; id: string }
|
|
364
|
-
| { type: "SHUTDOWN" }
|
|
629
|
+
| { type: "SHUTDOWN"; id: string }
|
|
630
|
+
| { type: "SHUTDOWN_COMPLETE" }
|
|
631
|
+
| { type: "CHUNK_PROCESSED"; id: string; success: boolean }
|
|
632
|
+
| { type: "CHUNK_ERROR"; id: string; error: string }
|
|
633
|
+
| { type: "METRICS"; metrics: StreamMetrics };
|
|
365
634
|
|
|
366
635
|
// Add branded types for safety
|
|
367
636
|
export type ModuleId = string & { readonly __brand: unique symbol };
|
|
@@ -371,52 +640,194 @@ export type HtmlProps = {
|
|
|
371
640
|
pageProps: any;
|
|
372
641
|
route: string;
|
|
373
642
|
url: string;
|
|
374
|
-
|
|
643
|
+
projectRoot: string;
|
|
644
|
+
moduleBase: string;
|
|
645
|
+
moduleBaseURL: string;
|
|
646
|
+
moduleBasePath: string;
|
|
647
|
+
moduleRootPath: string;
|
|
648
|
+
cssFiles: Map<string, CssContent>;
|
|
649
|
+
manifest: Manifest;
|
|
650
|
+
CssCollector: React.FC<React.PropsWithChildren<CssCollectorProps>>;
|
|
651
|
+
globalCss: Map<string, CssContent>;
|
|
375
652
|
};
|
|
376
653
|
|
|
377
654
|
export interface PageAsset {
|
|
378
|
-
type:
|
|
655
|
+
type: "css" | "js";
|
|
379
656
|
path: string;
|
|
380
657
|
parentUrl: string;
|
|
381
658
|
}
|
|
382
659
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
660
|
+
type BaseCssProps = {
|
|
661
|
+
as: string;
|
|
662
|
+
id: string;
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
type CssProps = BaseCssProps & {
|
|
666
|
+
as: "link";
|
|
667
|
+
type?: never;
|
|
668
|
+
children?: InlineCssProps extends false ? never : React.ReactNode;
|
|
669
|
+
id: string;
|
|
670
|
+
href: string;
|
|
671
|
+
rel: "stylesheet";
|
|
672
|
+
precedence?: string;
|
|
673
|
+
};
|
|
674
|
+
type InlineCssProps = BaseCssProps & {
|
|
675
|
+
as: "style";
|
|
676
|
+
type: "text/css";
|
|
677
|
+
children?: React.ReactNode;
|
|
678
|
+
precedence?: never;
|
|
679
|
+
rel?: never;
|
|
680
|
+
href?: never;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
export type CssContent<InlineCSS extends boolean | undefined = undefined> =
|
|
684
|
+
InlineCSS extends true
|
|
685
|
+
? InlineCssProps
|
|
686
|
+
: InlineCSS extends false
|
|
687
|
+
? CssProps
|
|
688
|
+
: CssProps | InlineCssProps;
|
|
396
689
|
|
|
397
|
-
export interface
|
|
690
|
+
export interface JsContent {
|
|
398
691
|
type?: string;
|
|
399
692
|
content: string;
|
|
400
693
|
key?: string;
|
|
401
694
|
path: string;
|
|
695
|
+
id?: string;
|
|
402
696
|
}
|
|
403
697
|
|
|
698
|
+
export type CssCollectorProps<
|
|
699
|
+
InlineCSS extends boolean | undefined = undefined
|
|
700
|
+
> = {
|
|
701
|
+
// to render the head tag or not
|
|
702
|
+
as?: React.ElementType;
|
|
703
|
+
children?: React.ReactNode;
|
|
704
|
+
/** A map containing all the css files imported by the route and their proxy values
|
|
705
|
+
* - when inlineCss is true, will contain the `content` property
|
|
706
|
+
* - when prugeCss is true, will contain the module proxy which includes a `userClasses`
|
|
707
|
+
* @example ```tsx
|
|
708
|
+
* import styles from './styles.module.css';
|
|
709
|
+
* export const Page = () => {
|
|
710
|
+
* return <div className={styles.userClass}>Hello World</div>
|
|
711
|
+
* }
|
|
712
|
+
* ```
|
|
713
|
+
* then the module will basically contain whatever `styles` exported here. But how does it track css class usages
|
|
714
|
+
* during streaming?
|
|
715
|
+
*
|
|
716
|
+
* const tags = Array.from(importedCss?.values() ?? []).map(cssFile => {
|
|
717
|
+
* return <link rel="stylesheet" href={cssFile.path} />
|
|
718
|
+
* })
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
*
|
|
722
|
+
* */
|
|
723
|
+
|
|
724
|
+
cssFiles?: Map<string, CssContent<InlineCSS>>;
|
|
725
|
+
} & React.HTMLAttributes<HTMLElement>;
|
|
726
|
+
|
|
404
727
|
export interface InlineCssCollectorProps {
|
|
405
|
-
cssFiles: CssContent
|
|
406
|
-
root: string;
|
|
728
|
+
cssFiles: Map<string, CssContent>;
|
|
407
729
|
moduleBaseURL: string;
|
|
408
|
-
moduleBasePath: string;
|
|
409
730
|
moduleRootPath: string;
|
|
410
|
-
|
|
731
|
+
moduleBasePath: string;
|
|
732
|
+
route?: string;
|
|
733
|
+
purgeCss?: boolean;
|
|
411
734
|
children?: React.ReactNode;
|
|
412
735
|
}
|
|
413
736
|
|
|
414
|
-
export interface
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
737
|
+
export interface HtmlRenderState {
|
|
738
|
+
id: string;
|
|
739
|
+
rscStream: PassThrough;
|
|
740
|
+
htmlStream: PassThrough;
|
|
741
|
+
progressStream: PassThrough;
|
|
742
|
+
errorTransform: Transform;
|
|
743
|
+
htmlChunks: string[];
|
|
744
|
+
pipeableStreamOptions: Omit<
|
|
745
|
+
ReactServerDomEsmOptions,
|
|
746
|
+
"onError" | "onPostpone"
|
|
747
|
+
>;
|
|
748
|
+
streamState: StreamMetrics;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
export type RenderPagesResult =
|
|
752
|
+
| {
|
|
753
|
+
type: "error";
|
|
754
|
+
error: Error;
|
|
755
|
+
failedRoutes: Set<string>;
|
|
756
|
+
completedRoutes: Set<string>;
|
|
757
|
+
htmlSizes: Map<string, number>;
|
|
758
|
+
rscSizes: Map<string, number>;
|
|
759
|
+
streamMetrics: StreamMetrics;
|
|
760
|
+
results: Map<
|
|
761
|
+
string,
|
|
762
|
+
{
|
|
763
|
+
html: PassThrough;
|
|
764
|
+
rsc: PassThrough;
|
|
765
|
+
metrics: {
|
|
766
|
+
rscFull: StreamMetrics;
|
|
767
|
+
rscHeadless: StreamMetrics;
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
>;
|
|
771
|
+
}
|
|
772
|
+
| {
|
|
773
|
+
type: "success";
|
|
774
|
+
completedRoutes: Set<string>;
|
|
775
|
+
failedRoutes?: never;
|
|
776
|
+
htmlSizes: Map<string, number>;
|
|
777
|
+
rscSizes: Map<string, number>;
|
|
778
|
+
streamMetrics: StreamMetrics;
|
|
779
|
+
results: Map<
|
|
780
|
+
string,
|
|
781
|
+
{
|
|
782
|
+
html: PassThrough;
|
|
783
|
+
rsc: PassThrough;
|
|
784
|
+
metrics: {
|
|
785
|
+
rscFull: StreamMetrics;
|
|
786
|
+
rscHeadless: StreamMetrics;
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
>;
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
export type HandlerAssets = {
|
|
793
|
+
css: CssContent[];
|
|
794
|
+
js: string[];
|
|
795
|
+
bootstrapModules: string[];
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
export type CreateHandlerResult =
|
|
799
|
+
| {
|
|
800
|
+
type: "success";
|
|
801
|
+
controller: AbortController;
|
|
802
|
+
stream: any;
|
|
803
|
+
assets: {
|
|
804
|
+
css: CssContent[];
|
|
805
|
+
js: string[];
|
|
806
|
+
bootstrapModules: string[];
|
|
807
|
+
};
|
|
808
|
+
route: string;
|
|
809
|
+
metrics: StreamMetrics;
|
|
810
|
+
}
|
|
811
|
+
| { type: "error"; error: Error }
|
|
812
|
+
| { type: "skip" };
|
|
813
|
+
|
|
814
|
+
export type ReactStaticEvent =
|
|
815
|
+
| FileWriteEvent
|
|
816
|
+
| {
|
|
817
|
+
type: "build.start";
|
|
818
|
+
data: {
|
|
819
|
+
pages: string[];
|
|
820
|
+
files: Array<[string, { page: string; props?: string }]>;
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
// Define LoaderContext interface locally
|
|
825
|
+
export interface LoaderContext {
|
|
826
|
+
data?: { port?: MessagePort };
|
|
827
|
+
}
|
|
828
|
+
// Add type declaration for import.meta.cssModules
|
|
829
|
+
declare global {
|
|
830
|
+
interface ImportMeta {
|
|
831
|
+
cssModules?: Record<string, Record<string, string>>;
|
|
832
|
+
}
|
|
833
|
+
}
|