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
|
@@ -1,73 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* plugin.ts
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Main Vite plugin for React Server Components (RSC) static site generation
|
|
5
|
+
*
|
|
6
|
+
* This module:
|
|
7
|
+
* 1. Orchestrates the entire static site generation process
|
|
8
|
+
* 2. Manages the lifecycle of the RSC rendering process
|
|
9
|
+
* 3. Handles file writing for both initial page loads and client-side navigation
|
|
10
|
+
* - Writes .html files for initial page loads (complete HTML document)
|
|
11
|
+
* - Writes .rsc files for client-side navigation (RSC content only)
|
|
12
|
+
* 4. Provides hooks for Vite to integrate with the build process
|
|
13
|
+
* 5. Manages worker threads for parallel rendering
|
|
14
|
+
* 6. Handles error reporting and metrics collection
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { join } from "node:path";
|
|
2
18
|
import { Worker } from "node:worker_threads";
|
|
3
19
|
import {
|
|
4
|
-
type ResolvedConfig,
|
|
5
|
-
type UserConfig,
|
|
6
20
|
type Manifest,
|
|
7
|
-
type
|
|
21
|
+
type ResolvedConfig,
|
|
8
22
|
type Plugin as VitePlugin,
|
|
9
23
|
createLogger,
|
|
10
24
|
} from "vite";
|
|
11
|
-
import { checkFilesExist } from "../checkFilesExist.js";
|
|
12
25
|
import { resolveOptions } from "../config/resolveOptions.js";
|
|
13
|
-
import { resolvePages } from "../config/resolvePages.js";
|
|
14
26
|
import { resolveUserConfig } from "../config/resolveUserConfig.js";
|
|
15
|
-
import { tryManifest } from "../helpers/tryManifest.js";
|
|
16
27
|
import { createBuildLoader } from "../loader/createBuildLoader.js";
|
|
17
28
|
import type {
|
|
18
29
|
BuildTiming,
|
|
19
|
-
CheckFilesExistReturn,
|
|
20
30
|
ReactStreamPluginMeta,
|
|
21
31
|
ResolvedUserConfig,
|
|
22
32
|
ResolvedUserOptions,
|
|
33
|
+
PluginEvent,
|
|
34
|
+
RenderPagesResult,
|
|
35
|
+
AutoDiscoveredFiles,
|
|
36
|
+
CssContent,
|
|
23
37
|
} from "../types.js";
|
|
24
38
|
import { type StreamPluginOptions } from "../types.js";
|
|
39
|
+
import { renderPages } from "./renderPages.js";
|
|
40
|
+
import { getBundleManifest } from "../helpers/getBundleManifest.js";
|
|
25
41
|
import { createWorker } from "../worker/createWorker.js";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
import { resolveAutoDiscover } from "../config/resolveAutoDiscover.js";
|
|
43
|
+
import { getCondition } from "../config/getCondition.js";
|
|
44
|
+
import {
|
|
45
|
+
serializedOptions,
|
|
46
|
+
serializeResolvedConfig,
|
|
47
|
+
} from "../helpers/serializeUserOptions.js";
|
|
48
|
+
import { collectManifestCss } from "../helpers/collectManifestCss.js";
|
|
49
|
+
import { createCssProps } from "../helpers/createCssProps.js";
|
|
50
|
+
import { tryManifest } from "../helpers/tryManifest.js";
|
|
51
|
+
|
|
52
|
+
if (getCondition() !== "react-server") {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"Condition mismatch, should be react-server but got " +
|
|
55
|
+
process.env["NODE_OPTIONS"]
|
|
56
|
+
);
|
|
57
|
+
}
|
|
31
58
|
|
|
32
|
-
let resolvedConfig: ResolvedConfig | null = null;
|
|
33
|
-
let loader: ((id: string) => Promise<Record<string, any>>) | null = null;
|
|
34
59
|
let worker: Worker;
|
|
35
|
-
let
|
|
36
|
-
let
|
|
60
|
+
let userConfig: ResolvedUserConfig;
|
|
61
|
+
let resolvedConfig: ResolvedConfig;
|
|
62
|
+
let userOptions: ResolvedUserOptions;
|
|
63
|
+
let autoDiscoveredFiles: AutoDiscoveredFiles | null = null;
|
|
64
|
+
let serverManifest: Manifest | undefined = undefined;
|
|
65
|
+
let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
|
|
37
66
|
|
|
38
67
|
export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
39
68
|
meta: ReactStreamPluginMeta;
|
|
40
69
|
}> {
|
|
41
70
|
const timing: BuildTiming = {
|
|
42
71
|
start: Date.now(),
|
|
72
|
+
configResolved: 0,
|
|
73
|
+
buildStart: 0,
|
|
74
|
+
renderStart: 0,
|
|
43
75
|
};
|
|
44
76
|
|
|
45
|
-
|
|
46
|
-
let root: string = process.cwd();
|
|
47
|
-
let userConfig: ResolvedUserConfig;
|
|
48
|
-
let userOptions: ResolvedUserOptions;
|
|
49
|
-
let pages: string[];
|
|
50
|
-
let serverManifest: Manifest = {};
|
|
51
|
-
let clientManifest: Manifest = {};
|
|
52
|
-
|
|
53
|
-
const resolvedOptions = resolveOptions(options, false);
|
|
77
|
+
const resolvedOptions = resolveOptions(options);
|
|
54
78
|
if (resolvedOptions.type === "error") {
|
|
55
79
|
throw resolvedOptions.error;
|
|
56
80
|
}
|
|
57
81
|
userOptions = resolvedOptions.userOptions;
|
|
58
|
-
if (
|
|
59
|
-
userOptions.projectRoot != root &&
|
|
60
|
-
typeof userOptions.projectRoot === "string" &&
|
|
61
|
-
userOptions.projectRoot !== process.cwd() &&
|
|
62
|
-
userOptions.projectRoot !== ""
|
|
63
|
-
) {
|
|
64
|
-
root = userOptions.projectRoot;
|
|
65
|
-
console.log(
|
|
66
|
-
"[vite:plugin-react-server] Root dir changed in plugin",
|
|
67
|
-
userOptions.projectRoot,
|
|
68
|
-
root
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
82
|
|
|
72
83
|
return {
|
|
73
84
|
name: "vite:plugin-react-server/static",
|
|
@@ -75,182 +86,298 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
75
86
|
api: {
|
|
76
87
|
meta: { timing },
|
|
77
88
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
config.root !== process.cwd() &&
|
|
83
|
-
config.root !== ""
|
|
84
|
-
) {
|
|
85
|
-
root = config.root;
|
|
89
|
+
|
|
90
|
+
async config(config, configEnv) {
|
|
91
|
+
if (config.root && config.root !== userOptions.projectRoot) {
|
|
92
|
+
userOptions.projectRoot = config.root;
|
|
86
93
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
|
|
95
|
+
const autoDiscoverResult = await resolveAutoDiscover({
|
|
96
|
+
config,
|
|
97
|
+
configEnv,
|
|
98
|
+
userOptions,
|
|
99
|
+
condition: "react-server",
|
|
100
|
+
});
|
|
101
|
+
if (autoDiscoverResult.type === "error") {
|
|
102
|
+
throw autoDiscoverResult.error;
|
|
90
103
|
}
|
|
91
|
-
|
|
92
|
-
files = await checkFilesExist(pages, userOptions, root);
|
|
104
|
+
autoDiscoveredFiles = autoDiscoverResult.autoDiscoveredFiles;
|
|
93
105
|
|
|
94
106
|
const resolvedConfig = resolveUserConfig({
|
|
95
|
-
|
|
107
|
+
condition: "react-server",
|
|
96
108
|
config,
|
|
97
109
|
configEnv,
|
|
98
110
|
userOptions,
|
|
99
|
-
|
|
111
|
+
autoDiscoveredFiles,
|
|
100
112
|
});
|
|
101
|
-
|
|
102
113
|
if (resolvedConfig.type === "error") {
|
|
103
114
|
throw resolvedConfig.error;
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
userConfig = resolvedConfig.userConfig;
|
|
107
118
|
timing.configResolved = Date.now();
|
|
108
|
-
return {};
|
|
109
119
|
},
|
|
120
|
+
configResolved(config) {
|
|
121
|
+
resolvedConfig = config;
|
|
122
|
+
},
|
|
123
|
+
|
|
110
124
|
async buildStart() {
|
|
111
125
|
timing.buildStart = Date.now();
|
|
126
|
+
if (userOptions.onEvent && autoDiscoveredFiles) {
|
|
127
|
+
userOptions.onEvent({
|
|
128
|
+
type: "build.start",
|
|
129
|
+
data: {
|
|
130
|
+
pages: Array.from(autoDiscoveredFiles.urlMap.keys()),
|
|
131
|
+
files: autoDiscoveredFiles,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
112
135
|
},
|
|
113
|
-
|
|
136
|
+
|
|
137
|
+
async renderStart() {
|
|
114
138
|
timing.renderStart = Date.now();
|
|
139
|
+
},
|
|
115
140
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
serverManifest = serverManifestResult.manifest;
|
|
141
|
+
async writeBundle(options, bundle) {
|
|
142
|
+
try {
|
|
143
|
+
const bundleManifest = getBundleManifest<false>({
|
|
144
|
+
bundle,
|
|
145
|
+
normalizer: userOptions.normalizer,
|
|
146
|
+
});
|
|
147
|
+
if (!("source" in bundleManifest[".vite/manifest.json"])) {
|
|
148
|
+
throw new Error("Server manifest not found");
|
|
149
|
+
}
|
|
126
150
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
outDir: join(userOptions.build.outDir, userOptions.build.client),
|
|
131
|
-
ssrManifest: false,
|
|
132
|
-
});
|
|
151
|
+
serverManifest = JSON.parse(
|
|
152
|
+
bundleManifest[".vite/manifest.json"].source as string
|
|
153
|
+
);
|
|
133
154
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
clientManifest = clientManifestResult.manifest;
|
|
155
|
+
if (!serverManifest) {
|
|
156
|
+
throw new Error("Failed to parse server manifest");
|
|
157
|
+
}
|
|
138
158
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
const clientManifestResult = await tryManifest({
|
|
160
|
+
root: userOptions.projectRoot,
|
|
161
|
+
outDir: join(userOptions.build.outDir, userOptions.build.client),
|
|
162
|
+
ssrManifest: false,
|
|
163
|
+
});
|
|
164
|
+
if (clientManifestResult.type === "error") {
|
|
165
|
+
throw clientManifestResult.error;
|
|
166
|
+
}
|
|
167
|
+
const clientManifest = clientManifestResult.manifest;
|
|
142
168
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
buildLoader = await createBuildLoader(
|
|
170
|
+
{
|
|
171
|
+
userConfig,
|
|
172
|
+
userOptions,
|
|
173
|
+
serverManifest: serverManifest ?? {},
|
|
174
|
+
staticManifest: autoDiscoveredFiles?.staticManifest ?? {},
|
|
175
|
+
clientManifest: clientManifest ?? {},
|
|
176
|
+
},
|
|
177
|
+
bundle
|
|
178
|
+
);
|
|
150
179
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
root: root,
|
|
154
|
-
userConfig,
|
|
155
|
-
userOptions,
|
|
156
|
-
pluginContext: this,
|
|
157
|
-
serverManifest,
|
|
158
|
-
clientManifest,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
180
|
+
// Create CSS props for each CSS file
|
|
181
|
+
const cssFilesByPage = new Map();
|
|
161
182
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
// First collect global styles from index.html
|
|
184
|
+
const globalCssInputs = collectManifestCss(
|
|
185
|
+
autoDiscoveredFiles?.staticManifest ?? {},
|
|
186
|
+
"index.html",
|
|
187
|
+
userOptions
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const globalCss: Map<string, CssContent> = new Map();
|
|
191
|
+
// Collect CSS files for each page and its props
|
|
192
|
+
for (const [url, { page, props }] of autoDiscoveredFiles?.urlMap ??
|
|
193
|
+
[]) {
|
|
194
|
+
const cssInputs = collectManifestCss(
|
|
195
|
+
serverManifest,
|
|
196
|
+
props ? [page, props] : page,
|
|
197
|
+
userOptions
|
|
198
|
+
);
|
|
178
199
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
// Create a map for this page's CSS files
|
|
201
|
+
const pageCssMap: Map<string, CssContent> = new Map();
|
|
202
|
+
|
|
203
|
+
// Add global styles if they exist
|
|
204
|
+
if (Object.keys(globalCssInputs).length > 0) {
|
|
205
|
+
for (const [, value] of Object.entries(globalCssInputs)) {
|
|
206
|
+
const cssContent = await buildLoader(value + "?inline").then(
|
|
207
|
+
(r) => String(r.default)
|
|
208
|
+
);
|
|
209
|
+
if (cssContent === "undefined") {
|
|
210
|
+
throw new Error(`CSS content is undefined for ${value}`);
|
|
211
|
+
}
|
|
212
|
+
if (cssContent) {
|
|
213
|
+
globalCss.set(
|
|
214
|
+
value,
|
|
215
|
+
createCssProps({
|
|
216
|
+
id: value,
|
|
217
|
+
code: cssContent,
|
|
218
|
+
css: userOptions.css,
|
|
219
|
+
moduleBaseURL: userOptions.moduleBaseURL,
|
|
220
|
+
moduleBasePath: userOptions.moduleBasePath,
|
|
221
|
+
moduleRootPath: userOptions.moduleRootPath,
|
|
222
|
+
projectRoot: userOptions.projectRoot,
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Add page-specific styles
|
|
230
|
+
for (const [, value] of Object.entries(cssInputs)) {
|
|
231
|
+
const { default: cssContent } = await buildLoader(
|
|
232
|
+
value + "?inline"
|
|
233
|
+
);
|
|
234
|
+
if (typeof cssContent !== "string") {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (cssContent) {
|
|
238
|
+
pageCssMap.set(
|
|
239
|
+
value,
|
|
240
|
+
createCssProps({
|
|
241
|
+
id: value,
|
|
242
|
+
code: cssContent,
|
|
243
|
+
css: userOptions.css,
|
|
244
|
+
moduleBaseURL: userOptions.moduleBaseURL,
|
|
245
|
+
moduleBasePath: userOptions.moduleBasePath,
|
|
246
|
+
moduleRootPath: userOptions.moduleRootPath,
|
|
247
|
+
projectRoot: userOptions.projectRoot,
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
cssFilesByPage.set(url, pageCssMap);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (userOptions.onEvent) {
|
|
256
|
+
userOptions.onEvent({
|
|
257
|
+
type: "build.writeBundle",
|
|
258
|
+
data: {
|
|
259
|
+
pages: Array.from(autoDiscoveredFiles?.urlMap.keys() ?? []),
|
|
260
|
+
options,
|
|
261
|
+
bundle,
|
|
262
|
+
manifest: serverManifest,
|
|
195
263
|
},
|
|
196
|
-
testClient: userOptions.autoDiscover.cssPattern,
|
|
197
|
-
testJson: userOptions.autoDiscover.jsonPattern,
|
|
198
264
|
});
|
|
199
|
-
routeCssMap.set(route, new Set([...globalCss, ...pageCss.cssFiles.keys()]));
|
|
200
265
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
266
|
+
const staticManifest = autoDiscoveredFiles?.staticManifest ?? {};
|
|
267
|
+
const indexHtml = staticManifest?.["index.html"]?.file;
|
|
268
|
+
const pipeableStreamOptions = {
|
|
269
|
+
...userOptions.pipeableStreamOptions,
|
|
270
|
+
bootstrapModules: [
|
|
271
|
+
...(indexHtml ? [indexHtml] : []),
|
|
272
|
+
...(userOptions.pipeableStreamOptions?.bootstrapModules ?? []),
|
|
273
|
+
],
|
|
274
|
+
};
|
|
275
|
+
userOptions.pipeableStreamOptions = pipeableStreamOptions;
|
|
276
|
+
const serializedUserOptions = serializedOptions(
|
|
277
|
+
userOptions,
|
|
278
|
+
autoDiscoveredFiles!
|
|
279
|
+
);
|
|
280
|
+
// Create worker
|
|
281
|
+
if (!worker) {
|
|
282
|
+
const workerResult = await createWorker({
|
|
283
|
+
projectRoot: userOptions.projectRoot,
|
|
284
|
+
workerPath: userOptions.htmlWorkerPath,
|
|
285
|
+
currentCondition: "react-server",
|
|
286
|
+
reverseCondition: "react-client",
|
|
287
|
+
workerData: {
|
|
288
|
+
resolvedConfig: serializeResolvedConfig(resolvedConfig),
|
|
289
|
+
userOptions: serializedUserOptions,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
if (workerResult.type === "error") {
|
|
293
|
+
throw workerResult.error;
|
|
294
|
+
} else if (workerResult.type === "skip") {
|
|
295
|
+
this.environment.logger.info("Worker not created, skipping static build");
|
|
296
|
+
return;
|
|
297
|
+
} else {
|
|
298
|
+
worker = workerResult.worker;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Render pages
|
|
302
|
+
const { onEvent, ...rest } = userOptions;
|
|
303
|
+
const renderPagesGenerator = renderPages(
|
|
304
|
+
autoDiscoveredFiles!,
|
|
305
|
+
{
|
|
306
|
+
...rest,
|
|
307
|
+
loader: buildLoader,
|
|
308
|
+
worker: worker,
|
|
309
|
+
logger: createLogger(),
|
|
310
|
+
onEvent: async (event: PluginEvent) => {
|
|
311
|
+
if (userOptions.onEvent) {
|
|
312
|
+
userOptions.onEvent(event);
|
|
313
|
+
}
|
|
314
|
+
// Add file write completion event
|
|
315
|
+
if (event.type === "file.write") {
|
|
316
|
+
await event.data.onComplete();
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
pipeableStreamOptions: pipeableStreamOptions,
|
|
320
|
+
manifest: serverManifest ?? {},
|
|
321
|
+
build: {
|
|
322
|
+
htmlOutputPath: userOptions.build.htmlOutputPath,
|
|
323
|
+
rscOutputPath: userOptions.build.rscOutputPath,
|
|
324
|
+
outDir: userOptions.build.outDir,
|
|
325
|
+
pages: userOptions.build.pages,
|
|
326
|
+
server: userOptions.build.server,
|
|
327
|
+
static: userOptions.build.static,
|
|
328
|
+
client: userOptions.build.client,
|
|
329
|
+
},
|
|
330
|
+
globalCss: globalCss,
|
|
217
331
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
cssFiles: [],
|
|
227
|
-
logger: createLogger(),
|
|
228
|
-
moduleBase: userOptions.moduleBase,
|
|
229
|
-
worker,
|
|
230
|
-
clientManifest,
|
|
231
|
-
serverManifest,
|
|
232
|
-
loader,
|
|
233
|
-
transformIndexHtml: htmlTransform!,
|
|
234
|
-
onClientJSFile: (url) => {
|
|
235
|
-
if (!clientAssets.has(url)) {
|
|
236
|
-
const clientPath = join(root, userOptions.build.outDir, userOptions.build.client, url);
|
|
237
|
-
const targetPath = join(root, userOptions.build.outDir, userOptions.build.static, url);
|
|
238
|
-
mkdirSync(dirname(targetPath), { recursive: true });
|
|
239
|
-
copyFileSync(clientPath, targetPath);
|
|
240
|
-
clientAssets.add(url);
|
|
241
|
-
}
|
|
332
|
+
cssFilesByPage,
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// Process render results
|
|
336
|
+
let finalResult: RenderPagesResult | undefined;
|
|
337
|
+
for await (const result of renderPagesGenerator) {
|
|
338
|
+
if (result.type === "error") {
|
|
339
|
+
throw result.error;
|
|
242
340
|
}
|
|
341
|
+
finalResult = result;
|
|
243
342
|
}
|
|
244
|
-
);
|
|
245
343
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
344
|
+
if (!finalResult) {
|
|
345
|
+
throw new Error("No render result produced");
|
|
346
|
+
}
|
|
347
|
+
finalResult.streamMetrics.duration = Math.round(performance.now() - finalResult.streamMetrics.startTime);
|
|
348
|
+
|
|
349
|
+
this.environment.logger.info(`Rendered ${finalResult.completedRoutes.size} unique routes in ${
|
|
350
|
+
finalResult.streamMetrics.duration
|
|
351
|
+
}ms`);
|
|
352
|
+
|
|
353
|
+
// Update timing
|
|
354
|
+
timing.render = Date.now() - (timing.renderStart ?? timing.start);
|
|
355
|
+
} catch (error) {
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Cleanup
|
|
360
|
+
try {
|
|
361
|
+
worker.postMessage({ type: "SHUTDOWN", id: "*" });
|
|
362
|
+
await new Promise<void>((resolve, reject) => {
|
|
363
|
+
const shutdownHandler = (msg: any) => {
|
|
364
|
+
if (msg.type === "SHUTDOWN_COMPLETE") {
|
|
365
|
+
worker.removeListener("message", shutdownHandler);
|
|
366
|
+
worker
|
|
367
|
+
.terminate()
|
|
368
|
+
.then((code) =>
|
|
369
|
+
code === 1
|
|
370
|
+
? resolve()
|
|
371
|
+
: reject(new Error(`Worker terminated with code ${code}`))
|
|
372
|
+
)
|
|
373
|
+
.catch(reject);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
worker.on("message", shutdownHandler);
|
|
377
|
+
});
|
|
378
|
+
} catch (error) {
|
|
379
|
+
throw error;
|
|
251
380
|
}
|
|
252
|
-
console.log(`Rendered ${completedRoutes.size} unique routes to ${join(userOptions.build.outDir, userOptions.build.static)}`);
|
|
253
|
-
await worker.terminate();
|
|
254
381
|
},
|
|
255
|
-
};
|
|
382
|
+
} as const;
|
|
256
383
|
}
|