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,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
7
|
-
import { join, dirname } from 'node:path';
|
|
8
|
-
import { Transform } from 'node:stream';
|
|
9
|
-
import { createHandler } from '../../helpers/createHandler.js';
|
|
10
|
-
import { createLogger } from 'vite';
|
|
11
|
-
import React__default from 'react';
|
|
12
|
-
import { collectManifestClientFiles } from '../../collect-manifest-client-files.js';
|
|
13
|
-
|
|
14
|
-
async function renderPages(routes, files, options) {
|
|
15
|
-
const failedRoutes = /* @__PURE__ */ new Map();
|
|
16
|
-
const completedRoutes = /* @__PURE__ */ new Set();
|
|
17
|
-
const clientCss = options.clientCss ?? [];
|
|
18
|
-
const partialPageData = /* @__PURE__ */ new Map();
|
|
19
|
-
const moduleRootPath = options.moduleBasePath !== "" && !options.moduleRootPath.endsWith(options.moduleBasePath) ? join(options.moduleRootPath, options.moduleBasePath) : options.moduleRootPath;
|
|
20
|
-
const mergeAndSendPageData = async (route, resolve) => {
|
|
21
|
-
const partial = partialPageData.get(route);
|
|
22
|
-
if (!partial?.html || !partial.rsc) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const pageData = {
|
|
26
|
-
route,
|
|
27
|
-
html: partial.html,
|
|
28
|
-
rsc: partial.rsc
|
|
29
|
-
};
|
|
30
|
-
let routeHtmlPath = route === "/" ? options.htmlOutputPath : options.htmlOutputPath.replace(
|
|
31
|
-
"index.html",
|
|
32
|
-
join(route, "index.html")
|
|
33
|
-
);
|
|
34
|
-
if (routeHtmlPath.startsWith("/")) {
|
|
35
|
-
routeHtmlPath = routeHtmlPath.slice(1);
|
|
36
|
-
}
|
|
37
|
-
const routeRscPath = routeHtmlPath.slice(0, -5) + ".rsc";
|
|
38
|
-
await mkdir(dirname(routeHtmlPath), { recursive: true });
|
|
39
|
-
await writeFile(routeRscPath, partial.rsc.content);
|
|
40
|
-
await writeFile(routeHtmlPath, partial.html.raw);
|
|
41
|
-
await options.onPage?.(pageData);
|
|
42
|
-
completedRoutes.add(route);
|
|
43
|
-
if (completedRoutes.size === routes.length) {
|
|
44
|
-
resolve();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
const allRoutesComplete = new Promise((resolve, reject) => {
|
|
49
|
-
options.worker.on("message", async (msg) => {
|
|
50
|
-
switch (msg.type) {
|
|
51
|
-
case "ALL_READY": {
|
|
52
|
-
const { id, html } = msg;
|
|
53
|
-
try {
|
|
54
|
-
const partial = partialPageData.get(id) || { route: id };
|
|
55
|
-
partial.html = {
|
|
56
|
-
raw: html,
|
|
57
|
-
transformed: typeof options.transformIndexHtml === "function" ? String(await options.transformIndexHtml(id, {
|
|
58
|
-
path: id,
|
|
59
|
-
filename: join(id, "index.html")
|
|
60
|
-
}) || "") : "",
|
|
61
|
-
// Will be set by main thread transform
|
|
62
|
-
assets: []
|
|
63
|
-
};
|
|
64
|
-
partialPageData.set(id, partial);
|
|
65
|
-
await mergeAndSendPageData(id, resolve);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
failedRoutes.set(id, error);
|
|
68
|
-
reject(error);
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "ERROR": {
|
|
73
|
-
console.error("Worker error for route:", msg.id, msg.error);
|
|
74
|
-
failedRoutes.set(msg.id, new Error(msg.error));
|
|
75
|
-
reject(new Error(msg.error));
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
for (const route of routes) {
|
|
82
|
-
const routeFiles = files.urlMap.get(route);
|
|
83
|
-
if (!routeFiles) {
|
|
84
|
-
console.error("No files found for route:", route);
|
|
85
|
-
failedRoutes.set(route, new Error(`No files found for ${route}`));
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (options.pipableStreamOptions?.importMap?.imports) {
|
|
89
|
-
for (let [, value] of Object.entries(
|
|
90
|
-
options.pipableStreamOptions?.importMap?.imports
|
|
91
|
-
)) {
|
|
92
|
-
options.onClientJSFile?.(value, route);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const getCss = async (id) => {
|
|
96
|
-
const cssFiles = collectManifestClientFiles({
|
|
97
|
-
manifest: options.serverManifest,
|
|
98
|
-
root: options.root,
|
|
99
|
-
pagePath: id
|
|
100
|
-
}).cssFiles;
|
|
101
|
-
return cssFiles;
|
|
102
|
-
};
|
|
103
|
-
const pagePath = files.urlMap.get(route)?.page;
|
|
104
|
-
const propsPath = files.urlMap.get(route)?.props;
|
|
105
|
-
if (!pagePath) {
|
|
106
|
-
throw new Error(`No page path found for ${route}`);
|
|
107
|
-
}
|
|
108
|
-
const rscResult = await createHandler({
|
|
109
|
-
root: options.root,
|
|
110
|
-
url: route,
|
|
111
|
-
route,
|
|
112
|
-
getCss,
|
|
113
|
-
loader: options.loader,
|
|
114
|
-
cssFiles: clientCss,
|
|
115
|
-
moduleBase: options.moduleBase,
|
|
116
|
-
moduleBasePath: options.moduleBasePath,
|
|
117
|
-
moduleRootPath,
|
|
118
|
-
moduleBaseURL: options.moduleBaseURL,
|
|
119
|
-
pipableStreamOptions: options.pipableStreamOptions ?? {},
|
|
120
|
-
inlineCss: options.inlineCss,
|
|
121
|
-
Html: React__default.Fragment,
|
|
122
|
-
CssCollector: options.CssCollector,
|
|
123
|
-
pagePath,
|
|
124
|
-
propsPath,
|
|
125
|
-
pageExportName: options.pageExportName,
|
|
126
|
-
propsExportName: options.propsExportName,
|
|
127
|
-
logger: createLogger()
|
|
128
|
-
});
|
|
129
|
-
const htmlResult = await createHandler({
|
|
130
|
-
root: options.root,
|
|
131
|
-
url: route,
|
|
132
|
-
route,
|
|
133
|
-
getCss,
|
|
134
|
-
loader: options.loader,
|
|
135
|
-
cssFiles: clientCss,
|
|
136
|
-
moduleBase: options.moduleBase,
|
|
137
|
-
moduleBasePath: options.moduleBasePath,
|
|
138
|
-
moduleRootPath,
|
|
139
|
-
moduleBaseURL: options.moduleBaseURL,
|
|
140
|
-
pipableStreamOptions: options.pipableStreamOptions,
|
|
141
|
-
inlineCss: options.inlineCss,
|
|
142
|
-
Html: options.Html,
|
|
143
|
-
CssCollector: options.CssCollector,
|
|
144
|
-
pagePath,
|
|
145
|
-
propsPath,
|
|
146
|
-
pageExportName: options.pageExportName,
|
|
147
|
-
propsExportName: options.propsExportName,
|
|
148
|
-
logger: createLogger()
|
|
149
|
-
});
|
|
150
|
-
if (rscResult.type !== "success" || htmlResult.type !== "success") {
|
|
151
|
-
if (rscResult.type !== "success") {
|
|
152
|
-
if (rscResult.type !== "skip") {
|
|
153
|
-
console.error("Handler failed for route:", route, rscResult.error);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (htmlResult.type !== "success") {
|
|
157
|
-
if (htmlResult.type !== "skip") {
|
|
158
|
-
console.error("Handler failed for route:", route, htmlResult.error);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
failedRoutes.set(route, new Error(`Handler failed for ${route}`));
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
await Promise.all([
|
|
165
|
-
// Handle RSC stream
|
|
166
|
-
new Promise((resolve, reject) => {
|
|
167
|
-
const chunks = [];
|
|
168
|
-
const rscTransform = new Transform({
|
|
169
|
-
transform(chunk, _encoding, callback) {
|
|
170
|
-
try {
|
|
171
|
-
if (chunk) {
|
|
172
|
-
chunks.push(Buffer.from(chunk));
|
|
173
|
-
callback(null, chunk);
|
|
174
|
-
}
|
|
175
|
-
} catch (error) {
|
|
176
|
-
callback(error);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
async flush(callback) {
|
|
180
|
-
try {
|
|
181
|
-
const rscContent = Buffer.concat(chunks).toString("utf-8");
|
|
182
|
-
const partial = partialPageData.get(route) || { route };
|
|
183
|
-
partial.rsc = {
|
|
184
|
-
modules: [],
|
|
185
|
-
// Will be parsed by the client
|
|
186
|
-
content: rscContent
|
|
187
|
-
};
|
|
188
|
-
partialPageData.set(route, partial);
|
|
189
|
-
await mergeAndSendPageData(route, resolve);
|
|
190
|
-
callback();
|
|
191
|
-
resolve();
|
|
192
|
-
} catch (error) {
|
|
193
|
-
callback(error);
|
|
194
|
-
reject(error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
rscResult.stream.pipe(rscTransform);
|
|
199
|
-
}),
|
|
200
|
-
// Send HTML stream to worker
|
|
201
|
-
new Promise((resolve) => {
|
|
202
|
-
const htmlTransform = new Transform({
|
|
203
|
-
transform(chunk, _encoding, callback) {
|
|
204
|
-
try {
|
|
205
|
-
options.worker.postMessage({
|
|
206
|
-
type: "RSC_CHUNK",
|
|
207
|
-
id: route,
|
|
208
|
-
chunk: chunk.toString(),
|
|
209
|
-
moduleRootPath,
|
|
210
|
-
moduleBaseURL: options.moduleBaseURL,
|
|
211
|
-
htmlOutputPath: options.htmlOutputPath,
|
|
212
|
-
pipableStreamOptions: options.pipableStreamOptions
|
|
213
|
-
});
|
|
214
|
-
callback(null, chunk);
|
|
215
|
-
} catch (error) {
|
|
216
|
-
callback(error);
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
flush(callback) {
|
|
220
|
-
options.worker.postMessage({
|
|
221
|
-
type: "RSC_END",
|
|
222
|
-
id: route
|
|
223
|
-
});
|
|
224
|
-
callback();
|
|
225
|
-
resolve();
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
htmlResult.stream.pipe(htmlTransform);
|
|
229
|
-
})
|
|
230
|
-
]);
|
|
231
|
-
}
|
|
232
|
-
await allRoutesComplete;
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error("Render error:", error);
|
|
235
|
-
throw error;
|
|
236
|
-
}
|
|
237
|
-
return { failedRoutes, completedRoutes };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export { renderPages };
|
|
241
|
-
//# sourceMappingURL=renderPages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderPages.js","sources":["../../../../plugin/worker/html/renderPages.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { Transform } from \"node:stream\";\nimport type { Worker } from \"node:worker_threads\";\nimport { createHandler } from \"../../helpers/createHandler.js\";\nimport type {\n CheckFilesExistReturn,\n CreateHandlerOptions,\n PageData,\n} from \"../../types.js\";\nimport type { HtmlWorkerResponse } from \"../types.js\";\nimport { type Manifest, type IndexHtmlTransformHook, createLogger } from \"vite\";\nimport React from \"react\";\nimport { collectManifestClientFiles } from \"../../collect-manifest-client-files.js\";\n\ntype RenderPagesOptions<T = any> = Omit<CreateHandlerOptions<T>, \"url\" | \"route\" | \"getCss\" | \"propsPath\" | \"pagePath\"> & {\n clientManifest: Manifest;\n serverManifest: Manifest;\n worker: Worker;\n loader: (id: string) => Promise<Record<string, any>>;\n onCssFile?: (url: string, parentUrl: string) => void;\n onClientJSFile?: (url: string, parentUrl: string) => void;\n onPage?: (pageData: PageData) => Promise<void>;\n clientCss?: string[];\n transformIndexHtml: IndexHtmlTransformHook;\n outDir: string;\n htmlOutputPath: string;\n server?: any;\n bundle?: any;\n chunk?: any;\n originalUrl?: string;\n};\n\nexport async function renderPages<T = any>(\n routes: string[],\n files: CheckFilesExistReturn,\n options: RenderPagesOptions<T>\n) {\n const failedRoutes = new Map<string, Error>();\n const completedRoutes = new Set<string>();\n const clientCss = options.clientCss ?? [];\n const partialPageData = new Map<string, Partial<PageData>>();\n const moduleRootPath =\n options.moduleBasePath !== \"\" &&\n !options.moduleRootPath.endsWith(options.moduleBasePath)\n ? join(options.moduleRootPath, options.moduleBasePath)\n : options.moduleRootPath;\n const mergeAndSendPageData = async (route: string, resolve: () => void) => {\n const partial = partialPageData.get(route);\n if (!partial?.html || !partial.rsc) {\n return; // Wait for both parts\n }\n\n const pageData: PageData = {\n route,\n html: partial.html,\n rsc: partial.rsc,\n };\n\n // Write HTML file\n let routeHtmlPath =\n route === \"/\"\n ? options.htmlOutputPath\n : options.htmlOutputPath.replace(\n \"index.html\",\n join(route, \"index.html\")\n );\n if (routeHtmlPath.startsWith(\"/\")) {\n routeHtmlPath = routeHtmlPath.slice(1);\n }\n const routeRscPath = routeHtmlPath.slice(0, -5) + \".rsc\";\n await mkdir(dirname(routeHtmlPath), { recursive: true });\n await writeFile(routeRscPath, partial.rsc.content);\n await writeFile(routeHtmlPath, partial.html.raw);\n\n await options.onPage?.(pageData);\n completedRoutes.add(route);\n if (completedRoutes.size === routes.length) {\n resolve();\n }\n };\n\n try {\n // Set up worker message handling\n const allRoutesComplete = new Promise<void>((resolve, reject) => {\n options.worker.on(\"message\", async (msg: HtmlWorkerResponse) => {\n switch (msg.type) {\n case \"ALL_READY\": {\n const { id, html } = msg;\n try {\n const partial = partialPageData.get(id) || { route: id };\n\n partial.html = {\n raw: html,\n transformed:\n typeof options.transformIndexHtml === \"function\"\n ? String(await options.transformIndexHtml(id, {\n path: id,\n filename: join(id, \"index.html\"),\n }) || \"\")\n : \"\", // Will be set by main thread transform\n assets: [],\n };\n partialPageData.set(id, partial);\n await mergeAndSendPageData(id, resolve);\n } catch (error) {\n failedRoutes.set(id, error as Error);\n reject(error);\n }\n break;\n }\n case \"ERROR\": {\n console.error(\"Worker error for route:\", msg.id, msg.error);\n failedRoutes.set(msg.id, new Error(msg.error));\n reject(new Error(msg.error));\n break;\n }\n }\n });\n });\n\n // Process routes sequentially\n for (const route of routes) {\n const routeFiles = files.urlMap.get(route);\n if (!routeFiles) {\n console.error(\"No files found for route:\", route);\n failedRoutes.set(route, new Error(`No files found for ${route}`));\n continue;\n }\n\n if (options.pipableStreamOptions?.importMap?.imports) {\n for (let [, value] of Object.entries(\n options.pipableStreamOptions?.importMap?.imports\n )) {\n options.onClientJSFile?.(value, route);\n }\n }\n const getCss = async (id: string) => {\n const cssFiles = collectManifestClientFiles({\n manifest: options.serverManifest,\n root: options.root,\n pagePath: id,\n }).cssFiles;\n return cssFiles;\n }\n const pagePath = files.urlMap.get(route)?.page;\n const propsPath = files.urlMap.get(route)?.props;\n if(!pagePath){\n throw new Error(`No page path found for ${route}`);\n }\n // Create handler for pure RSC output\n const rscResult = await createHandler({\n root: options.root,\n url: route,\n route: route,\n getCss: getCss,\n loader: options.loader,\n cssFiles: clientCss,\n moduleBase: options.moduleBase,\n moduleBasePath: options.moduleBasePath,\n moduleRootPath: moduleRootPath,\n moduleBaseURL: options.moduleBaseURL,\n pipableStreamOptions: options.pipableStreamOptions ?? {},\n inlineCss: options.inlineCss,\n Html: React.Fragment,\n CssCollector: options.CssCollector,\n pagePath: pagePath,\n propsPath: propsPath,\n pageExportName: options.pageExportName,\n propsExportName: options.propsExportName,\n logger: createLogger(),\n });\n // Create handler for HTML output\n const htmlResult = await createHandler({\n root: options.root,\n url: route,\n route: route,\n getCss: getCss,\n loader: options.loader,\n cssFiles: clientCss,\n moduleBase: options.moduleBase,\n moduleBasePath: options.moduleBasePath,\n moduleRootPath: moduleRootPath,\n moduleBaseURL: options.moduleBaseURL,\n pipableStreamOptions: options.pipableStreamOptions,\n inlineCss: options.inlineCss,\n Html: options.Html,\n CssCollector: options.CssCollector,\n pagePath: pagePath,\n propsPath: propsPath,\n pageExportName: options.pageExportName,\n propsExportName: options.propsExportName,\n logger: createLogger(),\n });\n\n if (rscResult.type !== \"success\" || htmlResult.type !== \"success\") {\n if (rscResult.type !== \"success\") {\n if (rscResult.type !== \"skip\") {\n console.error(\"Handler failed for route:\", route, rscResult.error);\n }\n }\n if (htmlResult.type !== \"success\") {\n if (htmlResult.type !== \"skip\") {\n console.error(\"Handler failed for route:\", route, htmlResult.error);\n }\n }\n failedRoutes.set(route, new Error(`Handler failed for ${route}`));\n continue;\n }\n\n // Process both streams\n await Promise.all([\n // Handle RSC stream\n new Promise<void>((resolve, reject) => {\n const chunks: Buffer[] = [];\n const rscTransform = new Transform({\n transform(chunk, _encoding, callback) {\n try {\n if (chunk) {\n chunks.push(Buffer.from(chunk));\n callback(null, chunk);\n }\n } catch (error) {\n callback(error as Error);\n }\n },\n async flush(callback) {\n try {\n const rscContent = Buffer.concat(chunks).toString(\"utf-8\");\n\n // Update partial page data with raw RSC content\n const partial = partialPageData.get(route) || { route };\n partial.rsc = {\n modules: [], // Will be parsed by the client\n content: rscContent,\n };\n partialPageData.set(route, partial);\n await mergeAndSendPageData(route, resolve);\n\n callback();\n resolve();\n } catch (error) {\n callback(error as Error);\n reject(error);\n }\n },\n });\n\n rscResult.stream.pipe(rscTransform);\n }),\n\n // Send HTML stream to worker\n new Promise<void>((resolve) => {\n const htmlTransform = new Transform({\n transform(chunk, _encoding, callback) {\n try {\n options.worker.postMessage({\n type: \"RSC_CHUNK\",\n id: route,\n chunk: chunk.toString(),\n moduleRootPath: moduleRootPath,\n moduleBaseURL: options.moduleBaseURL,\n htmlOutputPath: options.htmlOutputPath,\n pipableStreamOptions: options.pipableStreamOptions,\n });\n callback(null, chunk);\n } catch (error) {\n callback(error as Error);\n }\n },\n flush(callback) {\n options.worker.postMessage({\n type: \"RSC_END\",\n id: route,\n });\n callback();\n resolve();\n },\n });\n\n htmlResult.stream.pipe(htmlTransform);\n }),\n ]);\n }\n\n await allRoutesComplete;\n } catch (error) {\n console.error(\"Render error:\", error);\n throw error;\n }\n\n return { failedRoutes, completedRoutes };\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;AAiCsB,eAAA,WAAA,CACpB,MACA,EAAA,KAAA,EACA,OACA,EAAA;AACA,EAAM,MAAA,YAAA,uBAAmB,GAAmB,EAAA;AAC5C,EAAM,MAAA,eAAA,uBAAsB,GAAY,EAAA;AACxC,EAAM,MAAA,SAAA,GAAY,OAAQ,CAAA,SAAA,IAAa,EAAC;AACxC,EAAM,MAAA,eAAA,uBAAsB,GAA+B,EAAA;AAC3D,EAAA,MAAM,iBACJ,OAAQ,CAAA,cAAA,KAAmB,EAC3B,IAAA,CAAC,QAAQ,cAAe,CAAA,QAAA,CAAS,OAAQ,CAAA,cAAc,IACnD,IAAK,CAAA,OAAA,CAAQ,gBAAgB,OAAQ,CAAA,cAAc,IACnD,OAAQ,CAAA,cAAA;AACd,EAAM,MAAA,oBAAA,GAAuB,OAAO,KAAA,EAAe,OAAwB,KAAA;AACzE,IAAM,MAAA,OAAA,GAAU,eAAgB,CAAA,GAAA,CAAI,KAAK,CAAA;AACzC,IAAA,IAAI,CAAC,OAAA,EAAS,IAAQ,IAAA,CAAC,QAAQ,GAAK,EAAA;AAClC,MAAA;AAAA;AAGF,IAAA,MAAM,QAAqB,GAAA;AAAA,MACzB,KAAA;AAAA,MACA,MAAM,OAAQ,CAAA,IAAA;AAAA,MACd,KAAK,OAAQ,CAAA;AAAA,KACf;AAGA,IAAA,IAAI,gBACF,KAAU,KAAA,GAAA,GACN,OAAQ,CAAA,cAAA,GACR,QAAQ,cAAe,CAAA,OAAA;AAAA,MACrB,YAAA;AAAA,MACA,IAAA,CAAK,OAAO,YAAY;A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
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function assertServerCondition<P extends typeof process>(p: P): asserts p is P & { env: { NODE_OPTIONS: string } } {
|
|
2
|
-
const nodeOptions = p.env['NODE_OPTIONS'];
|
|
3
|
-
if (!nodeOptions?.match(/--conditions[= ]react-server/)) {
|
|
4
|
-
if(!nodeOptions?.match(/--conditions/)) {
|
|
5
|
-
console.warn(`process.env['NODE_OPTIONS'] is missing \`--conditions\` flag, it should be like \`--conditions=react-server\` or \`--conditions react-server\`, but was ${JSON.stringify(process.env['NODE_OPTIONS'])}`);
|
|
6
|
-
}
|
|
7
|
-
if(!nodeOptions?.match(/react-server/)) {
|
|
8
|
-
throw new Error(`process.env['NODE_OPTIONS'] is missing \`react-server\` flag, it should be like \`--conditions=react-server\` or \`--conditions react-server\`, but was ${JSON.stringify(process.env['NODE_OPTIONS'])}`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return undefined;
|
|
12
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import type { CheckFilesExistReturn, ResolvedUserOptions } from "./types.js";
|
|
4
|
-
import { createInputNormalizer } from "./helpers/inputNormalizer.js";
|
|
5
|
-
|
|
6
|
-
let stashedFiles: CheckFilesExistReturn | null = null;
|
|
7
|
-
|
|
8
|
-
const resolveFileOption = (pageOrProps: string | ((url: string) => string)) => {
|
|
9
|
-
if (typeof pageOrProps === "string") {
|
|
10
|
-
return () => pageOrProps;
|
|
11
|
-
}
|
|
12
|
-
return pageOrProps;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export async function checkFilesExist(
|
|
16
|
-
pages: string[],
|
|
17
|
-
options: ResolvedUserOptions,
|
|
18
|
-
root: string
|
|
19
|
-
): Promise<CheckFilesExistReturn> {
|
|
20
|
-
if(stashedFiles){
|
|
21
|
-
return stashedFiles;
|
|
22
|
-
}
|
|
23
|
-
if (!root || root === "") {
|
|
24
|
-
throw new Error("Root not found");
|
|
25
|
-
}
|
|
26
|
-
const errors: string[] = [];
|
|
27
|
-
const pageSet = new Set<string>();
|
|
28
|
-
const propsSet = new Set<string>();
|
|
29
|
-
const pageMap = new Map<string, string>();
|
|
30
|
-
const propsMap = new Map<string, string>();
|
|
31
|
-
const urlMap = new Map<string, { props: string; page: string }>();
|
|
32
|
-
const normalizer = createInputNormalizer({
|
|
33
|
-
root,
|
|
34
|
-
preserveModulesRoot: options.build.preserveModulesRoot === true ? options.moduleBase : undefined,
|
|
35
|
-
removeExtension: true,
|
|
36
|
-
});
|
|
37
|
-
const pageFn = resolveFileOption(options.Page);
|
|
38
|
-
const propsFn = resolveFileOption(options.props);
|
|
39
|
-
for (const page of pages) {
|
|
40
|
-
const pagePath = pageFn(page);
|
|
41
|
-
const propsPath = propsFn(page);
|
|
42
|
-
const [pageKey, pageValue] = normalizer(pagePath);
|
|
43
|
-
const [propsKey, propsValue] = normalizer(propsPath);
|
|
44
|
-
try {
|
|
45
|
-
if (!existsSync(join(root, pageValue))) {
|
|
46
|
-
errors.push(
|
|
47
|
-
`Page file not found: ${pagePath}, ${join(root, pagePath)}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
if (!existsSync(join(root, propsValue))) {
|
|
51
|
-
errors.push(
|
|
52
|
-
`Props file not found: ${propsPath}, ${join(root, propsPath)}`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
errors.push(`Error checking files: ${error}`);
|
|
57
|
-
}
|
|
58
|
-
urlMap.set(page, { props: propsPath, page: pagePath });
|
|
59
|
-
pageSet.add(pagePath);
|
|
60
|
-
propsSet.add(propsPath);
|
|
61
|
-
pageMap.set(pageKey, pageValue);
|
|
62
|
-
propsMap.set(propsKey, propsValue);
|
|
63
|
-
}
|
|
64
|
-
stashedFiles = { pageMap, pageSet, propsMap, propsSet, urlMap, errors };
|
|
65
|
-
return stashedFiles;
|
|
66
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type { Manifest, ModuleGraph } from "vite";
|
|
2
|
-
import { createInputNormalizer } from "./helpers/inputNormalizer.js";
|
|
3
|
-
import { DEFAULT_CONFIG } from "./config/defaults.js";
|
|
4
|
-
|
|
5
|
-
export async function collectModuleGraphCss({
|
|
6
|
-
moduleGraph,
|
|
7
|
-
pagePath,
|
|
8
|
-
onCss,
|
|
9
|
-
parentUrl,
|
|
10
|
-
}: {
|
|
11
|
-
moduleGraph: ModuleGraph;
|
|
12
|
-
pagePath: string;
|
|
13
|
-
onCss?: (path: string, parentUrl: string) => void;
|
|
14
|
-
parentUrl?: string;
|
|
15
|
-
}) {
|
|
16
|
-
if (!pagePath) return new Map<string, string>();
|
|
17
|
-
|
|
18
|
-
const cssFiles = new Map<string, string>();
|
|
19
|
-
const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
|
|
20
|
-
if (!pageModule) {
|
|
21
|
-
return new Map<string, string>();
|
|
22
|
-
}
|
|
23
|
-
const seen = new Set<string>();
|
|
24
|
-
const walkModule = (mod: any) => {
|
|
25
|
-
if (!mod?.id || seen.has(mod.id)) return;
|
|
26
|
-
seen.add(mod.id);
|
|
27
|
-
if (mod?.id?.endsWith(".css")) {
|
|
28
|
-
cssFiles.set(mod?.url, mod?.id);
|
|
29
|
-
onCss?.(mod?.url, parentUrl ?? pagePath);
|
|
30
|
-
}
|
|
31
|
-
mod?.importedModules?.forEach((imp: any) => walkModule(imp));
|
|
32
|
-
};
|
|
33
|
-
walkModule(pageModule);
|
|
34
|
-
return cssFiles;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function collectManifestClientFiles({
|
|
38
|
-
manifest,
|
|
39
|
-
root,
|
|
40
|
-
pagePath,
|
|
41
|
-
preserveModulesRoot,
|
|
42
|
-
moduleBase,
|
|
43
|
-
onCss,
|
|
44
|
-
onClientModule,
|
|
45
|
-
testClient = DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents,
|
|
46
|
-
testJson = DEFAULT_CONFIG.AUTO_DISCOVER.jsonPattern,
|
|
47
|
-
}: {
|
|
48
|
-
manifest: Manifest;
|
|
49
|
-
root: string;
|
|
50
|
-
pagePath: string;
|
|
51
|
-
preserveModulesRoot?: boolean;
|
|
52
|
-
moduleBase?: string;
|
|
53
|
-
onCss?: (path: string, parentUrl: string) => void;
|
|
54
|
-
onClientModule?: (path: string, parentUrl: string) => void;
|
|
55
|
-
parentUrl?: string;
|
|
56
|
-
testClient?: (id: string) => boolean;
|
|
57
|
-
testJson?: (id: string) => boolean;
|
|
58
|
-
}) {
|
|
59
|
-
const normalizer = createInputNormalizer({
|
|
60
|
-
root,
|
|
61
|
-
removeExtension: true,
|
|
62
|
-
preserveModulesRoot: preserveModulesRoot ? moduleBase : undefined,
|
|
63
|
-
});
|
|
64
|
-
const [_, value] = normalizer(pagePath);
|
|
65
|
-
|
|
66
|
-
const cssFiles = new Map<string, string>();
|
|
67
|
-
const clientFiles = new Map<string, string>();
|
|
68
|
-
const seen = new Set<string>();
|
|
69
|
-
const manifestValues = Object.values(manifest);
|
|
70
|
-
|
|
71
|
-
// Try different variations of the path
|
|
72
|
-
const possibleKeys = [
|
|
73
|
-
value, // Relative path
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
const walkManifestEntry = (id: string, parentUrl: string) => {
|
|
77
|
-
if (seen.has(id)) return;
|
|
78
|
-
seen.add(id);
|
|
79
|
-
|
|
80
|
-
// Get the manifest entry
|
|
81
|
-
const entry = manifest[id] ?? manifestValues.find((e) => id === e.file);
|
|
82
|
-
if (!entry) {
|
|
83
|
-
const hasKey = Object.keys(manifest).find((key) => id === key);
|
|
84
|
-
if (hasKey) {
|
|
85
|
-
console.log(
|
|
86
|
-
`Manifest entry found for ${id}, but it is ${typeof entry}`
|
|
87
|
-
);
|
|
88
|
-
return;
|
|
89
|
-
} else {
|
|
90
|
-
console.log(
|
|
91
|
-
`No manifest entry found for ${id}, possible keys: ${Object.keys(
|
|
92
|
-
manifest
|
|
93
|
-
).join(", ")}`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (
|
|
99
|
-
(typeof testClient === "function" &&
|
|
100
|
-
typeof onClientModule === "function" &&
|
|
101
|
-
testClient(entry.file)) ||
|
|
102
|
-
(typeof testJson === "function" && testJson(entry.file))
|
|
103
|
-
) {
|
|
104
|
-
onClientModule?.(entry.file ?? "", parentUrl);
|
|
105
|
-
clientFiles.set(id, entry.name ?? "");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Add direct CSS from the css array
|
|
109
|
-
if (entry.css) {
|
|
110
|
-
entry.css.forEach((css: string) => {
|
|
111
|
-
cssFiles.set(css, css);
|
|
112
|
-
onCss?.(css, id);
|
|
113
|
-
onClientModule?.(css, id);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Walk imports recursively
|
|
118
|
-
if (entry.imports) {
|
|
119
|
-
entry.imports.forEach((imp: string) =>
|
|
120
|
-
walkManifestEntry(imp, entry.file)
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Also check dynamicImports
|
|
125
|
-
if (entry.dynamicImports) {
|
|
126
|
-
entry.dynamicImports.forEach((imp: string) =>
|
|
127
|
-
walkManifestEntry(imp, entry.file)
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// Try all possible keys
|
|
133
|
-
for (const possibleKey of possibleKeys) {
|
|
134
|
-
if (manifest[possibleKey]) {
|
|
135
|
-
walkManifestEntry(possibleKey, pagePath);
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// If no entry found by key, try matching by file
|
|
141
|
-
if (cssFiles.size === 0) {
|
|
142
|
-
const entry = manifestValues.find(
|
|
143
|
-
(e) =>
|
|
144
|
-
possibleKeys.includes(e.file) ||
|
|
145
|
-
(e.src && possibleKeys.includes(e.src)) ||
|
|
146
|
-
(e.name && possibleKeys.includes(e.name))
|
|
147
|
-
);
|
|
148
|
-
if (entry) {
|
|
149
|
-
walkManifestEntry(value, pagePath);
|
|
150
|
-
} else {
|
|
151
|
-
const hasKey = Object.keys(manifest).find((key) => value === key);
|
|
152
|
-
if (hasKey) {
|
|
153
|
-
console.warn(
|
|
154
|
-
`Manifest entry found for ${value}, but it is ${typeof manifest[hasKey]}`
|
|
155
|
-
);
|
|
156
|
-
} else {
|
|
157
|
-
console.warn(
|
|
158
|
-
`No manifest entry found for ${value} (tried all possible keys: ${possibleKeys.join(
|
|
159
|
-
", "
|
|
160
|
-
)} for manifest keys: ${Object.keys(manifest).join(", ")})`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return { cssFiles, clientFiles };
|
|
167
|
-
}
|
package/plugin/copy-dir.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { copyFileSync, mkdirSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
4
|
-
export async function copyDir(src: string, dest: string, options?: {
|
|
5
|
-
filter?: (file: string) => boolean
|
|
6
|
-
}) {
|
|
7
|
-
const entries = readdirSync(src);
|
|
8
|
-
|
|
9
|
-
mkdirSync(dest, { recursive: true });
|
|
10
|
-
|
|
11
|
-
for (const entry of entries) {
|
|
12
|
-
const srcPath = join(src, entry);
|
|
13
|
-
const destPath = join(dest, entry);
|
|
14
|
-
|
|
15
|
-
const stat = statSync(srcPath);
|
|
16
|
-
|
|
17
|
-
if (options?.filter && !options.filter(srcPath)) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (stat.isDirectory()) {
|
|
22
|
-
await copyDir(srcPath, destPath, options);
|
|
23
|
-
} else {
|
|
24
|
-
copyFileSync(srcPath, destPath);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import type { InlineCssCollectorProps } from "./types.js";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
|
|
6
|
-
interface CssContent {
|
|
7
|
-
type?: string;
|
|
8
|
-
content: string;
|
|
9
|
-
key?: string;
|
|
10
|
-
path: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A component that inlines pre-transformed CSS content.
|
|
15
|
-
* Expects cssFiles to be an array of CssContent objects with the content already loaded.
|
|
16
|
-
*/
|
|
17
|
-
export function InlineCssCollector({
|
|
18
|
-
children,
|
|
19
|
-
cssFiles,
|
|
20
|
-
moduleRootPath,
|
|
21
|
-
}: InlineCssCollectorProps) {
|
|
22
|
-
return React.createElement(
|
|
23
|
-
React.Fragment,
|
|
24
|
-
null,
|
|
25
|
-
cssFiles.map((file, index) => {
|
|
26
|
-
if (typeof file === "string") {
|
|
27
|
-
let filePath = file as string;
|
|
28
|
-
if(process.env["NODE_ENV"] === "development") {
|
|
29
|
-
return React.createElement("link", {
|
|
30
|
-
key: file,
|
|
31
|
-
rel: "stylesheet",
|
|
32
|
-
href: filePath,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return React.createElement(
|
|
36
|
-
"style",
|
|
37
|
-
{
|
|
38
|
-
key: file,
|
|
39
|
-
type: "text/css",
|
|
40
|
-
},
|
|
41
|
-
readFileSync(join(moduleRootPath, filePath), "utf-8")
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const { type, content, key, path } = file as CssContent;
|
|
46
|
-
return React.createElement(
|
|
47
|
-
"style",
|
|
48
|
-
{
|
|
49
|
-
key: key ?? path ?? index,
|
|
50
|
-
type: type ?? "text/css",
|
|
51
|
-
...(process.env["NODE_ENV"] === "development" && {
|
|
52
|
-
"data-vite-dev-id": join(moduleRootPath, path),
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
content
|
|
56
|
-
);
|
|
57
|
-
}),
|
|
58
|
-
children
|
|
59
|
-
);
|
|
60
|
-
}
|