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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { React, ReactDOMServer } from "../vendor.server.js";
|
|
2
|
+
import type { CreateHandlerOptions, StreamMetrics } from "../types.js";
|
|
3
|
+
|
|
4
|
+
export function createRscStream<
|
|
5
|
+
T,
|
|
6
|
+
C extends React.ComponentType<T>,
|
|
7
|
+
InlineCSS extends boolean = true
|
|
8
|
+
>({
|
|
9
|
+
Html = React.Fragment,
|
|
10
|
+
PageComponent,
|
|
11
|
+
pageProps,
|
|
12
|
+
moduleBase,
|
|
13
|
+
moduleRootPath,
|
|
14
|
+
moduleBasePath,
|
|
15
|
+
moduleBaseURL,
|
|
16
|
+
cssFiles = new Map(),
|
|
17
|
+
globalCss = new Map(),
|
|
18
|
+
route,
|
|
19
|
+
pipeableStreamOptions,
|
|
20
|
+
CssCollector,
|
|
21
|
+
manifest,
|
|
22
|
+
onEvent,
|
|
23
|
+
projectRoot,
|
|
24
|
+
}: Pick<
|
|
25
|
+
CreateHandlerOptions<T, C, InlineCSS>,
|
|
26
|
+
| "Html"
|
|
27
|
+
| "PageComponent"
|
|
28
|
+
| "pageProps"
|
|
29
|
+
| "moduleBase"
|
|
30
|
+
| "moduleRootPath"
|
|
31
|
+
| "moduleBasePath"
|
|
32
|
+
| "moduleBaseURL"
|
|
33
|
+
| "cssFiles"
|
|
34
|
+
| "route"
|
|
35
|
+
| "pipeableStreamOptions"
|
|
36
|
+
| "CssCollector"
|
|
37
|
+
| "globalCss"
|
|
38
|
+
| "manifest"
|
|
39
|
+
| "projectRoot"
|
|
40
|
+
> & {
|
|
41
|
+
onEvent?: (event: "error" | "postpone", data: any) => void;
|
|
42
|
+
}):
|
|
43
|
+
| { type: "success"; stream: any; metrics: StreamMetrics }
|
|
44
|
+
| { type: "error"; error: Error; metrics: StreamMetrics } {
|
|
45
|
+
const startTime = performance.now()
|
|
46
|
+
const htmlIsFragment = Html == React.Fragment;
|
|
47
|
+
const url =
|
|
48
|
+
moduleBaseURL !== "" ? new URL(route, moduleBaseURL).toString() : route;
|
|
49
|
+
let errorCount = 0;
|
|
50
|
+
let streamError: Error | null = null;
|
|
51
|
+
|
|
52
|
+
if (!PageComponent) {
|
|
53
|
+
return {
|
|
54
|
+
type: "error",
|
|
55
|
+
error: new Error("PageComponent is required"),
|
|
56
|
+
metrics: {
|
|
57
|
+
chunks: 0,
|
|
58
|
+
bytes: 0,
|
|
59
|
+
backpressureCount: 0,
|
|
60
|
+
drainCount: 0,
|
|
61
|
+
errorCount: 0,
|
|
62
|
+
duration: 0,
|
|
63
|
+
startTime: 0,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const elements = htmlIsFragment ? (
|
|
68
|
+
<CssCollector
|
|
69
|
+
cssFiles={cssFiles}
|
|
70
|
+
>
|
|
71
|
+
<PageComponent {...(pageProps as any)} />
|
|
72
|
+
</CssCollector>
|
|
73
|
+
) : (
|
|
74
|
+
<Html
|
|
75
|
+
moduleBase={moduleBase}
|
|
76
|
+
moduleBaseURL={moduleBaseURL}
|
|
77
|
+
moduleBasePath={moduleBasePath}
|
|
78
|
+
moduleRootPath={moduleRootPath}
|
|
79
|
+
projectRoot={projectRoot}
|
|
80
|
+
url={url}
|
|
81
|
+
route={route}
|
|
82
|
+
pageProps={pageProps}
|
|
83
|
+
cssFiles={cssFiles}
|
|
84
|
+
globalCss={globalCss}
|
|
85
|
+
CssCollector={CssCollector}
|
|
86
|
+
manifest={manifest}
|
|
87
|
+
>
|
|
88
|
+
<PageComponent {...(pageProps as any)} />
|
|
89
|
+
</Html>
|
|
90
|
+
);
|
|
91
|
+
try {
|
|
92
|
+
const stream = ReactDOMServer.renderToPipeableStream(
|
|
93
|
+
elements,
|
|
94
|
+
moduleBasePath,
|
|
95
|
+
{
|
|
96
|
+
...pipeableStreamOptions,
|
|
97
|
+
onError(error: Error, errorInfo: any) {
|
|
98
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
99
|
+
streamError = err;
|
|
100
|
+
onEvent?.("error", { route, error: err, errorInfo });
|
|
101
|
+
errorCount++;
|
|
102
|
+
},
|
|
103
|
+
onPostpone(reason: string) {
|
|
104
|
+
onEvent?.("postpone", { route, reason });
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// If we have a stream error, return it immediately
|
|
110
|
+
if (streamError) {
|
|
111
|
+
return {
|
|
112
|
+
type: "error",
|
|
113
|
+
error: streamError,
|
|
114
|
+
metrics: {
|
|
115
|
+
chunks: 0,
|
|
116
|
+
bytes: 0,
|
|
117
|
+
backpressureCount: 0,
|
|
118
|
+
drainCount: 0,
|
|
119
|
+
errorCount,
|
|
120
|
+
duration: Date.now() - startTime,
|
|
121
|
+
startTime: startTime,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
type: "success",
|
|
128
|
+
stream,
|
|
129
|
+
metrics: {
|
|
130
|
+
chunks: 0,
|
|
131
|
+
bytes: 0,
|
|
132
|
+
backpressureCount: 0,
|
|
133
|
+
drainCount: 0,
|
|
134
|
+
errorCount,
|
|
135
|
+
duration: Date.now() - startTime,
|
|
136
|
+
startTime: startTime,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
} catch (error) {
|
|
140
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
141
|
+
onEvent?.("error", { route, error: err });
|
|
142
|
+
return {
|
|
143
|
+
type: "error",
|
|
144
|
+
error: err,
|
|
145
|
+
metrics: {
|
|
146
|
+
chunks: 0,
|
|
147
|
+
bytes: 0,
|
|
148
|
+
backpressureCount: 0,
|
|
149
|
+
drainCount: 0,
|
|
150
|
+
errorCount: errorCount + 1,
|
|
151
|
+
duration: Date.now() - startTime,
|
|
152
|
+
startTime: startTime,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
File without changes
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
OutputBundle,
|
|
3
|
-
PluginContext,
|
|
4
3
|
OutputChunk,
|
|
5
4
|
} from "rollup";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import type { ManifestChunk } from "vite";
|
|
6
|
+
import type { InputNormalizer } from "../types.js";
|
|
8
7
|
|
|
9
|
-
interface BundleManifestEntry {
|
|
10
|
-
file: string;
|
|
11
|
-
name: string;
|
|
12
|
-
src?: string;
|
|
13
|
-
isEntry?: boolean;
|
|
14
|
-
imports?: string[];
|
|
15
|
-
dynamicImports?: string[];
|
|
16
|
-
css?: string[];
|
|
17
|
-
}
|
|
18
8
|
|
|
19
9
|
/**
|
|
20
10
|
* Get the bundle manifest from the plugin context. Will only work during production build
|
|
@@ -23,23 +13,17 @@ interface BundleManifestEntry {
|
|
|
23
13
|
* @param preserveModulesRoot - The preserve modules root
|
|
24
14
|
* @returns The bundle manifest
|
|
25
15
|
*/
|
|
26
|
-
export function getBundleManifest({
|
|
27
|
-
pluginContext,
|
|
16
|
+
export function getBundleManifest<SSR extends boolean>({
|
|
28
17
|
bundle,
|
|
29
|
-
|
|
30
|
-
preserveModulesRoot,
|
|
18
|
+
normalizer,
|
|
31
19
|
}: {
|
|
32
|
-
pluginContext: PluginContext,
|
|
33
20
|
bundle: OutputBundle,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
removeExtension: DEFAULT_CONFIG.FILE_REGEX,
|
|
41
|
-
preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined,
|
|
42
|
-
});
|
|
21
|
+
normalizer: InputNormalizer,
|
|
22
|
+
}): SSR extends true ? Record<string, string[]> : {
|
|
23
|
+
[key: string]: ManifestChunk & {
|
|
24
|
+
source: string,
|
|
25
|
+
}
|
|
26
|
+
} {
|
|
43
27
|
|
|
44
28
|
if (!bundle) return {};
|
|
45
29
|
|
|
@@ -48,12 +32,32 @@ export function getBundleManifest({
|
|
|
48
32
|
|
|
49
33
|
const bundleManifest = Object.fromEntries(
|
|
50
34
|
Object.entries(bundle)
|
|
51
|
-
.map(([
|
|
52
|
-
if
|
|
35
|
+
.map(([originalFileName, chunk]) => {
|
|
36
|
+
if(!originalFileName && 'file' in chunk) {
|
|
37
|
+
return [
|
|
38
|
+
chunk.file,
|
|
39
|
+
{
|
|
40
|
+
file: chunk.file,
|
|
41
|
+
source: 'source' in chunk ? chunk.source : undefined,
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
if (chunk.type === "asset") {
|
|
46
|
+
return [
|
|
47
|
+
originalFileName,
|
|
48
|
+
{
|
|
49
|
+
file: chunk.fileName,
|
|
50
|
+
name: chunk.names[0],
|
|
51
|
+
src: originalFileName,
|
|
52
|
+
source: chunk.source,
|
|
53
|
+
isEntry: chunk.needsCodeReference,
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
53
57
|
const chunkWithFacade = chunk as OutputChunk;
|
|
54
58
|
|
|
55
59
|
// Get the module ID, preferring facadeModuleId
|
|
56
|
-
const moduleId = chunkWithFacade.facadeModuleId || chunkWithFacade.moduleIds[0] ||
|
|
60
|
+
const moduleId = chunkWithFacade.facadeModuleId || chunkWithFacade.moduleIds[0] || originalFileName;
|
|
57
61
|
|
|
58
62
|
// Handle commonjs helpers specially - must be done before normalization
|
|
59
63
|
if (moduleId.includes('commonjsHelpers')) {
|
|
@@ -72,7 +76,7 @@ export function getBundleManifest({
|
|
|
72
76
|
let [normalizedId, sourcePath] = normalizer(moduleId);
|
|
73
77
|
|
|
74
78
|
// For virtual modules, use a consistent naming scheme
|
|
75
|
-
let finalFileName =
|
|
79
|
+
let finalFileName = originalFileName;
|
|
76
80
|
if (moduleId.includes('?')) {
|
|
77
81
|
const [basePath, query] = moduleId.split('?');
|
|
78
82
|
const virtualPath = basePath.includes('node_modules')
|
|
@@ -84,12 +88,13 @@ export function getBundleManifest({
|
|
|
84
88
|
|
|
85
89
|
if (!virtualModules.has(virtualKey)) {
|
|
86
90
|
// First time seeing this virtual module
|
|
87
|
-
const virtualFileName = `${virtualPath
|
|
91
|
+
const virtualFileName = query === 'inline' ? virtualPath : `${virtualPath}.${query}.js`;
|
|
88
92
|
virtualModules.set(virtualKey, virtualFileName);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
finalFileName = virtualModules.get(virtualKey)!;
|
|
92
96
|
}
|
|
97
|
+
|
|
93
98
|
// handle preserveModulesRoot
|
|
94
99
|
if(normalizedId.startsWith('\x00')){
|
|
95
100
|
normalizedId = normalizedId.slice(1);
|
|
@@ -97,9 +102,11 @@ export function getBundleManifest({
|
|
|
97
102
|
if(sourcePath.startsWith('/')){
|
|
98
103
|
sourcePath = sourcePath.slice(1);
|
|
99
104
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const withCss = chunk.viteMetadata?.importedCss?.size ? {
|
|
108
|
+
css: Array.from(chunk.viteMetadata.importedCss),
|
|
109
|
+
} : {};
|
|
103
110
|
const bundleManifestEntry = [
|
|
104
111
|
sourcePath,
|
|
105
112
|
{
|
|
@@ -109,9 +116,7 @@ export function getBundleManifest({
|
|
|
109
116
|
isEntry: chunk.isEntry,
|
|
110
117
|
...(chunk.imports?.length > 0 ? { imports: chunk.imports } : {}),
|
|
111
118
|
...(chunk.dynamicImports?.length > 0 ? { dynamicImports: chunk.dynamicImports } : {}),
|
|
112
|
-
...
|
|
113
|
-
css: Array.from(chunk.viteMetadata.importedCss),
|
|
114
|
-
} : {}),
|
|
119
|
+
...withCss,
|
|
115
120
|
},
|
|
116
121
|
];
|
|
117
122
|
return bundleManifestEntry;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ResolvedUserOptions } from "../types.js";
|
|
2
|
+
|
|
3
|
+
import { resolveUrlOption } from "../config/resolveUrlOption.js";
|
|
4
|
+
import type { AutoDiscoveredFiles } from "../types.js";
|
|
5
|
+
|
|
6
|
+
type GetRouteFilesSuccess = {
|
|
7
|
+
type: "success";
|
|
8
|
+
page: string;
|
|
9
|
+
props?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type GetRouteFilesError = {
|
|
13
|
+
type: "error";
|
|
14
|
+
error: Error;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getRouteFiles = async (
|
|
18
|
+
route: string,
|
|
19
|
+
autoDiscoveredFiles: AutoDiscoveredFiles,
|
|
20
|
+
userOptions: ResolvedUserOptions
|
|
21
|
+
): Promise<GetRouteFilesSuccess | GetRouteFilesError> => {
|
|
22
|
+
if (autoDiscoveredFiles.urlMap.has(route)) {
|
|
23
|
+
const { page, props } = autoDiscoveredFiles.urlMap.get(route)!;
|
|
24
|
+
return { type: "success", page, props };
|
|
25
|
+
}
|
|
26
|
+
const { type, error, Page } = await resolveUrlOption(
|
|
27
|
+
userOptions,
|
|
28
|
+
"Page",
|
|
29
|
+
route
|
|
30
|
+
);
|
|
31
|
+
if(type === "error") {
|
|
32
|
+
return { type: "error", error };
|
|
33
|
+
}
|
|
34
|
+
if (!userOptions.props) {
|
|
35
|
+
return { type: "success", page: Page, props: undefined };
|
|
36
|
+
}
|
|
37
|
+
const {
|
|
38
|
+
type: propsType,
|
|
39
|
+
error: propsError,
|
|
40
|
+
props,
|
|
41
|
+
} = await resolveUrlOption(userOptions, "props", route);
|
|
42
|
+
|
|
43
|
+
if (propsType === "error") {
|
|
44
|
+
return { type: "error", error: propsError };
|
|
45
|
+
}
|
|
46
|
+
return { type: "success", page: Page, props };
|
|
47
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
2
|
import type { InputNormalizer, NormalizerInput } from "../types.js";
|
|
3
|
-
import { join } from "path";
|
|
3
|
+
import path, { join } from "path";
|
|
4
4
|
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
5
5
|
|
|
6
|
+
let stashedNormalizer: InputNormalizer | null = null;
|
|
7
|
+
|
|
6
8
|
type CreateInputNormalizerProps = {
|
|
7
9
|
root: string;
|
|
8
10
|
preserveModulesRoot?: string | undefined;
|
|
@@ -49,7 +51,7 @@ const resolveRootOption = (
|
|
|
49
51
|
) => {
|
|
50
52
|
if (typeof preserveModulesRoot === "string" && typeof root === "string") {
|
|
51
53
|
const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);
|
|
52
|
-
if (normalizedPreserveModulesRoot.startsWith(root)) {
|
|
54
|
+
if (root !== "" && normalizedPreserveModulesRoot.startsWith(root)) {
|
|
53
55
|
return normalizedPreserveModulesRoot.slice(root.length + 1);
|
|
54
56
|
}
|
|
55
57
|
return "";
|
|
@@ -75,8 +77,10 @@ const createKeyNormalizer =
|
|
|
75
77
|
|
|
76
78
|
let moduleId = normalizePath(actualKey);
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
// Normalize root path to handle both absolute and relative paths
|
|
81
|
+
const normalizedRootPath = normalizePath(normalizedRoot);
|
|
82
|
+
if (moduleId.startsWith(normalizedRootPath)) {
|
|
83
|
+
moduleId = moduleId.slice(normalizedRootPath.length);
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
moduleId = handleExtension(moduleId);
|
|
@@ -88,7 +92,7 @@ const createKeyNormalizer =
|
|
|
88
92
|
}
|
|
89
93
|
if (typeof preserveModulesRoot === "string" && preserveModulesRoot !== "") {
|
|
90
94
|
moduleId = moduleId.startsWith(preserveModulesRoot)
|
|
91
|
-
? moduleId.slice(preserveModulesRoot.length)
|
|
95
|
+
? moduleId.slice(preserveModulesRoot.length + path.sep.length)
|
|
92
96
|
: moduleId;
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -132,17 +136,18 @@ const createPathNormalizer =
|
|
|
132
136
|
export function createInputNormalizer({
|
|
133
137
|
root,
|
|
134
138
|
preserveModulesRoot = undefined,
|
|
135
|
-
removeExtension = DEFAULT_CONFIG.
|
|
139
|
+
removeExtension = DEFAULT_CONFIG.MODULE_EXTENSION,
|
|
136
140
|
}: CreateInputNormalizerProps): InputNormalizer {
|
|
141
|
+
if(stashedNormalizer) {
|
|
142
|
+
return stashedNormalizer;
|
|
143
|
+
}
|
|
137
144
|
const relativeRoot = resolveRootOption(root, preserveModulesRoot);
|
|
138
145
|
const handleExtension = resolveExtensionOptions(removeExtension);
|
|
139
|
-
|
|
140
146
|
const normalizeEntryKey = createKeyNormalizer({
|
|
141
147
|
root: root,
|
|
142
|
-
preserveModulesRoot:
|
|
148
|
+
preserveModulesRoot: preserveModulesRoot,
|
|
143
149
|
handleExtension,
|
|
144
150
|
});
|
|
145
|
-
|
|
146
151
|
const normalizeEntryPath = createPathNormalizer({
|
|
147
152
|
root: root,
|
|
148
153
|
preserveModulesRoot: relativeRoot,
|
|
@@ -182,7 +187,7 @@ export function createInputNormalizer({
|
|
|
182
187
|
throw new Error(`Invalid input type: ${typeof id}`);
|
|
183
188
|
};
|
|
184
189
|
|
|
185
|
-
|
|
190
|
+
stashedNormalizer = (input: NormalizerInput): [string, string] => {
|
|
186
191
|
const [key, path] = normalizeInput(input);
|
|
187
192
|
// Apply the same normalization to both key and path
|
|
188
193
|
const normalizedPath = path.startsWith('/') ? path.slice(1) : path;
|
|
@@ -195,4 +200,5 @@ export function createInputNormalizer({
|
|
|
195
200
|
|
|
196
201
|
return [key, finalPath];
|
|
197
202
|
};
|
|
203
|
+
return stashedNormalizer;
|
|
198
204
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import type { StreamMetrics, RenderMetrics } from "../types.js";
|
|
3
|
+
import type { PipeableStream } from "react-dom/server";
|
|
4
|
+
|
|
5
|
+
export function createStreamMetrics(): StreamMetrics {
|
|
6
|
+
return {
|
|
7
|
+
chunks: 0,
|
|
8
|
+
bytes: 0,
|
|
9
|
+
backpressureCount: 0,
|
|
10
|
+
drainCount: 0,
|
|
11
|
+
errorCount: 0,
|
|
12
|
+
duration: 0,
|
|
13
|
+
startTime: performance.now()
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createRenderMetrics(route: string): RenderMetrics {
|
|
18
|
+
return {
|
|
19
|
+
route,
|
|
20
|
+
htmlSize: 0,
|
|
21
|
+
rscSize: 0,
|
|
22
|
+
processingTime: 0,
|
|
23
|
+
chunks: 0,
|
|
24
|
+
chunkRate: 0,
|
|
25
|
+
memoryUsage: process.memoryUsage(),
|
|
26
|
+
streamMetrics: createStreamMetrics(),
|
|
27
|
+
htmlSizes: new Map(),
|
|
28
|
+
rscSizes: new Map(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates a transform stream that collects metrics from the input stream
|
|
34
|
+
* @param stream The stream to collect metrics from
|
|
35
|
+
* @returns A promise that resolves with the metrics when the stream ends
|
|
36
|
+
*/
|
|
37
|
+
export function collectStreamMetrics(stream: PipeableStream | NodeJS.ReadableStream): Promise<StreamMetrics> {
|
|
38
|
+
const metrics = createStreamMetrics();
|
|
39
|
+
const startTime = performance.now()
|
|
40
|
+
|
|
41
|
+
return new Promise<StreamMetrics>((resolve, reject) => {
|
|
42
|
+
const transform = new Transform({
|
|
43
|
+
transform(chunk, _encoding, callback) {
|
|
44
|
+
metrics.chunks++;
|
|
45
|
+
metrics.bytes += chunk.length;
|
|
46
|
+
callback(null, chunk);
|
|
47
|
+
},
|
|
48
|
+
flush(callback) {
|
|
49
|
+
metrics.duration = Date.now() - startTime;
|
|
50
|
+
callback();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
stream.pipe(transform);
|
|
55
|
+
|
|
56
|
+
transform.on("error", (error) => {
|
|
57
|
+
reject(error);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
transform.on("end", () => {
|
|
61
|
+
resolve(metrics);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { resolvePage } from "../resolvePage.js";
|
|
2
|
+
import { resolveProps } from "../resolveProps.js";
|
|
3
|
+
|
|
4
|
+
type ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {
|
|
5
|
+
pagePath: string;
|
|
6
|
+
pageExportName: N1;
|
|
7
|
+
propsPath?: string;
|
|
8
|
+
propsExportName?: N2;
|
|
9
|
+
route: string;
|
|
10
|
+
loader: (id: string) => Promise<any>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type ResolvePageAndPropsResult<T> =
|
|
14
|
+
| {
|
|
15
|
+
type: "success";
|
|
16
|
+
error?: never;
|
|
17
|
+
PageComponent: React.ComponentType<T>;
|
|
18
|
+
pageProps: T;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
type: "error";
|
|
22
|
+
error: Error;
|
|
23
|
+
PageComponent?: never;
|
|
24
|
+
pageProps?: never;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
type: "skip";
|
|
28
|
+
error?: never;
|
|
29
|
+
PageComponent?: never;
|
|
30
|
+
pageProps?: never;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export async function resolvePageAndProps<
|
|
34
|
+
T,
|
|
35
|
+
N1 extends string,
|
|
36
|
+
N2 extends string
|
|
37
|
+
>(
|
|
38
|
+
handlerOptions: ResolvePageAndPropsOptions<N1, N2>
|
|
39
|
+
): Promise<ResolvePageAndPropsResult<T>> {
|
|
40
|
+
try {
|
|
41
|
+
// Load the page component
|
|
42
|
+
const resolvePagePromise = resolvePage({
|
|
43
|
+
id: handlerOptions.pagePath,
|
|
44
|
+
exportName: handlerOptions.pageExportName,
|
|
45
|
+
loader: handlerOptions.loader,
|
|
46
|
+
});
|
|
47
|
+
const resolvePropsPromise = resolveProps({
|
|
48
|
+
url: handlerOptions.route,
|
|
49
|
+
id: handlerOptions.propsPath ?? handlerOptions.pagePath,
|
|
50
|
+
exportName: handlerOptions.propsExportName ?? "default",
|
|
51
|
+
loader: handlerOptions.propsPath
|
|
52
|
+
? handlerOptions.loader
|
|
53
|
+
: async () => {
|
|
54
|
+
const resolvePageResult = await resolvePagePromise;
|
|
55
|
+
if (resolvePageResult.type != "success") {
|
|
56
|
+
return resolvePageResult;
|
|
57
|
+
}
|
|
58
|
+
return resolvePageResult.module;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const [resolvePageResult, resolvePropsResult] = await Promise.all([resolvePagePromise, resolvePropsPromise]);
|
|
62
|
+
if (resolvePageResult.type != "success") {
|
|
63
|
+
return resolvePageResult;
|
|
64
|
+
}
|
|
65
|
+
if (resolvePropsResult.type != "success") {
|
|
66
|
+
return resolvePropsResult;
|
|
67
|
+
}
|
|
68
|
+
const { Page } = resolvePageResult;
|
|
69
|
+
const { props } = resolvePropsResult;
|
|
70
|
+
return {
|
|
71
|
+
type: "success",
|
|
72
|
+
PageComponent: Page as React.ComponentType<T>,
|
|
73
|
+
pageProps: props as T,
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
type: "error",
|
|
78
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|