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
|
@@ -3,101 +3,126 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
async function resolveProps({
|
|
10
|
-
propsModule,
|
|
11
|
-
path,
|
|
6
|
+
const resolveProps = async ({
|
|
7
|
+
id,
|
|
8
|
+
url,
|
|
12
9
|
exportName,
|
|
13
|
-
|
|
14
|
-
}) {
|
|
15
|
-
|
|
10
|
+
loader
|
|
11
|
+
}) => {
|
|
12
|
+
const propsLoadResult = await (async () => {
|
|
13
|
+
try {
|
|
14
|
+
return {
|
|
15
|
+
type: "success",
|
|
16
|
+
key: id,
|
|
17
|
+
module: await loader(id)
|
|
18
|
+
};
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
type: "error",
|
|
22
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
})();
|
|
26
|
+
if (propsLoadResult.type !== "success") {
|
|
27
|
+
return propsLoadResult;
|
|
28
|
+
}
|
|
29
|
+
const { module } = propsLoadResult;
|
|
30
|
+
const props = module[exportName];
|
|
31
|
+
if (module instanceof Error) {
|
|
16
32
|
return {
|
|
17
33
|
type: "error",
|
|
18
|
-
error:
|
|
34
|
+
error: module
|
|
19
35
|
};
|
|
20
|
-
}
|
|
21
|
-
|
|
36
|
+
} else if (!(exportName in module)) {
|
|
37
|
+
return {
|
|
38
|
+
type: "success",
|
|
39
|
+
key: exportName,
|
|
40
|
+
props: { url, ...module },
|
|
41
|
+
module
|
|
42
|
+
};
|
|
43
|
+
} else if (!props) {
|
|
44
|
+
return {
|
|
45
|
+
type: "success",
|
|
46
|
+
key: exportName,
|
|
47
|
+
props: { url },
|
|
48
|
+
module
|
|
49
|
+
};
|
|
50
|
+
} else if (props instanceof Error) {
|
|
22
51
|
return {
|
|
23
52
|
type: "error",
|
|
24
|
-
error:
|
|
25
|
-
`propsModule must be an object, got ${typeof propsModule}`
|
|
26
|
-
)
|
|
53
|
+
error: props
|
|
27
54
|
};
|
|
28
|
-
}
|
|
29
|
-
const keys = Object.keys(propsModule);
|
|
30
|
-
let found = keys.find((v) => v === exportName || v === url || v === path);
|
|
31
|
-
if (exportName in propsModule) {
|
|
32
|
-
found = exportName;
|
|
33
|
-
}
|
|
34
|
-
if (found) {
|
|
35
|
-
let value = propsModule[found];
|
|
55
|
+
} else if (typeof props === "function") {
|
|
36
56
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
props
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (value && typeof value.then === "function") {
|
|
46
|
-
const props = await value;
|
|
47
|
-
return {
|
|
48
|
-
type: "success",
|
|
49
|
-
key: found,
|
|
50
|
-
props
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (typeof value === "object" && value !== null) {
|
|
54
|
-
return {
|
|
55
|
-
type: "success",
|
|
56
|
-
key: found,
|
|
57
|
-
props: value
|
|
58
|
-
};
|
|
57
|
+
let propsResult;
|
|
58
|
+
if (props.prototype && props.prototype.constructor) {
|
|
59
|
+
propsResult = new props(url);
|
|
60
|
+
} else {
|
|
61
|
+
propsResult = props(url);
|
|
59
62
|
}
|
|
63
|
+
return {
|
|
64
|
+
type: "success",
|
|
65
|
+
key: exportName,
|
|
66
|
+
props: propsResult instanceof Promise ? await propsResult : propsResult,
|
|
67
|
+
module
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
60
70
|
return {
|
|
61
71
|
type: "error",
|
|
62
|
-
error: new Error(
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
} else if (props instanceof Promise) {
|
|
76
|
+
try {
|
|
77
|
+
return {
|
|
78
|
+
type: "success",
|
|
79
|
+
key: exportName,
|
|
80
|
+
props: await props,
|
|
81
|
+
module: propsLoadResult.module
|
|
65
82
|
};
|
|
66
83
|
} catch (error) {
|
|
67
|
-
console.trace(error);
|
|
68
|
-
console.warn(found, "error in resolveProps", propsModule, url, path);
|
|
69
84
|
return {
|
|
70
85
|
type: "error",
|
|
71
|
-
error
|
|
86
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
} else if (Array.isArray(props)) {
|
|
90
|
+
try {
|
|
91
|
+
return {
|
|
92
|
+
type: "success",
|
|
93
|
+
key: exportName,
|
|
94
|
+
props: Object.fromEntries(
|
|
95
|
+
props.map((prop) => typeof prop === "string" ? [prop, prop] : prop)
|
|
96
|
+
),
|
|
97
|
+
module: propsLoadResult.module
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return {
|
|
101
|
+
type: "error",
|
|
102
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
} else if (typeof props === "string") {
|
|
106
|
+
try {
|
|
107
|
+
return {
|
|
108
|
+
type: "success",
|
|
109
|
+
key: exportName,
|
|
110
|
+
props: JSON.parse(props)
|
|
111
|
+
};
|
|
112
|
+
} catch (error) {
|
|
113
|
+
return {
|
|
114
|
+
type: "error",
|
|
115
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
72
116
|
};
|
|
73
117
|
}
|
|
74
|
-
}
|
|
75
|
-
const commonjs = keys.find((v) => v === "exports");
|
|
76
|
-
if (!!commonjs) {
|
|
77
|
-
const exportKeys = commonjs["exports"] ? Object.keys(commonjs["exports"]) : [];
|
|
78
|
-
const foundCommonJS = exportKeys.find(
|
|
79
|
-
(v) => v === exportName || v === url || v === path
|
|
80
|
-
);
|
|
81
|
-
return {
|
|
82
|
-
type: "error",
|
|
83
|
-
error: new Error(
|
|
84
|
-
`Expected props export "${exportName}" in "${path}", but instead got "exports" with ${!!foundCommonJS ? foundCommonJS.toString() : exportKeys.length ? exportKeys.join(", ") : "no keys"}, this will not work. Make sure to set esModule: true in rollupOptions.output. ${JSON.stringify(propsModule)}`
|
|
85
|
-
)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (Object.keys(propsModule).includes("error")) {
|
|
89
|
-
return {
|
|
90
|
-
type: "error",
|
|
91
|
-
error: propsModule["error"]
|
|
92
|
-
};
|
|
93
118
|
}
|
|
94
119
|
return {
|
|
95
|
-
type: "
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
type: "success",
|
|
121
|
+
key: exportName,
|
|
122
|
+
props,
|
|
123
|
+
module
|
|
99
124
|
};
|
|
100
|
-
}
|
|
125
|
+
};
|
|
101
126
|
|
|
102
127
|
export { resolveProps };
|
|
103
128
|
//# sourceMappingURL=resolveProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveProps.js","sources":["../../plugin/resolveProps.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"resolveProps.js","sources":["../../plugin/resolveProps.ts"],"sourcesContent":["\ntype ResolvePropsOptions<N extends string> = {\n id: string;\n url: string;\n exportName: N;\n loader: (id: string) => Promise<any>;\n};\n\ntype ResolvePropsResult<T, N extends string> =\n | { type: \"success\"; key: string; props: T; module?: { [key in N]: T } }\n | { type: \"error\"; error: Error }\n | { type: \"skip\" };\n\n/**\n * Resolves props from a module, handling both real and virtual modules.\n *\n * During development (ssrLoadModule):\n * - Real modules have exports available directly on the module object\n * - Virtual modules have exports stored in temporaryReferences\n *\n * During build (createBuildLoader):\n * - Transformed modules (with ast/code) have exports as direct properties\n * - The exports array contains just the names of those exports\n * - We store the module in temporaryReferences for later use\n * - We access exports directly from the module object\n *\n * Props can be:\n * 1. A function that takes a URL and returns props\n * 2. A direct object of props\n * 3. A renamed export (where the actual export name differs from the expected name)\n *\n * @param options.propsModule - The module object from ssrLoadModule or createBuildLoader\n * @param options.path - The normalized path to the module\n * @param options.url - The URL route this page handles\n * @param options.exportName - The name of the export to resolve (e.g. 'props')\n * @param options.temporaryReferences - WeakMap used to store and retrieve virtual module references\n *\n * @returns A result object containing:\n * - type: \"success\" | \"error\" | \"skip\"\n * - key: The export name if successful\n * - props: The resolved props if successful\n * - error: Error message if failed\n */\nexport const resolveProps = async <T, N extends string>({\n id,\n url,\n exportName,\n loader,\n}: ResolvePropsOptions<N>): Promise<ResolvePropsResult<T, N>> => {\n // Check if this is a stashed page that needs special handling\n const propsLoadResult = await (async (): Promise<\n | { type: \"success\"; key: string; module: { [key in N]: T } }\n | { type: \"error\"; error: Error; module?: never }\n > => {\n try {\n return {\n type: \"success\",\n key: id,\n module: await loader(id),\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n })();\n\n if (propsLoadResult.type !== \"success\") {\n return propsLoadResult;\n }\n const { module } = propsLoadResult;\n const props = module[exportName as N];\n // handle different props use-cases\n if (module instanceof Error) {\n return {\n type: \"error\",\n error: module,\n };\n } else if (!(exportName in module)) {\n return {\n type: \"success\",\n key: exportName,\n props: { url, ...module } as T,\n module,\n };\n } else if (!props) {\n return {\n type: \"success\",\n key: exportName,\n props: { url } as T,\n module: module as { [key in N]: T },\n };\n } else if (props instanceof Error) {\n return {\n type: \"error\",\n error: props,\n };\n } else if (typeof props === \"function\") {\n // Handle both class constructors and regular functions\n try {\n let propsResult;\n if (props.prototype && props.prototype.constructor) {\n // Class constructor case\n propsResult = new (props as new (url: string) => T)(url);\n } else {\n // Regular function case\n propsResult = props(url);\n }\n \n return {\n type: \"success\",\n key: exportName,\n props: propsResult instanceof Promise ? await propsResult : propsResult,\n module: module as { [key in N]: T },\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n } else if (props instanceof Promise) {\n // object case\n try {\n return {\n type: \"success\",\n key: exportName,\n props: await props,\n module: propsLoadResult.module,\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n } else if (Array.isArray(props)) {\n // array case\n try {\n return {\n type: \"success\",\n key: exportName,\n props: Object.fromEntries(\n props.map((prop) => (typeof prop === \"string\" ? [prop, prop] : prop))\n ) as T,\n module: propsLoadResult.module,\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n } else if (typeof props === \"string\") {\n try {\n return {\n type: \"success\",\n key: exportName,\n props: JSON.parse(props),\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n }\n return {\n type: \"success\",\n key: exportName,\n props: props,\n module: module as { [key in N]: T },\n };\n};\n"],"names":[],"mappings":"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"}
|
package/dist/plugin/root.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../plugin/root.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../plugin/root.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA0C,CAAC;AAClE,eAAO,MAAM,QAAQ,SAA6C,CAAC"}
|
package/dist/plugin/root.js
CHANGED
package/dist/plugin/root.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sources":["../../plugin/root.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nexport const pluginRoot = dirname(fileURLToPath(import.meta.url));\n
|
|
1
|
+
{"version":3,"file":"root.js","sources":["../../plugin/root.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nexport const pluginRoot = dirname(fileURLToPath(import.meta.url));\nexport const isLinked = !import.meta.url.startsWith(process.cwd());\n"],"names":[],"mappings":";;;;;;;;AAEO,MAAM,UAAa,GAAA,OAAA,CAAQ,aAAc,CAAA,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC;AACxC,CAAC,MAAA,CAAA,IAAA,CAAY,IAAI,UAAW,CAAA,OAAA,CAAQ,KAAK;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { reactTransformPlugin } from "./plugin.js";
|
|
1
|
+
export { reactTransformPlugin as reactTransformPluginServer } from "./plugin.server.js";
|
|
2
|
+
export { reactTransformPlugin as reactTransformPluginClient } from "./plugin.client.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AA+BlD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA2EzE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { resolveOptions } from '../config/resolveOptions.js';
|
|
7
|
+
import 'vite';
|
|
8
|
+
import { transformModuleIfNeeded } from '../loader/react-loader.js';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { tryManifest } from '../helpers/tryManifest.js';
|
|
11
|
+
|
|
12
|
+
let isBuild = true;
|
|
13
|
+
function reactTransformPlugin(options) {
|
|
14
|
+
let userOptions;
|
|
15
|
+
const resolvedOptionsResult = resolveOptions(options);
|
|
16
|
+
if (resolvedOptionsResult.type === "error") throw resolvedOptionsResult.error;
|
|
17
|
+
userOptions = resolvedOptionsResult.userOptions;
|
|
18
|
+
let staticManifest;
|
|
19
|
+
return {
|
|
20
|
+
name: "vite:react-server-action-transform",
|
|
21
|
+
enforce: "pre",
|
|
22
|
+
async config(_, configEnv) {
|
|
23
|
+
isBuild = configEnv.command !== "serve";
|
|
24
|
+
if (!configEnv.isSsrBuild) {
|
|
25
|
+
staticManifest = {};
|
|
26
|
+
} else {
|
|
27
|
+
const staticManifestResult = await tryManifest({
|
|
28
|
+
root: userOptions.projectRoot,
|
|
29
|
+
ssrManifest: false,
|
|
30
|
+
outDir: join(userOptions.build.outDir, userOptions.build.static)
|
|
31
|
+
});
|
|
32
|
+
if (staticManifestResult.type === "error") {
|
|
33
|
+
staticManifest = {};
|
|
34
|
+
} else {
|
|
35
|
+
staticManifest = staticManifestResult.manifest;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async transform(code, id, options2) {
|
|
40
|
+
const ssr = options2?.ssr;
|
|
41
|
+
const isServer = code.match('"use server"') !== null;
|
|
42
|
+
const isClient = code.match('"use client"') !== null;
|
|
43
|
+
if (!ssr) return null;
|
|
44
|
+
if (!isServer && !isClient) return null;
|
|
45
|
+
if (isServer && isClient) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Server and client components cannot be used in the same file"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (isClient) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (isServer && isBuild) {
|
|
54
|
+
const [key] = userOptions.normalizer(id);
|
|
55
|
+
id = "/" + key + ".js";
|
|
56
|
+
}
|
|
57
|
+
const transformed = await transformModuleIfNeeded(code, id, null);
|
|
58
|
+
if (!transformed) return null;
|
|
59
|
+
return {
|
|
60
|
+
code: transformed,
|
|
61
|
+
id,
|
|
62
|
+
map: null
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
renderChunk(code, chunk, _options) {
|
|
66
|
+
if (!chunk.fileName.includes(".client")) return null;
|
|
67
|
+
const originalName = chunk.fileName.replace(".js", "");
|
|
68
|
+
const manifestEntry = Object.entries(staticManifest).find(
|
|
69
|
+
([_, info]) => info.file.startsWith(originalName)
|
|
70
|
+
);
|
|
71
|
+
if (manifestEntry) {
|
|
72
|
+
return {
|
|
73
|
+
code,
|
|
74
|
+
fileName: manifestEntry[1].file
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { reactTransformPlugin };
|
|
83
|
+
//# sourceMappingURL=plugin.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.client.js","sources":["../../../plugin/transformer/plugin.client.ts"],"sourcesContent":["import { resolveOptions } from \"../config/resolveOptions.js\";\nimport type { ResolvedUserOptions, StreamPluginOptions } from \"../types.js\";\nimport { type Manifest, type Plugin } from \"vite\";\nimport { transformModuleIfNeeded } from \"../loader/react-loader.js\";\nimport { join } from \"node:path\";\nimport { tryManifest } from \"../helpers/tryManifest.js\";\n\n/**\n * Plugin for transforming server actions for the client build.\n *\n * Core responsibilities:\n * 1. Transforms \"use server\" directives\n * 2. Transforms server actions for the client build\n * 3. Uses react-loader's transformModuleIfNeeded to create a server action reference\n *\n * When a component is marked with \"use server\", it:\n * - Gets transformed into a server action\n * - Maintains module ID for RSC boundaries\n * - Preserves class/function behavior\n *\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [\n * viteReactClientTransformPlugin({\n * projectRoot: process.cwd(),\n * })\n * ]\n * });\n * ```\n */\nlet isBuild = true;\n\nexport function reactTransformPlugin(options: StreamPluginOptions): Plugin {\n let userOptions: ResolvedUserOptions;\n const resolvedOptionsResult = resolveOptions(options);\n if (resolvedOptionsResult.type === \"error\") throw resolvedOptionsResult.error;\n userOptions = resolvedOptionsResult.userOptions;\n let staticManifest: Manifest;\n return {\n name: \"vite:react-server-action-transform\",\n enforce: \"pre\",\n async config(_, configEnv) {\n isBuild = configEnv.command !== \"serve\";\n if (!configEnv.isSsrBuild) {\n staticManifest = {};\n } else {\n const staticManifestResult = await tryManifest({\n root: userOptions.projectRoot,\n ssrManifest: false,\n outDir: join(userOptions.build.outDir, userOptions.build.static),\n });\n if (staticManifestResult.type === \"error\") {\n staticManifest = {};\n } else {\n staticManifest = staticManifestResult.manifest;\n }\n }\n },\n async transform(code, id, options) {\n const ssr = options?.ssr;\n const isServer = code.match('\"use server\"') !== null;\n const isClient = code.match('\"use client\"') !== null;\n if (!ssr) return null;\n if (!isServer && !isClient) return null;\n if (isServer && isClient) {\n throw new Error(\n \"Server and client components cannot be used in the same file\"\n );\n }\n if (isClient) {\n return null;\n }\n if (isServer && isBuild) {\n const [key] = userOptions.normalizer(id);\n id = \"/\" + key + \".js\";\n }\n const transformed = await transformModuleIfNeeded(code, id, null);\n if (!transformed) return null;\n return {\n code: transformed,\n id: id,\n map: null,\n };\n },\n renderChunk(code, chunk, _options) {\n // Only process client components\n if (!chunk.fileName.includes(\".client\")) return null;\n\n // Get the original file name without extension\n const originalName = chunk.fileName.replace(\".js\", \"\");\n\n // Find matching entry in static manifest\n const manifestEntry = Object.entries(staticManifest).find(([_, info]) =>\n info.file.startsWith(originalName)\n );\n\n if (manifestEntry) {\n // Use the static manifest's file name\n return {\n code,\n fileName: manifestEntry[1].file,\n };\n }\n\n return null;\n },\n };\n}\n"],"names":["options"],"mappings":"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"}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { type Plugin } from "vite";
|
|
3
|
-
/**
|
|
4
|
-
* Plugin for transforming React Client Components.
|
|
5
|
-
*
|
|
6
|
-
* Core responsibilities:
|
|
7
|
-
* 1. Detects "use client" directives
|
|
8
|
-
* 2. Transforms client components for RSC boundaries
|
|
9
|
-
* 3. Adds client reference metadata for RSC
|
|
10
|
-
*
|
|
11
|
-
* When a component is marked with "use client", it:
|
|
12
|
-
* - Gets transformed into a client reference
|
|
13
|
-
* - Maintains module ID for RSC boundaries
|
|
14
|
-
* - Preserves class/function behavior
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* export default defineConfig({
|
|
19
|
-
* plugins: [
|
|
20
|
-
* viteReactClientTransformPlugin({
|
|
21
|
-
* projectRoot: process.cwd(),
|
|
22
|
-
* })
|
|
23
|
-
* ]
|
|
24
|
-
* });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function reactTransformPlugin(options: StreamPluginOptions): Plugin;
|
|
1
|
+
export declare const reactTransformPlugin: any;
|
|
28
2
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.ts"],"names":[],"mappings":"AAEA,eAAO,MAAQ,oBAAoB,KAAoD,CAAC"}
|
|
@@ -3,94 +3,10 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
7
|
-
import '
|
|
8
|
-
import { transformModuleIfNeeded } from '../loader/react-loader.js';
|
|
9
|
-
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
10
|
-
import { createInputNormalizer } from '../helpers/inputNormalizer.js';
|
|
11
|
-
import { tryManifest } from '../helpers/tryManifest.js';
|
|
12
|
-
import { join } from 'node:path';
|
|
6
|
+
import __variableDynamicImportRuntimeHelper from '../../_virtual/dynamic-import-helper.js';
|
|
7
|
+
import { getCondition } from '../config/getCondition.js';
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
let normalizer;
|
|
16
|
-
let clientManifest;
|
|
17
|
-
let isDev;
|
|
18
|
-
let userOptions;
|
|
19
|
-
return {
|
|
20
|
-
name: "vite:react-transform",
|
|
21
|
-
enforce: "pre",
|
|
22
|
-
// Run before Vite's transforms
|
|
23
|
-
config(config, configEnv) {
|
|
24
|
-
const resolvedOptionsResult = resolveOptions(
|
|
25
|
-
options,
|
|
26
|
-
config.build?.outDir?.startsWith(
|
|
27
|
-
join(options.build?.outDir ?? DEFAULT_CONFIG.BUILD.outDir, options.build?.client ?? DEFAULT_CONFIG.BUILD.client)
|
|
28
|
-
) ?? false
|
|
29
|
-
);
|
|
30
|
-
isDev = configEnv.mode === "development" && configEnv.command === "serve";
|
|
31
|
-
if (resolvedOptionsResult.type === "error") throw resolvedOptionsResult.error;
|
|
32
|
-
userOptions = resolvedOptionsResult.userOptions;
|
|
33
|
-
normalizer = createInputNormalizer({
|
|
34
|
-
root: resolvedOptionsResult.userOptions.projectRoot,
|
|
35
|
-
preserveModulesRoot: undefined,
|
|
36
|
-
removeExtension: false
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
async transform(code, id, options2) {
|
|
40
|
-
const ssr = options2?.ssr ?? false;
|
|
41
|
-
if (!ssr) return null;
|
|
42
|
-
if (!id.match(DEFAULT_CONFIG.FILE_REGEX)) return null;
|
|
43
|
-
if (!code.match('"use client"')) return null;
|
|
44
|
-
const clientManifestResult = tryManifest({
|
|
45
|
-
root: userOptions.projectRoot,
|
|
46
|
-
outDir: join(
|
|
47
|
-
userOptions.build.outDir,
|
|
48
|
-
userOptions.build.client
|
|
49
|
-
),
|
|
50
|
-
ssrManifest: false
|
|
51
|
-
});
|
|
52
|
-
if (clientManifestResult.type === "error") throw clientManifestResult.error;
|
|
53
|
-
clientManifest = clientManifestResult.manifest;
|
|
54
|
-
const [key, value] = normalizer(id);
|
|
55
|
-
const transformed = await transformModuleIfNeeded(
|
|
56
|
-
code,
|
|
57
|
-
id,
|
|
58
|
-
// Pass null for nextLoad since we don't need module loading in the plugin
|
|
59
|
-
null
|
|
60
|
-
);
|
|
61
|
-
if (!transformed) return null;
|
|
62
|
-
if (isDev) {
|
|
63
|
-
return {
|
|
64
|
-
code: transformed,
|
|
65
|
-
map: null
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const moduleIdIndex = transformed.indexOf(value);
|
|
69
|
-
if (moduleIdIndex === -1) {
|
|
70
|
-
console.warn(
|
|
71
|
-
`[vite-plugin-react-server] Could not find module id in transformed code. Ignoring.`,
|
|
72
|
-
{
|
|
73
|
-
code,
|
|
74
|
-
id,
|
|
75
|
-
transformed
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const clientPath = clientManifest[key]?.file;
|
|
81
|
-
if (!clientPath) {
|
|
82
|
-
console.warn(
|
|
83
|
-
`[vite-plugin-react-server] Could not find client path for ${value}. Ignoring.`
|
|
84
|
-
);
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
code: transformed.replace(key, clientPath),
|
|
89
|
-
map: null
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
9
|
+
const { reactTransformPlugin } = await __variableDynamicImportRuntimeHelper((/* #__PURE__ */ Object.assign({})), `./plugin.${getCondition("")}.js`, 2);
|
|
94
10
|
|
|
95
11
|
export { reactTransformPlugin };
|
|
96
12
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["../../../plugin/transformer/plugin.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["../../../plugin/transformer/plugin.ts"],"sourcesContent":["import { getCondition } from '../config/getCondition.js';\n\nexport const { reactTransformPlugin } = await import(`./plugin.${getCondition('')}.js`);"],"names":[],"mappings":";;;;;;;;AAEa,MAAA,EAAE,sBAAyB,GAAA,MAAM,oCAAmC,mCAAA,GAAA,CAAA,SAAA,EAAA,YAAA,CAAA,EAAA,CAAA,CAAA,GAAA,CAAA,EAAA,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,MAAM,CAAC;AA8B7C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAiEzE"}
|