vite-plugin-react-server 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -76
- package/bin/patch.mjs +27 -20
- package/dist/_virtual/dynamic-import-helper.js +24 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -14
- package/dist/plugin/components.d.ts +1 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +18 -14
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +42 -21
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getCondition.d.ts +1 -1
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +2 -2
- package/dist/plugin/config/getCondition.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/index.d.ts +0 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscover.js +128 -0
- package/dist/plugin/config/resolveAutoDiscover.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +109 -77
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +0 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +6 -8
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
- package/dist/plugin/config/resolveUrlOption.js +37 -0
- package/dist/plugin/config/resolveUrlOption.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -132
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy.d.ts +7 -0
- package/dist/plugin/copy.d.ts.map +1 -0
- package/dist/plugin/copy.js +30 -0
- package/dist/plugin/css-collector-elements.d.ts +4 -0
- package/dist/plugin/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/css-collector-elements.js +19 -0
- package/dist/plugin/css-collector-elements.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +2 -8
- package/dist/plugin/css-collector.d.ts.map +1 -1
- package/dist/plugin/css-collector.js +9 -36
- package/dist/plugin/css-collector.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts +3 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
- package/dist/plugin/helpers/cleanObject.js +47 -0
- package/dist/plugin/helpers/cleanObject.js.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js +44 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
- package/dist/plugin/helpers/createCssProps.d.ts +25 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
- package/dist/plugin/helpers/createCssProps.js +57 -0
- package/dist/plugin/helpers/createCssProps.js.map +1 -0
- package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createEventHandler.js +36 -0
- package/dist/plugin/helpers/createEventHandler.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +7 -13
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +54 -96
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +12 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +105 -51
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
- package/dist/plugin/helpers/defaultFileWriter.js +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +30 -22
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.js +36 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +38 -32
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.d.ts +11 -0
- package/dist/plugin/helpers/metrics.d.ts.map +1 -0
- package/dist/plugin/helpers/metrics.js +35 -0
- package/dist/plugin/helpers/metrics.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +182 -0
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.js +14 -0
- package/dist/plugin/helpers/tryManifest.d.ts +5 -3
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +16 -7
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +2 -3
- package/dist/plugin/html.d.ts.map +1 -1
- package/dist/plugin/html.js +7 -1
- package/dist/plugin/html.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +98 -33
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts +57 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.development.js +81 -0
- package/dist/plugin/loader/css-loader.development.js.map +1 -0
- package/dist/plugin/loader/css-loader.production.d.ts +31 -0
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.production.js +45 -0
- package/dist/plugin/loader/css-loader.production.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +2 -0
- package/dist/plugin/loader/index.d.ts.map +1 -0
- package/dist/plugin/loader/index.js +1 -0
- package/dist/plugin/loader/plugin.d.ts +22 -0
- package/dist/plugin/loader/plugin.d.ts.map +1 -0
- package/dist/plugin/loader/plugin.js +27 -0
- package/dist/plugin/loader/react-loader.d.ts +3 -7
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +85 -30
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/loader/temporaryReferences.js +11 -0
- package/dist/plugin/loader/temporaryReferences.js.map +1 -0
- package/dist/plugin/moduleRefs.d.ts +7 -0
- package/dist/plugin/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/moduleRefs.js +17 -0
- package/dist/plugin/moduleRefs.js.map +1 -0
- package/dist/plugin/plugin.client.d.ts +3 -0
- package/dist/plugin/plugin.client.d.ts.map +1 -0
- package/dist/plugin/plugin.client.js +19 -0
- package/dist/plugin/plugin.client.js.map +1 -0
- package/dist/plugin/plugin.d.ts +1 -5
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +3 -9
- package/dist/plugin/plugin.server.d.ts +3 -0
- package/dist/plugin/plugin.server.d.ts.map +1 -0
- package/dist/plugin/plugin.server.js +28 -0
- package/dist/plugin/plugin.server.js.map +1 -0
- package/dist/plugin/preserver/plugin.js +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +1 -2
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +1 -19
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +60 -219
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +27 -0
- package/dist/plugin/react-client/server.d.ts.map +1 -0
- package/dist/plugin/react-client/server.js +197 -0
- package/dist/plugin/react-client/server.js.map +1 -0
- package/dist/plugin/react-server/index.d.ts +1 -2
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +1 -21
- package/dist/plugin/react-server/plugin.d.ts +0 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +60 -186
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts +9 -0
- package/dist/plugin/react-server/server.d.ts.map +1 -0
- package/dist/plugin/react-server/server.js +120 -0
- package/dist/plugin/react-server/server.js.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectRscContent.js +49 -0
- package/dist/plugin/react-static/collectRscContent.js.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.js +67 -0
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
- package/dist/plugin/react-static/fileWriter.d.ts +23 -0
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
- package/dist/plugin/react-static/fileWriter.js +65 -0
- package/dist/plugin/react-static/fileWriter.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +15 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +248 -149
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +3 -0
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.js +116 -0
- package/dist/plugin/react-static/renderPage.js.map +1 -0
- package/dist/plugin/react-static/renderPages.d.ts +3 -0
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPages.js +125 -0
- package/dist/plugin/react-static/renderPages.js.map +1 -0
- package/dist/plugin/react-static/renderStreams.d.ts +26 -0
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
- package/dist/plugin/react-static/renderStreams.js +27 -0
- package/dist/plugin/react-static/renderStreams.js.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
- package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
- package/dist/plugin/react-static/streamHandler.d.ts +2 -0
- package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
- package/dist/plugin/react-static/streamHandler.js +1 -0
- package/dist/plugin/react-static/types.d.ts +11 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/resolvePage.d.ts +26 -9
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +41 -39
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts +40 -7
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +100 -75
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/root.d.ts +1 -0
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -0
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/index.d.ts +2 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +2 -1
- package/dist/plugin/transformer/plugin.client.d.ts +4 -0
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.client.js +83 -0
- package/dist/plugin/transformer/plugin.client.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts +1 -27
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +3 -87
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +4 -0
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +76 -0
- package/dist/plugin/transformer/plugin.server.js.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
- package/dist/plugin/types/css-tracking.d.ts +6 -0
- package/dist/plugin/types/css-tracking.d.ts.map +1 -0
- package/dist/plugin/types/css-tracking.js +1 -0
- package/dist/plugin/types.d.ts +372 -86
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/vendor.client.d.ts +4 -0
- package/dist/plugin/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor.client.js +16 -0
- package/dist/plugin/vendor.client.js.map +1 -0
- package/dist/plugin/vendor.server.d.ts +4 -0
- package/dist/plugin/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor.server.js +16 -0
- package/dist/plugin/vendor.server.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +25 -7
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +108 -33
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +3 -17
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +12 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +87 -84
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/types.d.ts +18 -0
- package/dist/plugin/worker/html/types.d.ts.map +1 -0
- package/dist/plugin/worker/html/types.js +1 -0
- package/dist/plugin/worker/registerLoaders.d.ts +9 -0
- package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
- package/dist/plugin/worker/registerLoaders.js +45 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRender.js +147 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +47 -112
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +73 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +40 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +3 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
- package/dist/plugin/worker/sendMessage.js +48 -0
- package/dist/plugin/worker/types.d.ts +218 -76
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/plugin/components.ts +1 -1
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
- package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
- package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
- package/plugin/config/defaults.tsx +38 -29
- package/plugin/config/getCondition.ts +7 -3
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/index.ts +0 -1
- package/plugin/config/resolveAutoDiscover.ts +177 -0
- package/plugin/config/resolveOptions.ts +220 -118
- package/plugin/config/resolvePages.ts +5 -7
- package/plugin/config/resolveUrlOption.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +116 -166
- package/plugin/copy.ts +39 -0
- package/plugin/css-collector-elements.tsx +21 -0
- package/plugin/css-collector.tsx +20 -53
- package/plugin/helpers/cleanObject.ts +50 -0
- package/plugin/helpers/collectBundleManifestCss.ts +160 -0
- package/plugin/helpers/collectManifestCss.ts +61 -0
- package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
- package/plugin/helpers/createCssProps.tsx +85 -0
- package/plugin/helpers/createEventHandler.ts +44 -0
- package/plugin/helpers/createHandler.ts +57 -126
- package/plugin/helpers/createRscStream.tsx +156 -0
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/getBundleManifest.ts +42 -37
- package/plugin/helpers/getRouteFiles.ts +47 -0
- package/plugin/helpers/inputNormalizer.ts +16 -10
- package/plugin/helpers/metrics.ts +64 -0
- package/plugin/helpers/resolvePageAndProps.ts +81 -0
- package/plugin/helpers/serializeUserOptions.ts +209 -0
- package/plugin/helpers/stashReturnValue.ts +16 -0
- package/plugin/helpers/tryManifest.ts +35 -18
- package/plugin/html.tsx +14 -3
- package/plugin/index.ts +5 -2
- package/plugin/loader/createBuildLoader.ts +152 -47
- package/plugin/loader/css-loader.development.ts +157 -0
- package/plugin/loader/css-loader.production.ts +86 -0
- package/plugin/loader/index.ts +1 -0
- package/plugin/loader/plugin.ts +33 -0
- package/plugin/loader/react-loader.ts +109 -41
- package/plugin/loader/temporaryReferences.ts +3 -0
- package/plugin/moduleRefs.ts +11 -0
- package/plugin/plugin.client.ts +12 -0
- package/plugin/plugin.server.ts +25 -0
- package/plugin/plugin.ts +5 -9
- package/plugin/preserver/plugin.ts +1 -1
- package/plugin/react-client/index.ts +1 -12
- package/plugin/react-client/plugin.ts +70 -259
- package/plugin/react-client/server.ts +276 -0
- package/plugin/react-server/index.ts +1 -14
- package/plugin/react-server/plugin.ts +69 -220
- package/plugin/react-server/server.ts +128 -0
- package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
- package/plugin/react-static/collectRscContent.ts +77 -0
- package/plugin/react-static/configurePreviewServer.ts +68 -0
- package/plugin/react-static/fileWriter.ts +103 -0
- package/plugin/react-static/plugin.ts +308 -181
- package/plugin/react-static/renderPage.ts +151 -0
- package/plugin/react-static/renderPages.ts +154 -0
- package/plugin/react-static/renderStreams.ts +48 -0
- package/plugin/react-static/rscToHtmlStream.ts +85 -0
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/react-static/types.ts +10 -0
- package/plugin/resolvePage.ts +67 -57
- package/plugin/resolveProps.ts +148 -104
- package/plugin/root.ts +1 -1
- package/plugin/transformer/index.ts +2 -1
- package/plugin/transformer/plugin.client.ts +109 -0
- package/plugin/transformer/plugin.server.ts +98 -0
- package/plugin/transformer/plugin.ts +2 -115
- package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
- package/plugin/types/css-tracking.ts +5 -0
- package/plugin/types/react-server-dom-esm.d.ts +54 -0
- package/plugin/types.ts +508 -97
- package/plugin/vendor.client.ts +12 -0
- package/plugin/vendor.server.ts +12 -0
- package/plugin/worker/createWorker.ts +158 -53
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -75
- package/plugin/worker/html/html-worker.production.tsx +18 -7
- package/plugin/worker/html/messageHandler.tsx +126 -0
- package/plugin/worker/html/types.ts +19 -0
- package/plugin/worker/registerLoaders.ts +54 -0
- package/plugin/worker/rsc/handleRender.ts +180 -0
- package/plugin/worker/rsc/messageHandler.tsx +58 -132
- package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
- package/plugin/worker/rsc/state.ts +79 -2
- package/plugin/worker/sendMessage.ts +49 -0
- package/plugin/worker/types.ts +299 -100
- package/scripts/check-react-version.mjs +60 -48
- package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
- package/tsconfig.json +7 -2
- package/dist/plugin/assertServerCondition.d.ts +0 -6
- package/dist/plugin/assertServerCondition.d.ts.map +0 -1
- package/dist/plugin/assertServerCondition.js +0 -13
- package/dist/plugin/checkFilesExist.d.ts +0 -3
- package/dist/plugin/checkFilesExist.d.ts.map +0 -1
- package/dist/plugin/checkFilesExist.js +0 -67
- package/dist/plugin/checkFilesExist.js.map +0 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
- package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
- package/dist/plugin/collect-manifest-client-files.js +0 -131
- package/dist/plugin/collect-manifest-client-files.js.map +0 -1
- package/dist/plugin/config/getWorkerPath.d.ts +0 -2
- package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
- package/dist/plugin/config/getWorkerPath.js +0 -4
- package/dist/plugin/copy-dir.d.ts +0 -4
- package/dist/plugin/copy-dir.d.ts.map +0 -1
- package/dist/plugin/copy-dir.js +0 -25
- package/dist/plugin/copy-dir.js.map +0 -1
- package/dist/plugin/css-collector-inline.d.ts +0 -10
- package/dist/plugin/css-collector-inline.d.ts.map +0 -1
- package/dist/plugin/css-collector-inline.js +0 -55
- package/dist/plugin/css-collector-inline.js.map +0 -1
- package/dist/plugin/loader/css-loader.d.ts +0 -16
- package/dist/plugin/loader/css-loader.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.js +0 -70
- package/dist/plugin/loader/css-loader.js.map +0 -1
- package/dist/plugin/react-client/index.js.map +0 -1
- package/dist/plugin/react-server/index.js.map +0 -1
- package/dist/plugin/worker/html/renderPages.d.ts +0 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
- package/dist/plugin/worker/html/renderPages.js +0 -241
- package/dist/plugin/worker/html/renderPages.js.map +0 -1
- package/plugin/assertServerCondition.ts +0 -12
- package/plugin/checkFilesExist.ts +0 -66
- package/plugin/collect-manifest-client-files.ts +0 -167
- package/plugin/config/getWorkerPath.ts +0 -5
- package/plugin/copy-dir.ts +0 -27
- package/plugin/css-collector-inline.tsx +0 -60
- package/plugin/helpers/createRscStream.ts +0 -109
- package/plugin/loader/css-loader.ts +0 -94
- package/plugin/worker/html/messageHandler.ts +0 -130
- package/plugin/worker/html/renderPages.ts +0 -293
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { cleanObject } from './cleanObject.js';
|
|
7
|
+
|
|
8
|
+
const VITE_NON_SERIALIZABLE_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
9
|
+
"renderChunk",
|
|
10
|
+
"buildStart",
|
|
11
|
+
"buildEnd",
|
|
12
|
+
"watchChange",
|
|
13
|
+
"resolveId",
|
|
14
|
+
"config",
|
|
15
|
+
"output[].entryFileNames",
|
|
16
|
+
"output[].chunkFileNames",
|
|
17
|
+
"output[].assetFileNames",
|
|
18
|
+
"transform",
|
|
19
|
+
"handler",
|
|
20
|
+
"configureServer",
|
|
21
|
+
"shouldTransformCachedModule",
|
|
22
|
+
"generateBundle",
|
|
23
|
+
"renderStart",
|
|
24
|
+
"writeBundle",
|
|
25
|
+
"hotUpdate",
|
|
26
|
+
"configResolved",
|
|
27
|
+
"configurePreviewServer",
|
|
28
|
+
"handleHotUpdate",
|
|
29
|
+
"load",
|
|
30
|
+
"augmentChunkHash",
|
|
31
|
+
"closeBundle",
|
|
32
|
+
"entryFileNames",
|
|
33
|
+
"assetFileNames",
|
|
34
|
+
"chunkFileNames",
|
|
35
|
+
"createEnvironment",
|
|
36
|
+
"sourcemapIgnoreList",
|
|
37
|
+
"assetsInclude",
|
|
38
|
+
"info",
|
|
39
|
+
"warn",
|
|
40
|
+
"warnOnce",
|
|
41
|
+
"error",
|
|
42
|
+
"clearScreen",
|
|
43
|
+
"hasErrorLogged",
|
|
44
|
+
"set",
|
|
45
|
+
"plugins",
|
|
46
|
+
"getSortedPlugins",
|
|
47
|
+
"getSortedPluginHooks",
|
|
48
|
+
"createResolver",
|
|
49
|
+
"fsDenyGlob",
|
|
50
|
+
// Nested plugin functions
|
|
51
|
+
"plugins[].renderChunk",
|
|
52
|
+
"plugins[].buildStart",
|
|
53
|
+
"plugins[].buildEnd",
|
|
54
|
+
"plugins[].watchChange",
|
|
55
|
+
"plugins[].resolveId",
|
|
56
|
+
"plugins[].config",
|
|
57
|
+
"plugins[].transform",
|
|
58
|
+
"plugins[].handler",
|
|
59
|
+
"plugins[].configureServer",
|
|
60
|
+
"plugins[].shouldTransformCachedModule",
|
|
61
|
+
"plugins[].generateBundle",
|
|
62
|
+
"plugins[].renderStart",
|
|
63
|
+
"plugins[].writeBundle",
|
|
64
|
+
"plugins[].hotUpdate",
|
|
65
|
+
"plugins[].configResolved",
|
|
66
|
+
"plugins[].configurePreviewServer",
|
|
67
|
+
"plugins[].handleHotUpdate",
|
|
68
|
+
"plugins[].load",
|
|
69
|
+
"plugins[].augmentChunkHash",
|
|
70
|
+
"plugins[].closeBundle",
|
|
71
|
+
"plugins[].entryFileNames",
|
|
72
|
+
"plugins[].assetFileNames",
|
|
73
|
+
"plugins[].chunkFileNames",
|
|
74
|
+
"plugins[].createEnvironment",
|
|
75
|
+
"plugins[].sourcemapIgnoreList",
|
|
76
|
+
"plugins[].assetsInclude"
|
|
77
|
+
]);
|
|
78
|
+
const PLUGIN_NON_SERIALIZABLE_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
79
|
+
"Page",
|
|
80
|
+
"props",
|
|
81
|
+
"normalizer",
|
|
82
|
+
"CssCollector",
|
|
83
|
+
"Html",
|
|
84
|
+
"onEvent",
|
|
85
|
+
"onMetrics",
|
|
86
|
+
"build.entryFile",
|
|
87
|
+
"build.chunkFile",
|
|
88
|
+
"build.assetFile",
|
|
89
|
+
"build.pages",
|
|
90
|
+
"autoDiscover"
|
|
91
|
+
]);
|
|
92
|
+
function serializeRegExp(regex) {
|
|
93
|
+
return {
|
|
94
|
+
source: regex.source,
|
|
95
|
+
flags: regex.flags,
|
|
96
|
+
__isRegExp: true
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function deserializeRegExp(obj) {
|
|
100
|
+
if (obj && obj.__isRegExp) {
|
|
101
|
+
return new RegExp(obj.source, obj.flags);
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(obj)) {
|
|
104
|
+
return obj.map(deserializeRegExp);
|
|
105
|
+
}
|
|
106
|
+
if (obj && typeof obj === "object") {
|
|
107
|
+
const result = {};
|
|
108
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
109
|
+
result[key] = deserializeRegExp(value);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
return obj;
|
|
114
|
+
}
|
|
115
|
+
function processForSerialization(obj) {
|
|
116
|
+
if (obj instanceof RegExp) {
|
|
117
|
+
return serializeRegExp(obj);
|
|
118
|
+
}
|
|
119
|
+
if (Array.isArray(obj)) {
|
|
120
|
+
return obj.map(processForSerialization);
|
|
121
|
+
}
|
|
122
|
+
if (obj && typeof obj === "object") {
|
|
123
|
+
const result = {};
|
|
124
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
125
|
+
result[key] = processForSerialization(value);
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
return obj;
|
|
130
|
+
}
|
|
131
|
+
function serializeResolvedConfig(config, knownNonSerializableFunctions = VITE_NON_SERIALIZABLE_FUNCTIONS) {
|
|
132
|
+
const {
|
|
133
|
+
getSortedPluginHooks,
|
|
134
|
+
getSortedPlugins,
|
|
135
|
+
assetsInclude,
|
|
136
|
+
// extract known vite function properties
|
|
137
|
+
...handlerOptions
|
|
138
|
+
} = config;
|
|
139
|
+
return processForSerialization(cleanObject(handlerOptions, knownNonSerializableFunctions));
|
|
140
|
+
}
|
|
141
|
+
const serializedDevServerConfig = (config, customNonSerializableFunctions = PLUGIN_NON_SERIALIZABLE_FUNCTIONS) => {
|
|
142
|
+
const {
|
|
143
|
+
getSortedPluginHooks,
|
|
144
|
+
getSortedPlugins,
|
|
145
|
+
assetsInclude,
|
|
146
|
+
build,
|
|
147
|
+
...handlerOptions
|
|
148
|
+
} = config;
|
|
149
|
+
return processForSerialization(cleanObject(
|
|
150
|
+
handlerOptions,
|
|
151
|
+
customNonSerializableFunctions
|
|
152
|
+
));
|
|
153
|
+
};
|
|
154
|
+
const serializedOptions = (userOptions, autoDiscoveredFiles, customNonSerializableFunctions = PLUGIN_NON_SERIALIZABLE_FUNCTIONS) => {
|
|
155
|
+
const {
|
|
156
|
+
Page,
|
|
157
|
+
props,
|
|
158
|
+
normalizer,
|
|
159
|
+
CssCollector,
|
|
160
|
+
Html,
|
|
161
|
+
onEvent,
|
|
162
|
+
onMetrics,
|
|
163
|
+
build,
|
|
164
|
+
autoDiscover,
|
|
165
|
+
...handlerOptions
|
|
166
|
+
} = userOptions;
|
|
167
|
+
const { entryFile, chunkFile, assetFile, pages, ...buildOptions } = build;
|
|
168
|
+
const result = {
|
|
169
|
+
...handlerOptions,
|
|
170
|
+
build: {
|
|
171
|
+
...buildOptions,
|
|
172
|
+
pages: autoDiscoveredFiles ? Array.from(autoDiscoveredFiles.urlMap.keys()) : []
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return processForSerialization(cleanObject(
|
|
176
|
+
result,
|
|
177
|
+
customNonSerializableFunctions
|
|
178
|
+
));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { deserializeRegExp, processForSerialization, serializeResolvedConfig, serializedDevServerConfig, serializedOptions };
|
|
182
|
+
//# sourceMappingURL=serializeUserOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeUserOptions.js","sources":["../../../plugin/helpers/serializeUserOptions.ts"],"sourcesContent":["import type { ResolvedConfig, ViteDevServer } from \"vite\";\nimport type {\n AutoDiscoveredFiles,\n ResolvedUserOptions,\n} from \"../types.js\";\nimport { cleanObject } from \"./cleanObject.js\";\n\n// Common non-serializable functions in Vite's resolved config\nconst VITE_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"renderChunk\",\n \"buildStart\",\n \"buildEnd\",\n \"watchChange\",\n \"resolveId\",\n \"config\",\n \"output[].entryFileNames\",\n \"output[].chunkFileNames\",\n \"output[].assetFileNames\",\n \"transform\",\n \"handler\",\n \"configureServer\",\n \"shouldTransformCachedModule\",\n \"generateBundle\",\n \"renderStart\",\n \"writeBundle\",\n \"hotUpdate\",\n \"configResolved\",\n \"configurePreviewServer\",\n \"handleHotUpdate\",\n \"load\",\n \"augmentChunkHash\",\n \"closeBundle\",\n \"entryFileNames\",\n \"assetFileNames\",\n \"chunkFileNames\",\n \"createEnvironment\",\n \"sourcemapIgnoreList\",\n \"assetsInclude\",\n \"info\",\n \"warn\",\n \"warnOnce\",\n \"error\",\n \"clearScreen\",\n \"hasErrorLogged\",\n \"set\",\n \"plugins\",\n \"getSortedPlugins\",\n \"getSortedPluginHooks\",\n \"createResolver\",\n \"fsDenyGlob\",\n // Nested plugin functions\n \"plugins[].renderChunk\",\n \"plugins[].buildStart\",\n \"plugins[].buildEnd\",\n \"plugins[].watchChange\",\n \"plugins[].resolveId\",\n \"plugins[].config\",\n \"plugins[].transform\",\n \"plugins[].handler\",\n \"plugins[].configureServer\",\n \"plugins[].shouldTransformCachedModule\",\n \"plugins[].generateBundle\",\n \"plugins[].renderStart\",\n \"plugins[].writeBundle\",\n \"plugins[].hotUpdate\",\n \"plugins[].configResolved\",\n \"plugins[].configurePreviewServer\",\n \"plugins[].handleHotUpdate\",\n \"plugins[].load\",\n \"plugins[].augmentChunkHash\",\n \"plugins[].closeBundle\",\n \"plugins[].entryFileNames\",\n \"plugins[].assetFileNames\",\n \"plugins[].chunkFileNames\",\n \"plugins[].createEnvironment\",\n \"plugins[].sourcemapIgnoreList\",\n \"plugins[].assetsInclude\",\n]);\n\n// Common non-serializable functions in our plugin's options\nconst PLUGIN_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"Page\",\n \"props\",\n \"normalizer\",\n \"CssCollector\",\n \"Html\",\n \"onEvent\",\n \"onMetrics\",\n \"build.entryFile\",\n \"build.chunkFile\",\n \"build.assetFile\",\n \"build.pages\",\n \"autoDiscover\",\n]);\n\n// Helper function to serialize RegExp objects\nfunction serializeRegExp(regex: RegExp) {\n return {\n source: regex.source,\n flags: regex.flags,\n __isRegExp: true\n };\n}\n\n// Helper function to deserialize RegExp objects\nexport function deserializeRegExp(obj: any): any {\n if (obj && obj.__isRegExp) {\n return new RegExp(obj.source, obj.flags);\n }\n if (Array.isArray(obj)) {\n return obj.map(deserializeRegExp);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = deserializeRegExp(value);\n }\n return result;\n }\n return obj;\n}\n\n// Helper function to recursively process objects for serialization\nexport function processForSerialization(obj: any): any {\n if (obj instanceof RegExp) {\n return serializeRegExp(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map(processForSerialization);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = processForSerialization(value);\n }\n return result;\n }\n return obj;\n}\n\nexport function serializeResolvedConfig<T extends ResolvedConfig>(\n config: T,\n knownNonSerializableFunctions: Set<string> = VITE_NON_SERIALIZABLE_FUNCTIONS\n) {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n // extract known vite function properties\n ...handlerOptions\n } = config;\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(handlerOptions, knownNonSerializableFunctions));\n}\n\n// For Vite's config\nexport const serializedDevServerConfig = <T extends ViteDevServer[\"config\"]>(\n config: T,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n build,\n ...handlerOptions\n } = config;\n return processForSerialization(cleanObject(\n handlerOptions,\n customNonSerializableFunctions\n ));\n};\n\n// For your own options (if you need custom non-serializable functions)\nexport const serializedOptions = <T extends ResolvedUserOptions>(\n userOptions: T,\n autoDiscoveredFiles: AutoDiscoveredFiles,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n Page,\n props,\n normalizer,\n CssCollector,\n Html,\n onEvent,\n onMetrics,\n build,\n autoDiscover,\n ...handlerOptions\n } = userOptions;\n const { entryFile, chunkFile, assetFile, pages, ...buildOptions } = build;\n const result = {\n ...handlerOptions,\n build: {\n ...buildOptions,\n pages: autoDiscoveredFiles\n ? Array.from(autoDiscoveredFiles.urlMap.keys())\n : [],\n },\n };\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(\n result,\n customNonSerializableFunctions\n ));\n};\n"],"names":[],"mappings":";;;;;;;AAQA,MAAM,+BAAA,uBAAsC,GAAI,CAAA;AAAA,EAC9C,aAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,iBAAA;AAAA,EACA,6BAAA;AAAA,EACA,gBA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;AAGA,EAAA,OAAO,uBAAwB,CAAA,WAAA;AAAA,IAC7B,MAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stashReturnValue.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/stashReturnValue.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,GAAI,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,MACjE,EAAE,KACL,EAYF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const stashedReturnValue = new Map();
|
|
2
|
+
export const stashReturnValue = (fn) => {
|
|
3
|
+
return ((...args) => {
|
|
4
|
+
const id = args
|
|
5
|
+
.map((arg) => !arg ? '' : typeof arg === "string" ? arg : typeof arg === "object" && 'id' in arg ? arg.id : '')
|
|
6
|
+
.join("_");
|
|
7
|
+
if (stashedReturnValue.has(id)) {
|
|
8
|
+
return stashedReturnValue.get(id);
|
|
9
|
+
}
|
|
10
|
+
const result = fn(...args);
|
|
11
|
+
stashedReturnValue.set(id, result);
|
|
12
|
+
return result;
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Manifest } from "vite";
|
|
2
|
-
type TryManifestOptions<SSR extends boolean> = {
|
|
2
|
+
type TryManifestOptions<SSR extends boolean = false> = {
|
|
3
3
|
root: string;
|
|
4
4
|
outDir: string;
|
|
5
5
|
ssrManifest?: SSR;
|
|
6
|
+
preserveModulesRoot?: string;
|
|
7
|
+
manifestPath?: string | undefined;
|
|
6
8
|
};
|
|
7
|
-
export declare function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): {
|
|
9
|
+
export declare function tryManifest<SSR extends boolean>(options: TryManifestOptions<SSR>): Promise<{
|
|
8
10
|
type: "success";
|
|
9
11
|
manifest: SSR extends true ? Record<string, string[]> : Manifest;
|
|
10
12
|
error?: never;
|
|
@@ -12,6 +14,6 @@ export declare function tryManifest<SSR extends boolean>(options: TryManifestOpt
|
|
|
12
14
|
type: "error";
|
|
13
15
|
error: Error;
|
|
14
16
|
manifest?: never;
|
|
15
|
-
}
|
|
17
|
+
}>;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=tryManifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/tryManifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"tryManifest.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/tryManifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGrC,KAAK,kBAAkB,CAAC,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAIF,wBAAsB,WAAW,CAAC,GAAG,SAAS,OAAO,EACnD,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC/B,OAAO,CACN;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,SAAS,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC;IACjE,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC,CA4BL"}
|
|
@@ -3,24 +3,33 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
|
+
import { readFile } from 'node:fs/promises';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const stashedManifests = /* @__PURE__ */ new Map();
|
|
10
|
+
async function tryManifest(options) {
|
|
11
|
+
if (stashedManifests.has(options.outDir)) {
|
|
12
|
+
return {
|
|
13
|
+
type: "success",
|
|
14
|
+
manifest: stashedManifests.get(options.outDir)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const localSsrManifestPath = !options.ssrManifest ? undefined : options.manifestPath ? options.manifestPath : join(".vite", "ssr-manifest.json");
|
|
18
|
+
const localManifestPath = options.ssrManifest ? undefined : options.manifestPath ? options.manifestPath : join(".vite", "manifest.json");
|
|
10
19
|
const manifestPath = resolve(
|
|
11
20
|
options.root,
|
|
12
21
|
options.outDir,
|
|
13
|
-
|
|
14
|
-
options.ssrManifest ? "ssr-manifest.json" : "manifest.json"
|
|
22
|
+
options.ssrManifest ? localSsrManifestPath : localManifestPath
|
|
15
23
|
);
|
|
16
24
|
try {
|
|
17
|
-
const result = JSON.parse(
|
|
25
|
+
const result = JSON.parse(await readFile(manifestPath, "utf-8"));
|
|
26
|
+
stashedManifests.set(options.outDir, result);
|
|
18
27
|
return {
|
|
19
28
|
type: "success",
|
|
20
29
|
manifest: result
|
|
21
30
|
};
|
|
22
31
|
} catch (e) {
|
|
23
|
-
console.
|
|
32
|
+
console.trace("No manifest found", manifestPath);
|
|
24
33
|
return {
|
|
25
34
|
type: "error",
|
|
26
35
|
error: e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryManifest.js","sources":["../../../plugin/helpers/tryManifest.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"tryManifest.js","sources":["../../../plugin/helpers/tryManifest.ts"],"sourcesContent":["import { join, resolve } from \"node:path\";\n\nimport type { Manifest } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\n\ntype TryManifestOptions<SSR extends boolean = false> = {\n root: string;\n outDir: string;\n ssrManifest?: SSR;\n preserveModulesRoot?: string;\n manifestPath?: string | undefined;\n};\n\nconst stashedManifests: Map<string, any> = new Map();\n\nexport async function tryManifest<SSR extends boolean>(\n options: TryManifestOptions<SSR>\n): Promise<\n | {\n type: \"success\";\n manifest: SSR extends true ? Record<string, string[]> : Manifest;\n error?: never;\n }\n | {\n type: \"error\";\n error: Error;\n manifest?: never;\n }> {\n if (stashedManifests.has(options.outDir)) {\n return {\n type: \"success\",\n manifest: stashedManifests.get(options.outDir),\n };\n }\n const localSsrManifestPath = !options.ssrManifest ? undefined : options.manifestPath ? options.manifestPath : join('.vite', 'ssr-manifest.json');\n const localManifestPath = options.ssrManifest ? undefined : options.manifestPath ? options.manifestPath : join('.vite', 'manifest.json');\n const manifestPath = resolve(\n options.root,\n options.outDir,\n options.ssrManifest ? localSsrManifestPath as string : localManifestPath as string\n );\n try {\n const result = JSON.parse(await readFile(manifestPath, \"utf-8\"));\n stashedManifests.set(options.outDir, result);\n return {\n type: \"success\",\n manifest: result,\n };\n } catch (e) {\n console.trace(\"No manifest found\", manifestPath);\n return {\n type: \"error\",\n error: e as Error,\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAaA,MAAM,gBAAA,uBAAyC,GAAI,EAAA;AAEnD,eAAsB,YACpB,OAWK,EAAA;AACL,EAAA,IAAI,gBAAiB,CAAA,GAAA,CAAI,OAAQ,CAAA,MAAM,CAAG,EAAA;AACxC,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,QAAU,EAAA,gBAAA,CAAiB,GAAI,CAAA,OAAA,CAAQ,MAAM;AAAA,KAC/C;AAAA;AAEF,EAAM,MAAA,oBAAA,GAAuB,CAAC,OAAA,CAAQ,WAAc,GAAA,SAAA,GAAY,OAAQ,CAAA,YAAA,GAAe,OAAQ,CAAA,YAAA,GAAe,IAAK,CAAA,OAAA,EAAS,mBAAmB,CAAA;AAC/I,EAAM,MAAA,iBAAA,GAAoB,OAAQ,CAAA,WAAA,GAAc,SAAY,GAAA,OAAA,CAAQ,eAAe,OAAQ,CAAA,YAAA,GAAe,IAAK,CAAA,OAAA,EAAS,eAAe,CAAA;AACvI,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,OAAQ,CAAA,IAAA;AAAA,IACR,OAAQ,CAAA,MAAA;AAAA,IACR,OAAA,CAAQ,cAAc,oBAAiC,GAAA;AAAA,GACzD;AACA,EAAI,IAAA;AACF,IAAA,MAAM,SAAS,IAAK,CAAA,KAAA,CAAM,MAAM,QAAS,CAAA,YAAA,EAAc,OAAO,CAAC,CAAA;AAC/D,IAAiB,gBAAA,CAAA,GAAA,CAAI,OAAQ,CAAA,MAAA,EAAQ,MAAM,CAAA;AAC3C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,QAAU,EAAA;AAAA,KACZ;AAAA,WACO,CAAG,EAAA;AACV,IAAQ,OAAA,CAAA,KAAA,CAAM,qBAAqB,YAAY,CAAA;AAC/C,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,KACT;AAAA;AAEJ;;;;"}
|
package/dist/plugin/html.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}) => React.JSX.Element;
|
|
2
|
+
import type { HtmlProps } from "./types.js";
|
|
3
|
+
export declare const Html: ({ children, CssCollector, cssFiles, globalCss, }: React.PropsWithChildren<HtmlProps>) => React.JSX.Element;
|
|
5
4
|
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../plugin/html.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../plugin/html.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,IAAI,qDAKd,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,sBAWpC,CAAC"}
|
package/dist/plugin/html.js
CHANGED
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import React__default from 'react';
|
|
7
|
+
import { CssCollectorElements } from './css-collector-elements.js';
|
|
7
8
|
|
|
8
|
-
const Html = ({
|
|
9
|
+
const Html = ({
|
|
10
|
+
children,
|
|
11
|
+
CssCollector,
|
|
12
|
+
cssFiles,
|
|
13
|
+
globalCss
|
|
14
|
+
}) => /* @__PURE__ */ React__default.createElement("html", null, /* @__PURE__ */ React__default.createElement("head", null, /* @__PURE__ */ React__default.createElement(CssCollectorElements, { cssFiles: globalCss })), /* @__PURE__ */ React__default.createElement("body", null, /* @__PURE__ */ React__default.createElement(CssCollector, { as: "div", id: "root", cssFiles }, children)));
|
|
9
15
|
|
|
10
16
|
export { Html };
|
|
11
17
|
//# sourceMappingURL=html.js.map
|
package/dist/plugin/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sources":["../../plugin/html.tsx"],"sourcesContent":["import React from \"react\";\nexport const Html = ({
|
|
1
|
+
{"version":3,"file":"html.js","sources":["../../plugin/html.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HtmlProps } from \"./types.js\";\nimport { CssCollectorElements } from \"./css-collector-elements.js\";\nexport const Html = ({\n children,\n CssCollector,\n cssFiles,\n globalCss,\n}: React.PropsWithChildren<HtmlProps>) => (\n <html>\n <head>\n <CssCollectorElements cssFiles={globalCss} />\n </head>\n <body>\n <CssCollector as={\"div\"} id=\"root\" cssFiles={cssFiles}>\n {children}\n </CssCollector>\n </body>\n </html>\n);\n"],"names":["React"],"mappings":";;;;;;;;AAGO,MAAM,OAAO,CAAC;AAAA,EACnB,QAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CACE,qBAAAA,cAAA,CAAA,aAAA,CAAC,8BACEA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,+CACE,oBAAqB,EAAA,EAAA,QAAA,EAAU,WAAW,CAC7C,CAAA,+CACC,MACC,EAAA,IAAA,kBAAAA,cAAA,CAAA,aAAA,CAAC,gBAAa,EAAI,EAAA,KAAA,EAAO,IAAG,MAAO,EAAA,QAAA,EAAA,EAChC,QACH,CACF,CACF;;;;"}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../plugin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../plugin/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAQ,qBAAqB,KAA6C,CAAC"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,13 +1,35 @@
|
|
|
1
|
-
import type { PluginContext } from "rollup";
|
|
2
1
|
import type { ResolvedUserConfig, ResolvedUserOptions } from "../../server.js";
|
|
3
2
|
import type { Manifest } from "vite";
|
|
3
|
+
import type { OutputBundle } from "rollup";
|
|
4
4
|
export interface BuildLoaderOptions {
|
|
5
|
-
root: string;
|
|
6
|
-
pluginContext: PluginContext;
|
|
7
5
|
userConfig: ResolvedUserConfig;
|
|
8
6
|
userOptions: ResolvedUserOptions;
|
|
9
7
|
serverManifest: Manifest;
|
|
10
8
|
clientManifest: Manifest;
|
|
9
|
+
staticManifest: Manifest;
|
|
11
10
|
}
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Creates a loader function for handling module resolution during build.
|
|
13
|
+
*
|
|
14
|
+
* The loader handles the following strategy:
|
|
15
|
+
* - Just load any file from any manifest we can find in the order of client, server, static
|
|
16
|
+
* - Ideally the buildLoader is only used form loading pages, props and inline css modules
|
|
17
|
+
* -
|
|
18
|
+
*
|
|
19
|
+
* During build:
|
|
20
|
+
* - We use the manifest information to get module exports
|
|
21
|
+
* - The manifest contains the transformed modules with their exports
|
|
22
|
+
* - We store the module in temporaryReferences for later use
|
|
23
|
+
*
|
|
24
|
+
* @param options.root - The project root directory
|
|
25
|
+
* @param options.pluginContext - The Rollup plugin context
|
|
26
|
+
* @param options.userConfig - Resolved user configuration
|
|
27
|
+
* @param options.userOptions - Resolved user options
|
|
28
|
+
* @param options.serverManifest - Vite server manifest
|
|
29
|
+
* @param options.clientManifest - Vite client manifest
|
|
30
|
+
* @param options.options - Additional options including temporaryReferences
|
|
31
|
+
*
|
|
32
|
+
* @returns A loader function that resolves module paths to their exports
|
|
33
|
+
*/
|
|
34
|
+
export declare function createBuildLoader({ userOptions, serverManifest, clientManifest, staticManifest, }: BuildLoaderOptions, bundle: OutputBundle): Promise<(id: string) => Promise<any>>;
|
|
13
35
|
//# sourceMappingURL=createBuildLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"createBuildLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createBuildLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3C,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,WAAW,EAAE,mBAAmB,CAAC;IACjC,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,iBAAiB,CACrC,EACE,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,GACf,EAAE,kBAAkB,EACrB,MAAM,EAAE,YAAY,gBAMkB,MAAM,mBAuH7C"}
|
|
@@ -4,49 +4,114 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import {
|
|
7
|
+
import { getModuleRef } from '../moduleRefs.js';
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import { temporaryReferences } from './temporaryReferences.js';
|
|
8
10
|
|
|
9
|
-
function createBuildLoader({
|
|
10
|
-
root,
|
|
11
|
-
userConfig: _userConfig,
|
|
11
|
+
async function createBuildLoader({
|
|
12
12
|
userOptions,
|
|
13
|
-
pluginContext: _pluginContext,
|
|
14
13
|
serverManifest,
|
|
15
|
-
clientManifest
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
14
|
+
clientManifest,
|
|
15
|
+
staticManifest
|
|
16
|
+
}, bundle) {
|
|
17
|
+
const manifestKeys = Object.keys(serverManifest);
|
|
18
|
+
if (!manifestKeys.length) {
|
|
19
|
+
throw new Error("Server manifest is empty");
|
|
20
|
+
}
|
|
22
21
|
return async function buildLoader(id) {
|
|
23
|
-
const [
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const [withoutQuery, query] = id.split("?", 2);
|
|
23
|
+
const [, normalizedValue] = userOptions.normalizer(withoutQuery);
|
|
24
|
+
const moduleRef = getModuleRef(id);
|
|
25
|
+
if (temporaryReferences?.has(moduleRef)) {
|
|
26
|
+
const mod = temporaryReferences.get(moduleRef);
|
|
27
|
+
if (typeof mod === "object" && mod !== null && "error" in mod) ; else {
|
|
28
|
+
return mod;
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
try {
|
|
32
|
+
if (query === "inline") {
|
|
33
|
+
const serverChunk = bundle[serverManifest[normalizedValue]?.file] ?? bundle[staticManifest[normalizedValue]?.file] ?? bundle[clientManifest[normalizedValue]?.file] ?? bundle[withoutQuery];
|
|
34
|
+
if (serverChunk) {
|
|
35
|
+
if (serverChunk.type === "asset") {
|
|
36
|
+
return { default: serverChunk.source };
|
|
37
|
+
} else if ("code" in serverChunk) {
|
|
38
|
+
return { default: serverChunk.code };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const module = {
|
|
42
|
+
default: await readFile(
|
|
43
|
+
join(
|
|
44
|
+
userOptions.projectRoot,
|
|
45
|
+
userOptions.build.outDir,
|
|
46
|
+
userOptions.build.static,
|
|
47
|
+
normalizedValue
|
|
48
|
+
),
|
|
49
|
+
"utf-8"
|
|
50
|
+
)
|
|
51
|
+
};
|
|
52
|
+
temporaryReferences?.set(moduleRef, module);
|
|
53
|
+
return module;
|
|
54
|
+
}
|
|
55
|
+
const clientEntry = clientManifest[normalizedValue];
|
|
56
|
+
if (clientEntry) {
|
|
57
|
+
const module = await import(join(
|
|
58
|
+
userOptions.projectRoot,
|
|
59
|
+
userOptions.build.outDir,
|
|
60
|
+
userOptions.build.client,
|
|
61
|
+
clientEntry.file
|
|
62
|
+
));
|
|
63
|
+
console.warn(
|
|
64
|
+
"client module used in buildLoader, consider making this available in the server manifest",
|
|
65
|
+
module
|
|
66
|
+
);
|
|
67
|
+
temporaryReferences?.set(moduleRef, module);
|
|
68
|
+
return module;
|
|
34
69
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
const bundleEntry = bundle[withoutQuery];
|
|
71
|
+
if (bundleEntry) {
|
|
72
|
+
const module = await import(join(
|
|
73
|
+
userOptions.projectRoot,
|
|
74
|
+
userOptions.build.outDir,
|
|
75
|
+
userOptions.build.server,
|
|
76
|
+
bundleEntry.fileName
|
|
77
|
+
));
|
|
78
|
+
temporaryReferences?.set(moduleRef, module);
|
|
40
79
|
}
|
|
41
|
-
|
|
42
|
-
|
|
80
|
+
const serverEntry = serverManifest[normalizedValue];
|
|
81
|
+
if (serverEntry) {
|
|
82
|
+
const module = await import(join(
|
|
83
|
+
userOptions.projectRoot,
|
|
84
|
+
userOptions.build.outDir,
|
|
85
|
+
userOptions.build.server,
|
|
86
|
+
serverEntry.file
|
|
87
|
+
));
|
|
88
|
+
temporaryReferences?.set(moduleRef, module);
|
|
89
|
+
return module;
|
|
43
90
|
}
|
|
44
|
-
|
|
45
|
-
|
|
91
|
+
const staticEntry = staticManifest[normalizedValue];
|
|
92
|
+
if (staticEntry) {
|
|
93
|
+
const module = await import(join(
|
|
94
|
+
userOptions.projectRoot,
|
|
95
|
+
userOptions.build.outDir,
|
|
96
|
+
userOptions.build.static,
|
|
97
|
+
staticEntry.file
|
|
98
|
+
));
|
|
99
|
+
console.warn(
|
|
100
|
+
"static module used in buildLoader, consider making this available in the server manifest",
|
|
101
|
+
module
|
|
102
|
+
);
|
|
103
|
+
temporaryReferences?.set(moduleRef, module);
|
|
104
|
+
return module;
|
|
46
105
|
}
|
|
47
|
-
|
|
106
|
+
throw new Error(`Module ${normalizedValue} not found`);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const emptyExports = {
|
|
109
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
110
|
+
id
|
|
111
|
+
};
|
|
112
|
+
temporaryReferences?.set(moduleRef, emptyExports);
|
|
113
|
+
return emptyExports;
|
|
48
114
|
}
|
|
49
|
-
throw new Error(`Module not found: ${id}`);
|
|
50
115
|
};
|
|
51
116
|
}
|
|
52
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type {
|
|
1
|
+
{"version":3,"file":"createBuildLoader.js","sources":["../../../plugin/loader/createBuildLoader.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type { ResolvedUserConfig, ResolvedUserOptions } from \"../../server.js\";\nimport type { Manifest } from \"vite\";\nimport { getModuleRef } from \"../moduleRefs.js\";\nimport { readFile } from \"node:fs/promises\";\nimport type { OutputBundle } from \"rollup\";\nimport { temporaryReferences } from \"./temporaryReferences.js\";\n\nexport interface BuildLoaderOptions {\n userConfig: ResolvedUserConfig;\n userOptions: ResolvedUserOptions;\n serverManifest: Manifest;\n clientManifest: Manifest;\n staticManifest: Manifest;\n}\n\n/**\n * Creates a loader function for handling module resolution during build.\n *\n * The loader handles the following strategy:\n * - Just load any file from any manifest we can find in the order of client, server, static\n * - Ideally the buildLoader is only used form loading pages, props and inline css modules\n * -\n *\n * During build:\n * - We use the manifest information to get module exports\n * - The manifest contains the transformed modules with their exports\n * - We store the module in temporaryReferences for later use\n *\n * @param options.root - The project root directory\n * @param options.pluginContext - The Rollup plugin context\n * @param options.userConfig - Resolved user configuration\n * @param options.userOptions - Resolved user options\n * @param options.serverManifest - Vite server manifest\n * @param options.clientManifest - Vite client manifest\n * @param options.options - Additional options including temporaryReferences\n *\n * @returns A loader function that resolves module paths to their exports\n */\nexport async function createBuildLoader(\n {\n userOptions,\n serverManifest,\n clientManifest,\n staticManifest,\n }: BuildLoaderOptions,\n bundle: OutputBundle\n) {\n const manifestKeys = Object.keys(serverManifest);\n if (!manifestKeys.length) {\n throw new Error(\"Server manifest is empty\");\n }\n return async function buildLoader(id: string) {\n const [withoutQuery, query] = id.split(\"?\", 2);\n const [, normalizedValue] = userOptions.normalizer(withoutQuery);\n const moduleRef = getModuleRef(id);\n // Check if we have a temporary reference (cached module)\n if (temporaryReferences?.has(moduleRef)) {\n const mod = temporaryReferences.get(moduleRef);\n if (typeof mod === \"object\" && mod !== null && \"error\" in mod) {\n // ignore it\n } else {\n return mod;\n }\n }\n\n try {\n // For inline modules, handle them directly\n if (query === \"inline\") {\n // Then check server manifest\n const serverChunk =\n bundle[serverManifest[normalizedValue]?.file] ??\n bundle[staticManifest[normalizedValue]?.file] ??\n bundle[clientManifest[normalizedValue]?.file] ??\n bundle[withoutQuery];\n if (serverChunk) {\n if (serverChunk.type === \"asset\") {\n return { default: serverChunk.source };\n } else if (\"code\" in serverChunk) {\n return { default: serverChunk.code };\n }\n }\n\n // If not found in either manifest, try reading the file directly\n const module = {\n default: await readFile(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n normalizedValue\n ),\n \"utf-8\"\n ),\n };\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n const clientEntry = clientManifest[normalizedValue];\n if (clientEntry) {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.client,\n clientEntry.file\n )\n );\n console.warn(\n \"client module used in buildLoader, consider making this available in the server manifest\",\n module\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n const bundleEntry = bundle[withoutQuery];\n if (bundleEntry) {\n // Load the module\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n bundleEntry.fileName\n )\n );\n temporaryReferences?.set(moduleRef, module);\n }\n // Try to resolve the module using Vite's resolution\n const serverEntry = serverManifest[normalizedValue];\n if (serverEntry) {\n // Load the module\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.server,\n serverEntry.file\n )\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n // try static manifest\n const staticEntry = staticManifest[normalizedValue];\n if (staticEntry) {\n const module = await import(\n join(\n userOptions.projectRoot,\n userOptions.build.outDir,\n userOptions.build.static,\n staticEntry.file\n )\n );\n console.warn(\n \"static module used in buildLoader, consider making this available in the server manifest\",\n module\n );\n temporaryReferences?.set(moduleRef, module);\n return module;\n }\n throw new Error(`Module ${normalizedValue} not found`);\n } catch (error) {\n const emptyExports = {\n error: error instanceof Error ? error : new Error(String(error)),\n id: id,\n };\n temporaryReferences?.set(moduleRef, emptyExports);\n return emptyExports;\n }\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuCA,eAAsB,iBACpB,CAAA;AAAA,EACE,WAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA,EACA,MACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,MAAO,CAAA,IAAA,CAAK,cAAc,CAAA;AAC/C,EAAI,IAAA,CAAC,aAAa,MAAQ,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAE5C,EAAO,OAAA,eAAe,YAAY,EAAY,EAAA;AAC5C,IAAA,MAAM,CAAC,YAAc,EAAA,KAAK,IAAI,EAAG,CAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AAC7C,IAAA,MAAM,GAAG,eAAe,CAAI,GAAA,WAAA,CAAY,WAAW,YAAY,CAAA;AAC/D,IAAM,MAAA,SAAA,GAAY,aAAa,EAAE,CAAA;AAEjC,IAAI,IAAA,mBAAA,EAAqB,GAAI,CAAA,SAAS,CAAG,EAAA;AACvC,MAAM,MAAA,GAAA,GAAM,mBAAoB,CAAA,GAAA,CAAI,SAAS,CAAA;AAC7C,MAAA,IAAI,OAAO,GAAQ,KAAA,QAAA,IAAY,GAAQ,KAAA,IAAA,IAAQ,WAAW,GAAK,EAAA,CAExD,MAAA;AACL,QAAO,OAAA,GAAA;AAAA;AACT;AAGF,IAAI,IAAA;AAEF,MAAA,IAAI,UAAU,QAAU,EAAA;AAEtB,QAAM,MAAA,WAAA,GACJ,OAAO,cAAe,CAAA,eAAe,GAAG,IAAI,CAAA,IAC5C,OAAO,cAAe,CAAA,eAAe,GAAG,IAAI,CAAA,IAC5C,OAAO,cAAe,CAAA,eAAe,GAAG,IAAI,CAAA,IAC5C,OAAO,YAAY,CAAA;AACrB,QAAA,IAAI,WA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