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,25 +1,20 @@
|
|
|
1
1
|
import type { ConfigEnv, UserConfig } from "vite";
|
|
2
2
|
import type {
|
|
3
|
-
CheckFilesExistReturn,
|
|
4
3
|
ResolvedUserConfig,
|
|
5
4
|
ResolvedUserOptions,
|
|
5
|
+
AutoDiscoveredFiles,
|
|
6
6
|
} from "../types.js";
|
|
7
|
-
import {
|
|
8
|
-
import { join } from "path";
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
import { globSync } from "fs";
|
|
7
|
+
import { join } from "node:path";
|
|
11
8
|
import type { OutputOptions } from "rollup";
|
|
12
|
-
import { pluginRoot } from "../root.js";
|
|
13
9
|
|
|
14
10
|
let stashedUserConfig: Record<string, ResolvedUserConfig | null> = {};
|
|
15
11
|
|
|
16
12
|
export type ResolveUserConfigProps = {
|
|
17
|
-
|
|
18
|
-
isStatic?: boolean;
|
|
13
|
+
condition: "react-client" | "react-server";
|
|
19
14
|
config: UserConfig;
|
|
20
15
|
configEnv: ConfigEnv;
|
|
21
16
|
userOptions: ResolvedUserOptions;
|
|
22
|
-
|
|
17
|
+
autoDiscoveredFiles: Pick<AutoDiscoveredFiles, "inputs" | "staticManifest">;
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
export type ResolveUserConfigReturn =
|
|
@@ -27,151 +22,60 @@ export type ResolveUserConfigReturn =
|
|
|
27
22
|
| { type: "error"; error: Error };
|
|
28
23
|
|
|
29
24
|
export function resolveUserConfig({
|
|
30
|
-
|
|
31
|
-
isStatic = false,
|
|
25
|
+
condition,
|
|
32
26
|
config,
|
|
33
27
|
configEnv,
|
|
34
28
|
userOptions,
|
|
35
|
-
|
|
29
|
+
autoDiscoveredFiles,
|
|
36
30
|
}: ResolveUserConfigProps): ResolveUserConfigReturn {
|
|
37
|
-
if(isStatic) {
|
|
38
|
-
const serverConfig = stashedUserConfig[`${userOptions.build.server}-ssr`]
|
|
39
|
-
if(!serverConfig) {
|
|
40
|
-
return {
|
|
41
|
-
type: "error",
|
|
42
|
-
error: new Error("Static plugin should run after the server plugin"),
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
type: "success",
|
|
47
|
-
userConfig: serverConfig,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const envDir = isStatic
|
|
51
|
-
? userOptions.build.static
|
|
52
|
-
: isClient
|
|
53
|
-
? userOptions.build.client
|
|
54
|
-
: userOptions.build.server;
|
|
55
31
|
const ssr =
|
|
56
32
|
typeof config.build?.ssr === "boolean"
|
|
57
33
|
? config.build?.ssr
|
|
58
|
-
: configEnv.isSsrBuild ||
|
|
34
|
+
: Boolean(configEnv.isSsrBuild) || condition === "react-server";
|
|
35
|
+
const envDir =
|
|
36
|
+
condition === "react-client" && ssr
|
|
37
|
+
? userOptions.build.client
|
|
38
|
+
: condition === "react-client"
|
|
39
|
+
? userOptions.build.static
|
|
40
|
+
: userOptions.build.server;
|
|
59
41
|
const envId = `${envDir}${ssr ? "-ssr" : ""}`;
|
|
42
|
+
|
|
60
43
|
if (stashedUserConfig[envId]) {
|
|
61
|
-
console.log(`[RSC] Using cached config for ${envId}`);
|
|
62
44
|
return {
|
|
63
45
|
type: "success",
|
|
64
46
|
userConfig: stashedUserConfig[envId],
|
|
65
47
|
};
|
|
66
48
|
}
|
|
49
|
+
|
|
67
50
|
// Get existing inputs
|
|
68
51
|
const root = config.root ?? userOptions.projectRoot ?? process.cwd();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
? userOptions.moduleBase
|
|
74
|
-
: undefined,
|
|
75
|
-
removeExtension: true,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const serverEntry = userOptions.serverEntry
|
|
79
|
-
? Object.fromEntries([
|
|
80
|
-
normalizer([userOptions.serverEntry, userOptions.serverEntry]),
|
|
81
|
-
])
|
|
82
|
-
: null;
|
|
83
|
-
const clientEntry = userOptions.clientEntry
|
|
84
|
-
? Object.fromEntries(
|
|
85
|
-
[
|
|
86
|
-
[userOptions.clientEntry, userOptions.clientEntry],
|
|
87
|
-
["index.html", "index.html"],
|
|
88
|
-
].map(normalizer)
|
|
89
|
-
)
|
|
90
|
-
: { "index.html": "index.html" };
|
|
91
|
-
|
|
92
|
-
const autoDiscoveredClientFiles = (inputs: Record<string, string>) => {
|
|
93
|
-
const allFiles = globSync(`**/*.client.*`, {
|
|
94
|
-
cwd: join(root, userOptions.moduleBase),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
for (const file of allFiles) {
|
|
98
|
-
const [key, value] = normalizer(join(userOptions.moduleBase, file));
|
|
99
|
-
if (!inputs[key]) {
|
|
100
|
-
inputs[key] = value;
|
|
101
|
-
} else {
|
|
102
|
-
console.warn(`[RSC] Client file already exists: ${key}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return inputs;
|
|
106
|
-
};
|
|
107
|
-
const autoDiscoveredServerFiles = (inputs: Record<string, string>) => {
|
|
108
|
-
const allFiles = globSync(`${userOptions.moduleBase}/**/*.server.*`, {
|
|
109
|
-
cwd: join(root, userOptions.moduleBase),
|
|
110
|
-
});
|
|
111
|
-
for (const file of allFiles) {
|
|
112
|
-
const [key, value] = normalizer(join(userOptions.moduleBase, file));
|
|
113
|
-
if (!inputs[key]) {
|
|
114
|
-
inputs[key] = value;
|
|
115
|
-
} else {
|
|
116
|
-
console.warn(`[RSC] Server file already exists: ${key}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return inputs;
|
|
120
|
-
};
|
|
121
|
-
const customWorkerFiles = (inputs: Record<string, string>) => {
|
|
122
|
-
const customRscWorker = !userOptions.rscWorkerPath.startsWith(pluginRoot)
|
|
123
|
-
const customHtmlWorker = !userOptions.htmlWorkerPath.startsWith(pluginRoot)
|
|
124
|
-
if(customRscWorker && !inputs['rsc-worker']) {
|
|
125
|
-
inputs['rsc-worker'] = userOptions.rscWorkerPath
|
|
126
|
-
}
|
|
127
|
-
if(customHtmlWorker && !inputs['html-worker']) {
|
|
128
|
-
inputs['html-worker'] = userOptions.htmlWorkerPath
|
|
129
|
-
}
|
|
130
|
-
return inputs
|
|
131
|
-
}
|
|
132
|
-
const autoDiscoveredFiles = (inputs: Record<string, string>) => {
|
|
133
|
-
if (!files) return inputs;
|
|
134
|
-
|
|
135
|
-
// Add page files without extra prefix
|
|
136
|
-
for (const [key, value] of files.pageMap) {
|
|
137
|
-
if (!inputs[key]) {
|
|
138
|
-
inputs[key] = value;
|
|
139
|
-
} else {
|
|
140
|
-
console.warn(`[RSC] Page file already exists: ${key}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// Add props files without extra prefix
|
|
144
|
-
for (const [key, value] of files.propsMap) {
|
|
145
|
-
if (!inputs[key]) {
|
|
146
|
-
inputs[key] = value;
|
|
147
|
-
} else {
|
|
148
|
-
console.warn(`[RSC] Props file already exists: ${key}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return inputs;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// Add inputs based on condition
|
|
155
|
-
let inputs = isClient
|
|
156
|
-
? autoDiscoveredClientFiles(clientEntry)
|
|
157
|
-
: customWorkerFiles(autoDiscoveredServerFiles(autoDiscoveredFiles(serverEntry ?? {})));
|
|
158
|
-
|
|
52
|
+
const staticEntries =
|
|
53
|
+
ssr && autoDiscoveredFiles.staticManifest
|
|
54
|
+
? Object.entries(autoDiscoveredFiles.staticManifest)
|
|
55
|
+
: [];
|
|
159
56
|
const pluginOutput = {
|
|
160
|
-
preserveModules: !isClient,
|
|
161
57
|
preserveModulesRoot: userOptions.build.preserveModulesRoot
|
|
162
58
|
? userOptions.moduleBase
|
|
163
59
|
: undefined,
|
|
164
|
-
entryFileNames:
|
|
165
|
-
|
|
166
|
-
|
|
60
|
+
entryFileNames: (info) => {
|
|
61
|
+
if (ssr) {
|
|
62
|
+
const entry = staticEntries.find(([, { file }]) =>
|
|
63
|
+
file.startsWith(info.name)
|
|
64
|
+
);
|
|
65
|
+
if (entry) {
|
|
66
|
+
return entry[1].file;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return userOptions.build.entryFile(info, ssr);
|
|
70
|
+
},
|
|
71
|
+
assetFileNames: (i) => {
|
|
72
|
+
return userOptions.build.assetFile(i, false);
|
|
73
|
+
},
|
|
74
|
+
chunkFileNames: (i) => {
|
|
75
|
+
return userOptions.build.chunkFile(i, ssr);
|
|
76
|
+
},
|
|
167
77
|
format: "esm",
|
|
168
78
|
exports: "named",
|
|
169
|
-
hoistTransitiveImports: false,
|
|
170
|
-
generatedCode: {
|
|
171
|
-
constBindings: true,
|
|
172
|
-
objectShorthand: true,
|
|
173
|
-
},
|
|
174
|
-
interop: "auto",
|
|
175
79
|
} satisfies OutputOptions;
|
|
176
80
|
|
|
177
81
|
let newOutput = Array.isArray(config.build?.rollupOptions?.output)
|
|
@@ -180,80 +84,125 @@ export function resolveUserConfig({
|
|
|
180
84
|
config.build?.rollupOptions?.output !== null
|
|
181
85
|
? [config.build?.rollupOptions?.output, pluginOutput]
|
|
182
86
|
: pluginOutput;
|
|
183
|
-
|
|
184
|
-
|
|
87
|
+
const mode =
|
|
88
|
+
process.env["NODE_ENV"] === "development"
|
|
89
|
+
? "development"
|
|
90
|
+
: config.mode
|
|
91
|
+
? config.mode
|
|
92
|
+
: configEnv.mode
|
|
93
|
+
? configEnv.mode
|
|
94
|
+
: configEnv.command === "build"
|
|
95
|
+
? "production"
|
|
96
|
+
: "development";
|
|
97
|
+
const minify = config.build?.minify;
|
|
98
|
+
if (condition === "react-client") {
|
|
185
99
|
// client plugin build options (client plugin still outputs server files)
|
|
186
100
|
stashedUserConfig[envId] = {
|
|
187
101
|
...config,
|
|
188
102
|
root: root,
|
|
189
|
-
mode:
|
|
190
|
-
configEnv.mode ?? configEnv.command === "build"
|
|
191
|
-
? "production"
|
|
192
|
-
: "development",
|
|
103
|
+
mode: mode,
|
|
193
104
|
resolve: {
|
|
194
|
-
|
|
195
|
-
|
|
105
|
+
...config.resolve,
|
|
106
|
+
external: config.resolve?.external ?? [
|
|
107
|
+
"react",
|
|
108
|
+
"react-dom",
|
|
109
|
+
"react-server-dom-esm/client",
|
|
110
|
+
],
|
|
196
111
|
},
|
|
197
112
|
ssr: {
|
|
198
|
-
|
|
199
|
-
|
|
113
|
+
...config.ssr,
|
|
114
|
+
target: config.ssr?.target ?? "node",
|
|
115
|
+
optimizeDeps: {
|
|
116
|
+
...config.ssr?.optimizeDeps,
|
|
117
|
+
include: config.ssr?.optimizeDeps?.include ?? [
|
|
118
|
+
"react",
|
|
119
|
+
"react-dom",
|
|
120
|
+
"react-server-dom-esm/client",
|
|
121
|
+
],
|
|
122
|
+
},
|
|
200
123
|
resolve: {
|
|
201
|
-
|
|
124
|
+
...config.ssr?.resolve,
|
|
125
|
+
externalConditions: config.ssr?.resolve?.externalConditions ?? [
|
|
126
|
+
"react-server",
|
|
127
|
+
],
|
|
202
128
|
},
|
|
203
129
|
},
|
|
204
130
|
// client build options
|
|
205
131
|
build: {
|
|
206
132
|
...config.build,
|
|
207
133
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
208
|
-
outDir: join(userOptions.build.outDir, envDir),
|
|
134
|
+
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
209
135
|
assetsDir: config.build?.assetsDir ?? userOptions.build.assetsDir,
|
|
210
136
|
copyPublicDir: config.build?.copyPublicDir ?? true,
|
|
211
137
|
// modern browsers
|
|
212
|
-
target: ["esnext"],
|
|
213
|
-
minify:
|
|
214
|
-
ssr: ssr,
|
|
215
|
-
manifest: config.build?.manifest ?? `.vite/manifest.json`,
|
|
216
|
-
ssrManifest: config.build?.ssrManifest ?? `.vite/ssr-manifest.json`,
|
|
217
|
-
ssrEmitAssets: config.build?.ssrEmitAssets ?? true,
|
|
138
|
+
target: config.build?.target ?? ["esnext"],
|
|
139
|
+
minify: minify,
|
|
218
140
|
rollupOptions: {
|
|
219
141
|
...config.build?.rollupOptions,
|
|
220
|
-
input: inputs,
|
|
142
|
+
input: autoDiscoveredFiles.inputs,
|
|
221
143
|
output: newOutput,
|
|
222
|
-
preserveEntrySignatures:
|
|
144
|
+
preserveEntrySignatures:
|
|
145
|
+
config.build?.rollupOptions?.preserveEntrySignatures ??
|
|
146
|
+
"exports-only",
|
|
223
147
|
},
|
|
148
|
+
ssr: ssr,
|
|
149
|
+
manifest: config.build?.manifest ?? `.vite/manifest.json`,
|
|
150
|
+
ssrManifest: config.build?.ssrManifest ?? `.vite/ssr-manifest.json`,
|
|
151
|
+
ssrEmitAssets: config.build?.ssrEmitAssets ?? true,
|
|
152
|
+
cssCodeSplit:
|
|
153
|
+
typeof config.build?.cssCodeSplit === "boolean"
|
|
154
|
+
? config.build?.cssCodeSplit
|
|
155
|
+
: true,
|
|
224
156
|
},
|
|
225
157
|
};
|
|
226
158
|
} else {
|
|
227
|
-
// server build options
|
|
228
|
-
if (configEnv.isSsrBuild === false) {
|
|
229
|
-
configEnv.isSsrBuild = true;
|
|
230
|
-
}
|
|
231
159
|
stashedUserConfig[envId] = {
|
|
232
160
|
...config,
|
|
233
161
|
root: root,
|
|
234
|
-
mode:
|
|
235
|
-
configEnv.mode ?? configEnv.command === "build"
|
|
236
|
-
? "production"
|
|
237
|
-
: "development",
|
|
162
|
+
mode: mode,
|
|
238
163
|
resolve: {
|
|
239
|
-
|
|
164
|
+
...config.resolve,
|
|
165
|
+
externalConditions: config.resolve?.externalConditions ?? [
|
|
166
|
+
"react-server",
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
ssr: {
|
|
170
|
+
...config.ssr,
|
|
171
|
+
target: config.ssr?.target ?? "node",
|
|
172
|
+
resolve: {
|
|
173
|
+
...config.ssr?.resolve,
|
|
174
|
+
externalConditions: config.ssr?.resolve?.externalConditions ?? [
|
|
175
|
+
"react-server",
|
|
176
|
+
],
|
|
177
|
+
},
|
|
240
178
|
},
|
|
241
179
|
// server build options
|
|
242
180
|
build: {
|
|
243
181
|
...config.build,
|
|
244
182
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
245
|
-
outDir: join(userOptions.build.outDir, envDir),
|
|
183
|
+
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
246
184
|
target: config.build?.target ?? "node18",
|
|
247
|
-
minify:
|
|
185
|
+
minify: minify,
|
|
248
186
|
ssr: ssr,
|
|
249
187
|
manifest: config.build?.manifest ?? `.vite/manifest.json`,
|
|
250
188
|
ssrManifest: config.build?.ssrManifest ?? `.vite/ssr-manifest.json`,
|
|
251
|
-
ssrEmitAssets:
|
|
252
|
-
|
|
189
|
+
ssrEmitAssets:
|
|
190
|
+
typeof config.build?.ssrEmitAssets === "boolean"
|
|
191
|
+
? config.build?.ssrEmitAssets
|
|
192
|
+
: true,
|
|
193
|
+
copyPublicDir:
|
|
194
|
+
typeof config.build?.copyPublicDir === "boolean"
|
|
195
|
+
? config.build?.copyPublicDir
|
|
196
|
+
: true,
|
|
253
197
|
assetsDir: config.build?.assetsDir ?? userOptions.build.assetsDir,
|
|
198
|
+
// Ensure CSS files are output to static directory
|
|
199
|
+
cssCodeSplit:
|
|
200
|
+
typeof config.build?.cssCodeSplit === "boolean"
|
|
201
|
+
? config.build?.cssCodeSplit
|
|
202
|
+
: true,
|
|
254
203
|
rollupOptions: {
|
|
255
204
|
...config.build?.rollupOptions,
|
|
256
|
-
input: inputs,
|
|
205
|
+
input: autoDiscoveredFiles.inputs,
|
|
257
206
|
preserveEntrySignatures:
|
|
258
207
|
config.build?.rollupOptions?.preserveEntrySignatures ?? "strict",
|
|
259
208
|
output: newOutput,
|
|
@@ -267,6 +216,7 @@ export function resolveUserConfig({
|
|
|
267
216
|
error: new Error("Failed to resolve config"),
|
|
268
217
|
};
|
|
269
218
|
}
|
|
219
|
+
|
|
270
220
|
return {
|
|
271
221
|
type: "success",
|
|
272
222
|
userConfig: stashedUserConfig[envId],
|
package/plugin/copy.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { copyFile, mkdir, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export async function copy({
|
|
5
|
+
src,
|
|
6
|
+
dest,
|
|
7
|
+
exclude,
|
|
8
|
+
include,
|
|
9
|
+
}: {
|
|
10
|
+
src: string;
|
|
11
|
+
dest: string;
|
|
12
|
+
exclude: ((src: string) => boolean)[];
|
|
13
|
+
include?: ((src: string) => boolean)[];
|
|
14
|
+
}) {
|
|
15
|
+
// handle file case first
|
|
16
|
+
const stats = await stat(src);
|
|
17
|
+
if (stats.isFile()) {
|
|
18
|
+
// handle exclusions
|
|
19
|
+
if (exclude && exclude.some((f) => f(src))) {
|
|
20
|
+
return;
|
|
21
|
+
} else if (!include || include.some((f) => f(src))) {
|
|
22
|
+
const dir = dirname(dest);
|
|
23
|
+
// wait 'till last moment to prevent empty directories
|
|
24
|
+
await mkdir(dir, { recursive: true });
|
|
25
|
+
await copyFile(src, dest);
|
|
26
|
+
}
|
|
27
|
+
} else if (stats.isDirectory()) {
|
|
28
|
+
const entries = await readdir(src);
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
let newSrc = join(src, entry);
|
|
31
|
+
copy({
|
|
32
|
+
src: newSrc,
|
|
33
|
+
dest: join(dest, entry),
|
|
34
|
+
exclude: exclude,
|
|
35
|
+
include: include,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CssCollectorProps, CssContent } from "./types.js";
|
|
3
|
+
|
|
4
|
+
// Create link elements for each CSS file
|
|
5
|
+
export const CssCollectorElements = ({
|
|
6
|
+
cssFiles,
|
|
7
|
+
}: Pick<
|
|
8
|
+
CssCollectorProps,
|
|
9
|
+
"cssFiles"
|
|
10
|
+
>) =>
|
|
11
|
+
Array.from(cssFiles?.values() ?? []).map((cssFile: CssContent) => {
|
|
12
|
+
// Emit style tag for inline CSS
|
|
13
|
+
const { as: As, id, children, precedence, type, ...rest } = cssFile;
|
|
14
|
+
if(As !== "link" && (typeof children === "string" || React.isValidElement(children))) {
|
|
15
|
+
// style tag
|
|
16
|
+
// since we can't bubble up the style tags, we need to be creative
|
|
17
|
+
return <As {...rest} type={type ?? "text/css"} key={cssFile.id}>{children}</As>;
|
|
18
|
+
}
|
|
19
|
+
// link tag
|
|
20
|
+
return <As {...rest} key={cssFile.id} precedence={precedence} />;
|
|
21
|
+
});
|
package/plugin/css-collector.tsx
CHANGED
|
@@ -1,62 +1,29 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { CssCollectorProps } from "./types.js";
|
|
3
|
+
import { CssCollectorElements } from "./css-collector-elements.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A component that emits <link> tags for CSS files during streaming.
|
|
6
7
|
* The high precedence ensures they bubble up to the document head.
|
|
7
8
|
*/
|
|
8
9
|
export function CssCollector({
|
|
9
|
-
children,
|
|
10
|
-
cssFiles,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
// Handle string paths
|
|
30
|
-
if (typeof file === "string" && file.endsWith('.css')) {
|
|
31
|
-
// Handle different types of paths
|
|
32
|
-
let url = file;
|
|
33
|
-
if (file.startsWith('http') || file.startsWith('data:')) {
|
|
34
|
-
// Keep absolute URLs as is
|
|
35
|
-
url = file;
|
|
36
|
-
} else if (file.startsWith('/')) {
|
|
37
|
-
// Convert absolute paths to relative
|
|
38
|
-
url = base + file.slice(1);
|
|
39
|
-
} else if (!file.startsWith('./') && !file.startsWith('../')) {
|
|
40
|
-
// Add prefix to relative paths that don't start with ./ or ../
|
|
41
|
-
url = join(base, file);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return React.createElement("link", {
|
|
45
|
-
key: file,
|
|
46
|
-
rel: "stylesheet",
|
|
47
|
-
href: url,
|
|
48
|
-
precedence: "high",
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return null;
|
|
53
|
-
}).filter(Boolean);
|
|
54
|
-
|
|
55
|
-
return React.createElement(
|
|
56
|
-
React.Fragment,
|
|
57
|
-
null,
|
|
58
|
-
...elements,
|
|
59
|
-
children
|
|
10
|
+
children = null,
|
|
11
|
+
cssFiles = new Map(),
|
|
12
|
+
as: As = React.Fragment,
|
|
13
|
+
...props
|
|
14
|
+
}: Pick<CssCollectorProps, "children" | "cssFiles" | "as">) {
|
|
15
|
+
if (As === React.Fragment) {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{children}
|
|
19
|
+
<CssCollectorElements cssFiles={cssFiles} />
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<As {...props}>
|
|
25
|
+
{children}
|
|
26
|
+
<CssCollectorElements cssFiles={cssFiles} />
|
|
27
|
+
</As>
|
|
60
28
|
);
|
|
61
29
|
}
|
|
62
|
-
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SerializableRecord } from "../types.js";
|
|
2
|
+
|
|
3
|
+
// Helper function to serialize RegExp objects
|
|
4
|
+
function serializeRegExp(regex: RegExp): { source: string; flags: string; __isRegExp: boolean } {
|
|
5
|
+
return {
|
|
6
|
+
source: regex.source,
|
|
7
|
+
flags: regex.flags,
|
|
8
|
+
__isRegExp: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function cleanObject<T>(obj: T, knownNonSerializableFunctions: Set<string> = new Set(), currentPath: string = ''): SerializableRecord & T {
|
|
13
|
+
if (obj === null || obj === undefined) return obj as Extract<SerializableRecord, T>;
|
|
14
|
+
if (typeof obj !== 'object') return obj as Extract<SerializableRecord, T>;
|
|
15
|
+
if (obj instanceof RegExp) return serializeRegExp(obj) as unknown as Extract<SerializableRecord, T>;
|
|
16
|
+
if (Array.isArray(obj)) {
|
|
17
|
+
return obj.map((x, i) => cleanObject(x, knownNonSerializableFunctions, `${currentPath}[${i}]`)).filter(x => x !== undefined) as Extract<SerializableRecord, T>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const result: Record<string, any> = {};
|
|
21
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
22
|
+
const fullPath = currentPath ? `${currentPath}.${key}` : key;
|
|
23
|
+
const normalizedPath = fullPath.replace(/\[\d+\]/g, '[]');
|
|
24
|
+
// Skip if it's a function or known non-serializable property
|
|
25
|
+
if (typeof value === 'function' || knownNonSerializableFunctions.has(normalizedPath) || knownNonSerializableFunctions.has(key)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Handle nested objects
|
|
30
|
+
if (typeof value === 'object' && value !== null) {
|
|
31
|
+
// Check if the object has any functions
|
|
32
|
+
const hasFunctions = Object.entries(value).some(([k, v]) => {
|
|
33
|
+
const nestedPath = `${normalizedPath}.${k}`;
|
|
34
|
+
return typeof v === 'function' || knownNonSerializableFunctions.has(nestedPath);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (hasFunctions) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const cleaned = cleanObject(value, knownNonSerializableFunctions, `${normalizedPath}.${key}`);
|
|
42
|
+
if (cleaned !== undefined && Object.keys(cleaned).length > 0) {
|
|
43
|
+
result[key] = cleaned;
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
result[key] = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return (Object.keys(result).length > 0 ? result : {}) as Extract<SerializableRecord, T>;
|
|
50
|
+
}
|