vite-plugin-react-server 1.1.12 → 1.1.14
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/dist/package.json +12 -8
- package/dist/plugin/components/css-collector-elements.d.ts +4 -2
- package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
- package/dist/plugin/components/css-collector-elements.js +21 -7
- package/dist/plugin/components/css-collector-elements.js.map +1 -1
- package/dist/plugin/components/css-collector.d.ts +4 -5
- package/dist/plugin/components/css-collector.d.ts.map +1 -1
- package/dist/plugin/components/css-collector.js +5 -9
- package/dist/plugin/components/css-collector.js.map +1 -1
- package/dist/plugin/components/html.d.ts +1 -1
- package/dist/plugin/components/html.d.ts.map +1 -1
- package/dist/plugin/components/html.js +14 -3
- package/dist/plugin/components/html.js.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +66 -12
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +69 -15
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +16 -5
- package/dist/plugin/config/resolveEnv.js.map +1 -1
- package/dist/plugin/config/resolveOptions.d.ts +3 -3
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +144 -135
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +8 -1
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/error/toError.d.ts +3 -0
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +32 -4
- package/dist/plugin/error/toError.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
- package/dist/plugin/helpers/cleanObject.js +19 -5
- package/dist/plugin/helpers/cleanObject.js.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.js +3 -5
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts +4 -3
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +11 -27
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createHandler.d.ts +4 -3
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +1 -1
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +2 -2
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +16 -5
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/index.d.ts +2 -2
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +2 -2
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +4 -1
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
- package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
- package/dist/plugin/helpers/moduleResolver.js +25 -0
- package/dist/plugin/helpers/requestInfo.d.ts +18 -3
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +75 -11
- package/dist/plugin/helpers/requestInfo.js.map +1 -1
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePage.js +2 -3
- package/dist/plugin/helpers/resolvePage.js.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +13 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
- package/dist/plugin/helpers/sourceMap.d.ts +8 -0
- package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
- package/dist/plugin/helpers/sourceMap.js +136 -0
- package/dist/plugin/helpers.js +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createDefaultLoader.js +111 -0
- package/dist/plugin/loader/css-loader.development.d.ts +3 -15
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +17 -16
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.production.js +1 -1
- package/dist/plugin/loader/css-loader.production.js.map +1 -1
- package/dist/plugin/loader/env-loader.development.d.ts +1 -0
- package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/env-loader.development.js +17 -9
- package/dist/plugin/loader/handleExports.d.ts +34 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -0
- package/dist/plugin/loader/handleExports.js +193 -0
- package/dist/plugin/loader/handleExports.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +1 -1
- package/dist/plugin/loader/index.d.ts.map +1 -1
- package/dist/plugin/loader/index.js +4 -1
- package/dist/plugin/loader/parse.d.ts +6 -0
- package/dist/plugin/loader/parse.d.ts.map +1 -0
- package/dist/plugin/loader/parse.js +23 -0
- package/dist/plugin/loader/parse.js.map +1 -0
- package/dist/plugin/loader/react-loader.client.d.ts +2 -0
- package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.client.js +2 -0
- package/dist/plugin/loader/react-loader.d.ts +1 -12
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +5 -687
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.server.d.ts +21 -0
- package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.server.js +131 -0
- package/dist/plugin/loader/sourceMap.d.ts +35 -0
- package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
- package/dist/plugin/loader/sourceMap.js +105 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +125 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
- package/dist/plugin/loader/types.d.ts +8 -0
- package/dist/plugin/loader/types.d.ts.map +1 -0
- package/dist/plugin/loader/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +2 -2
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +1 -3
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/plugin.server.d.ts +2 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +2 -2
- package/dist/plugin/plugin.server.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts +2 -2
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +6 -2
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
- package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +96 -14
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
- package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +21 -11
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +72 -27
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +21 -4
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts +2 -2
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +7 -8
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +11 -4
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
- package/dist/plugin/react-server/{server.js → configureReactServer.js} +27 -10
- package/dist/plugin/react-server/configureReactServer.js.map +1 -0
- package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
- package/dist/plugin/react-server/handleServerAction.js +129 -0
- package/dist/plugin/react-server/handleServerAction.js.map +1 -0
- package/dist/plugin/react-server/plugin.d.ts +2 -2
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +1 -1
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
- package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +18 -7
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.d.ts +20 -0
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
- package/dist/plugin/react-static/createBuildLoader.js +135 -0
- package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +2 -2
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +36 -23
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +2 -2
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js.map +1 -1
- package/dist/plugin/react-static/renderPages.d.ts +2 -2
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js.map +1 -1
- package/dist/plugin/react-static/renderStreams.d.ts +2 -2
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +4 -4
- package/dist/plugin/react-static/renderStreams.js.map +1 -1
- package/dist/plugin/react-static/temporaryReferences.d.ts +2 -0
- package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
- package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
- package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
- package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
- package/dist/plugin/source-map/readMappings.d.ts +2 -0
- package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
- package/dist/plugin/source-map/readMappings.js +201 -0
- package/dist/plugin/transformer/index.d.ts +0 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +0 -1
- package/dist/plugin/transformer/plugin.client.d.ts +1 -3
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +1 -84
- package/dist/plugin/transformer/plugin.server.d.ts +2 -2
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +52 -20
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/types.d.ts +100 -119
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/utils/callServer.d.ts +1 -1
- package/dist/plugin/utils/callServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.d.ts +1 -1
- package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.js +13 -4
- package/dist/plugin/utils/createCallServer.js.map +1 -1
- package/dist/plugin/utils/index.d.ts +1 -0
- package/dist/plugin/utils/index.d.ts.map +1 -1
- package/dist/plugin/utils/index.js +1 -0
- package/dist/plugin/utils.js +1 -0
- package/dist/plugin/utils.js.map +1 -1
- package/dist/plugin/vendor/vendor.client.d.ts +2 -1
- package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.client.js +2 -1
- package/dist/plugin/vendor/vendor.client.js.map +1 -1
- package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.server.js +1 -1
- package/dist/plugin/vendor/vendor.server.js.map +1 -1
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +17 -22
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +15 -13
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +2 -12
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +2 -2
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +9 -8
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handlers.js +223 -0
- package/dist/plugin/worker/rsc/handlers.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +64 -110
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +110 -53
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +6 -66
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +6 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/userOptions.js +17 -0
- package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
- package/dist/plugin/worker/sendMessage.d.ts +2 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +2 -1
- package/dist/plugin/worker/sendMessage.js.map +1 -1
- package/dist/plugin/worker/types.d.ts +53 -53
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -8
- package/plugin/components/css-collector-elements.tsx +30 -9
- package/plugin/components/css-collector.tsx +13 -22
- package/plugin/components/html.tsx +12 -5
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
- package/plugin/config/defaults.tsx +75 -16
- package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
- package/plugin/config/resolveEnv.ts +20 -12
- package/plugin/config/resolveOptions.ts +238 -207
- package/plugin/config/resolveUserConfig.ts +20 -5
- package/plugin/error/toError.ts +33 -1
- package/plugin/helpers/cleanObject.ts +79 -15
- package/plugin/helpers/collectManifestCss.ts +2 -6
- package/plugin/helpers/collectViteModuleGraphCss.ts +10 -3
- package/plugin/helpers/createCssProps.tsx +26 -38
- package/plugin/helpers/createHandler.ts +7 -4
- package/plugin/helpers/createRscStream.tsx +21 -14
- package/plugin/helpers/index.ts +2 -2
- package/plugin/helpers/inputNormalizer.ts +4 -2
- package/plugin/helpers/moduleResolver.ts +36 -0
- package/plugin/helpers/requestInfo.ts +117 -23
- package/plugin/helpers/resolvePage.ts +2 -3
- package/plugin/helpers/resolvePageAndProps.ts +7 -6
- package/plugin/helpers/serializeUserOptions.ts +20 -2
- package/plugin/helpers/sourceMap.ts +182 -0
- package/plugin/loader/createDefaultLoader.ts +138 -0
- package/plugin/loader/css-loader.development.ts +19 -35
- package/plugin/loader/css-loader.production.ts +2 -4
- package/plugin/loader/env-loader.development.ts +38 -15
- package/plugin/loader/handleExports.ts +299 -0
- package/plugin/loader/index.ts +6 -1
- package/plugin/loader/parse.ts +22 -0
- package/plugin/loader/react-loader.client.ts +1 -0
- package/plugin/loader/react-loader.server.ts +185 -0
- package/plugin/loader/react-loader.ts +4 -1002
- package/plugin/loader/sourceMap.ts +118 -0
- package/plugin/loader/transformModuleIfNeeded.ts +33 -0
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +226 -0
- package/plugin/loader/types.ts +10 -0
- package/plugin/plugin.client.ts +16 -11
- package/plugin/plugin.server.ts +6 -3
- package/plugin/preserver/plugin.ts +37 -17
- package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +128 -15
- package/plugin/react-client/createMessageHandlers.ts +24 -13
- package/plugin/react-client/createWorkerStream.ts +85 -33
- package/plugin/react-client/handleWorkerRscStream.ts +24 -5
- package/plugin/react-client/plugin.ts +18 -13
- package/plugin/react-client/restartWorker.ts +18 -5
- package/plugin/react-server/{server.ts → configureReactServer.ts} +41 -11
- package/plugin/react-server/handleServerAction.ts +159 -0
- package/plugin/react-server/plugin.ts +8 -3
- package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
- package/plugin/react-static/collectRscContent.ts +17 -9
- package/plugin/react-static/configurePreviewServer.ts +37 -17
- package/plugin/react-static/createBuildLoader.ts +194 -0
- package/plugin/react-static/plugin.ts +53 -33
- package/plugin/react-static/renderPage.ts +12 -6
- package/plugin/react-static/renderPages.ts +15 -4
- package/plugin/react-static/renderStreams.ts +13 -12
- package/plugin/source-map/createMappingsSerializer.ts +182 -0
- package/plugin/source-map/readMappings.ts +195 -0
- package/plugin/transformer/README.md +295 -29
- package/plugin/transformer/index.ts +0 -1
- package/plugin/transformer/plugin.client.ts +0 -111
- package/plugin/transformer/plugin.server.ts +94 -25
- package/plugin/types/react-server-dom-esm.d.ts +183 -24
- package/plugin/types/sourceMap.d.ts +2 -0
- package/plugin/types/webpack-sources.d.ts +24 -0
- package/plugin/types.ts +192 -132
- package/plugin/utils/createCallServer.ts +21 -6
- package/plugin/utils/index.ts +2 -1
- package/plugin/vendor/vendor.client.ts +2 -1
- package/plugin/vendor/vendor.server.ts +1 -1
- package/plugin/worker/createWorker.ts +21 -24
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
- package/plugin/worker/html/html-worker.development.tsx +16 -16
- package/plugin/worker/html/html-worker.production.tsx +3 -19
- package/plugin/worker/html/messageHandler.tsx +2 -4
- package/plugin/worker/rsc/handleRender.ts +16 -12
- package/plugin/worker/rsc/handlers.ts +243 -0
- package/plugin/worker/rsc/messageHandler.tsx +79 -122
- package/plugin/worker/rsc/rsc-worker.development.ts +145 -77
- package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
- package/plugin/worker/rsc/state.ts +12 -6
- package/plugin/worker/rsc/userOptions.ts +8 -0
- package/plugin/worker/sendMessage.ts +32 -14
- package/plugin/worker/types.ts +101 -64
- package/dist/plugin/loader/createBuildLoader.d.ts +0 -35
- package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createBuildLoader.js +0 -121
- package/dist/plugin/loader/createBuildLoader.js.map +0 -1
- package/dist/plugin/loader/plugin.d.ts +0 -22
- package/dist/plugin/loader/plugin.d.ts.map +0 -1
- package/dist/plugin/loader/plugin.js +0 -27
- package/dist/plugin/loader/temporaryReferences.d.ts +0 -2
- package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
- package/dist/plugin/loader/temporaryReferences.js.map +0 -1
- package/dist/plugin/react-client/server.d.ts.map +0 -1
- package/dist/plugin/react-client/server.js.map +0 -1
- package/dist/plugin/react-server/server.d.ts +0 -9
- package/dist/plugin/react-server/server.d.ts.map +0 -1
- package/dist/plugin/react-server/server.js.map +0 -1
- package/dist/plugin/transformer/plugin.client.js.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
- package/dist/plugin/worker/loader.d.ts +0 -5
- package/dist/plugin/worker/loader.d.ts.map +0 -1
- package/dist/plugin/worker/loader.js +0 -11
- package/dist/plugin/worker/loader.js.map +0 -1
- package/plugin/loader/createBuildLoader.ts +0 -174
- package/plugin/loader/plugin.ts +0 -33
- package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
- package/plugin/worker/loader.ts +0 -7
- /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
- /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ResolvedUserConfig,
|
|
4
4
|
ResolvedUserOptions,
|
|
5
5
|
AutoDiscoveredFiles,
|
|
6
|
+
PagePropOpt,
|
|
7
|
+
InlineCssOpt,
|
|
6
8
|
} from "../types.js";
|
|
7
9
|
import { join } from "node:path";
|
|
8
10
|
import type { OutputOptions, PreRenderedAsset, PreRenderedChunk } from "rollup";
|
|
@@ -10,11 +12,14 @@ import { DEFAULT_CONFIG } from "./defaults.js";
|
|
|
10
12
|
|
|
11
13
|
let stashedUserConfig: Record<string, ResolvedUserConfig | null> = {};
|
|
12
14
|
|
|
13
|
-
export type ResolveUserConfigProps
|
|
15
|
+
export type ResolveUserConfigProps<
|
|
16
|
+
T extends PagePropOpt = PagePropOpt,
|
|
17
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
18
|
+
> = {
|
|
14
19
|
condition: "react-client" | "react-server";
|
|
15
20
|
config: UserConfig;
|
|
16
21
|
configEnv: ConfigEnv;
|
|
17
|
-
userOptions: ResolvedUserOptions
|
|
22
|
+
userOptions: ResolvedUserOptions<T, InlineCSS>;
|
|
18
23
|
autoDiscoveredFiles: Pick<AutoDiscoveredFiles, "inputs" | "staticManifest">;
|
|
19
24
|
};
|
|
20
25
|
|
|
@@ -22,13 +27,16 @@ export type ResolveUserConfigReturn =
|
|
|
22
27
|
| { type: "success"; userConfig: ResolvedUserConfig }
|
|
23
28
|
| { type: "error"; error: Error };
|
|
24
29
|
|
|
25
|
-
export function resolveUserConfig
|
|
30
|
+
export function resolveUserConfig<
|
|
31
|
+
T extends PagePropOpt = PagePropOpt,
|
|
32
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
33
|
+
>({
|
|
26
34
|
condition,
|
|
27
35
|
config,
|
|
28
36
|
configEnv,
|
|
29
37
|
userOptions,
|
|
30
38
|
autoDiscoveredFiles,
|
|
31
|
-
}: ResolveUserConfigProps): ResolveUserConfigReturn {
|
|
39
|
+
}: ResolveUserConfigProps<T, InlineCSS>): ResolveUserConfigReturn {
|
|
32
40
|
const ssr =
|
|
33
41
|
typeof config.build?.ssr === "boolean"
|
|
34
42
|
? config.build?.ssr
|
|
@@ -62,6 +70,9 @@ export function resolveUserConfig({
|
|
|
62
70
|
fallback: (info: T, ssr: boolean) => string,
|
|
63
71
|
ssr: boolean
|
|
64
72
|
) => {
|
|
73
|
+
if ("source" in info && info.source === "") {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
65
76
|
if (!ssr || !input) {
|
|
66
77
|
return fallback(info, false);
|
|
67
78
|
}
|
|
@@ -234,6 +245,7 @@ export function resolveUserConfig({
|
|
|
234
245
|
// client build options
|
|
235
246
|
build: {
|
|
236
247
|
...config.build,
|
|
248
|
+
modulePreload: config.build?.modulePreload ?? false,
|
|
237
249
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
238
250
|
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
239
251
|
assetsDir: config.build?.assetsDir ?? userOptions.build.assetsDir,
|
|
@@ -246,7 +258,9 @@ export function resolveUserConfig({
|
|
|
246
258
|
minify: minify,
|
|
247
259
|
rollupOptions: {
|
|
248
260
|
...config.build?.rollupOptions,
|
|
249
|
-
input:
|
|
261
|
+
input: {
|
|
262
|
+
...autoDiscoveredFiles.inputs,
|
|
263
|
+
},
|
|
250
264
|
output: newOutput,
|
|
251
265
|
preserveEntrySignatures:
|
|
252
266
|
config.build?.rollupOptions?.preserveEntrySignatures ??
|
|
@@ -285,6 +299,7 @@ export function resolveUserConfig({
|
|
|
285
299
|
// server build options
|
|
286
300
|
build: {
|
|
287
301
|
...config.build,
|
|
302
|
+
modulePreload: config.build?.modulePreload ?? false,
|
|
288
303
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
289
304
|
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
290
305
|
target: config.build?.target ?? "node18",
|
package/plugin/error/toError.ts
CHANGED
|
@@ -1,19 +1,51 @@
|
|
|
1
|
+
import type { Logger } from "vite";
|
|
2
|
+
|
|
1
3
|
export function toError(error: unknown): {
|
|
2
4
|
name: string;
|
|
3
5
|
message: string;
|
|
4
6
|
stack?: string;
|
|
7
|
+
cause?: unknown;
|
|
5
8
|
} {
|
|
9
|
+
if(typeof error === "string") {
|
|
10
|
+
return {
|
|
11
|
+
name: "Error",
|
|
12
|
+
message: error,
|
|
13
|
+
stack: undefined,
|
|
14
|
+
cause: undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
return error instanceof Error
|
|
7
18
|
? error
|
|
8
19
|
: typeof error === "object" && error !== null
|
|
9
20
|
? {
|
|
10
21
|
name: "name" in error ? String(error.name) : "Unknown Error",
|
|
11
|
-
message: "message" in error ?
|
|
22
|
+
message: "message" in error ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : "Unknown Error",
|
|
12
23
|
stack: "stack" in error ? String(error.stack) : undefined,
|
|
24
|
+
cause: "cause" in error ? toError(error.cause) : error,
|
|
13
25
|
}
|
|
14
26
|
: {
|
|
15
27
|
name: "Unknown Error",
|
|
16
28
|
message: typeof error === "string" ? error : "Unknown Error",
|
|
17
29
|
stack: undefined,
|
|
30
|
+
cause: error,
|
|
18
31
|
};
|
|
19
32
|
}
|
|
33
|
+
|
|
34
|
+
export function logError(error: unknown, logger: Logger | Console = console) {
|
|
35
|
+
const err = toError(error);
|
|
36
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
37
|
+
if (err.stack && err.stack.includes(err.message)) {
|
|
38
|
+
logger.error(err.stack);
|
|
39
|
+
} else if (err.stack) {
|
|
40
|
+
logger.error(err.message + "\n" + err.stack, {
|
|
41
|
+
error: err,
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
logger.error(err.message, {
|
|
45
|
+
error: err,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
logger.error(err.message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,44 +1,105 @@
|
|
|
1
1
|
import type { SerializableRecord } from "../types.js";
|
|
2
2
|
|
|
3
3
|
// Helper function to serialize RegExp objects
|
|
4
|
-
function serializeRegExp(regex: RegExp): {
|
|
4
|
+
function serializeRegExp(regex: RegExp): {
|
|
5
|
+
source: string;
|
|
6
|
+
flags: string;
|
|
7
|
+
__isRegExp: boolean;
|
|
8
|
+
} {
|
|
5
9
|
return {
|
|
6
10
|
source: regex.source,
|
|
7
11
|
flags: regex.flags,
|
|
8
|
-
__isRegExp: true
|
|
12
|
+
__isRegExp: true,
|
|
9
13
|
};
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const isSerializable = (
|
|
17
|
+
x: unknown
|
|
18
|
+
): x is
|
|
19
|
+
| number
|
|
20
|
+
| bigint
|
|
21
|
+
| boolean
|
|
22
|
+
| string
|
|
23
|
+
| undefined
|
|
24
|
+
| null
|
|
25
|
+
| Uint8Array
|
|
26
|
+
| Uint16Array
|
|
27
|
+
| Uint32Array
|
|
28
|
+
| Int8Array
|
|
29
|
+
| Int16Array
|
|
30
|
+
| Int32Array => {
|
|
31
|
+
return (
|
|
32
|
+
typeof x === "number" ||
|
|
33
|
+
typeof x === "bigint" ||
|
|
34
|
+
typeof x === "boolean" ||
|
|
35
|
+
typeof x === "string" ||
|
|
36
|
+
x instanceof Buffer ||
|
|
37
|
+
(Array.isArray(x) &&
|
|
38
|
+
(!x.length ||
|
|
39
|
+
x instanceof Uint8Array ||
|
|
40
|
+
x instanceof Uint16Array ||
|
|
41
|
+
x instanceof Uint32Array ||
|
|
42
|
+
x instanceof Int8Array ||
|
|
43
|
+
x instanceof Int16Array ||
|
|
44
|
+
x instanceof Int32Array))
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export function cleanObject<T>(
|
|
49
|
+
obj: T,
|
|
50
|
+
knownNonSerializableFunctions: Set<string> = new Set(),
|
|
51
|
+
currentPath: string = ""
|
|
52
|
+
): SerializableRecord & T {
|
|
53
|
+
if (typeof obj !== "object" || obj == null) return obj as Extract<SerializableRecord, T>;
|
|
54
|
+
if (isSerializable(obj)) return obj as Extract<SerializableRecord, T>;
|
|
55
|
+
|
|
16
56
|
if (Array.isArray(obj)) {
|
|
17
|
-
return obj
|
|
57
|
+
return obj
|
|
58
|
+
.map((x, i) =>
|
|
59
|
+
cleanObject(x, knownNonSerializableFunctions, `${currentPath}[${i}]`)
|
|
60
|
+
)
|
|
61
|
+
.filter((x) => x !== undefined) as Extract<SerializableRecord, T>;
|
|
18
62
|
}
|
|
19
|
-
|
|
63
|
+
if (obj instanceof RegExp)
|
|
64
|
+
return serializeRegExp(obj) as unknown as Extract<SerializableRecord, T>;
|
|
65
|
+
|
|
20
66
|
const result: Record<string, any> = {};
|
|
21
67
|
for (const [key, value] of Object.entries(obj)) {
|
|
22
68
|
const fullPath = currentPath ? `${currentPath}.${key}` : key;
|
|
23
|
-
const normalizedPath = fullPath.replace(/\[\d+\]/g,
|
|
69
|
+
const normalizedPath = fullPath.replace(/\[\d+\]/g, "[]");
|
|
24
70
|
// Skip if it's a function or known non-serializable property
|
|
25
|
-
if
|
|
71
|
+
if(isSerializable(value)) {
|
|
72
|
+
result[key] = value;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
typeof value === "function" ||
|
|
77
|
+
knownNonSerializableFunctions.has(normalizedPath) ||
|
|
78
|
+
knownNonSerializableFunctions.has(key)
|
|
79
|
+
) {
|
|
26
80
|
continue;
|
|
27
81
|
}
|
|
28
82
|
|
|
29
83
|
// Handle nested objects
|
|
30
|
-
if (typeof value ===
|
|
84
|
+
if (typeof value === "object" && value !== null) {
|
|
31
85
|
// Check if the object has any functions
|
|
32
86
|
const hasFunctions = Object.entries(value).some(([k, v]) => {
|
|
33
87
|
const nestedPath = `${normalizedPath}.${k}`;
|
|
34
|
-
return
|
|
88
|
+
return (
|
|
89
|
+
typeof v === "function" ||
|
|
90
|
+
knownNonSerializableFunctions.has(nestedPath)
|
|
91
|
+
);
|
|
35
92
|
});
|
|
36
93
|
|
|
37
94
|
if (hasFunctions) {
|
|
38
95
|
continue;
|
|
39
96
|
}
|
|
40
97
|
|
|
41
|
-
const cleaned = cleanObject(
|
|
98
|
+
const cleaned = cleanObject(
|
|
99
|
+
value,
|
|
100
|
+
knownNonSerializableFunctions,
|
|
101
|
+
`${normalizedPath}.${key}`
|
|
102
|
+
);
|
|
42
103
|
if (cleaned !== undefined && Object.keys(cleaned).length > 0) {
|
|
43
104
|
result[key] = cleaned;
|
|
44
105
|
}
|
|
@@ -46,5 +107,8 @@ export function cleanObject<T>(obj: T, knownNonSerializableFunctions: Set<string
|
|
|
46
107
|
result[key] = value;
|
|
47
108
|
}
|
|
48
109
|
}
|
|
49
|
-
return (Object.keys(result).length > 0 ? result : {}) as Extract<
|
|
50
|
-
|
|
110
|
+
return (Object.keys(result).length > 0 ? result : {}) as Extract<
|
|
111
|
+
SerializableRecord,
|
|
112
|
+
T
|
|
113
|
+
>;
|
|
114
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Manifest } from "vite";
|
|
2
|
-
import type { ResolvedUserOptions } from "../types.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Collects CSS file paths from a manifest by walking through imports starting from a given file
|
|
@@ -7,7 +6,6 @@ import type { ResolvedUserOptions } from "../types.js";
|
|
|
7
6
|
export function collectManifestCss(
|
|
8
7
|
manifest: Manifest,
|
|
9
8
|
startFile: string | string[],
|
|
10
|
-
userOptions: Pick<ResolvedUserOptions, "normalizer">
|
|
11
9
|
): Record<string, string> {
|
|
12
10
|
const cssInputs: Record<string, string> = {};
|
|
13
11
|
const visited = new Set<string>();
|
|
@@ -29,8 +27,7 @@ export function collectManifestCss(
|
|
|
29
27
|
// Add CSS files from the css property
|
|
30
28
|
if (fileInfo.css) {
|
|
31
29
|
for (const cssFile of fileInfo.css) {
|
|
32
|
-
|
|
33
|
-
cssInputs[keyNormalized] = valueNormalized;
|
|
30
|
+
cssInputs[cssFile] = cssFile + '.css';
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
|
|
@@ -49,8 +46,7 @@ export function collectManifestCss(
|
|
|
49
46
|
const importedFile = manifest[importPath];
|
|
50
47
|
if (importedFile?.css) {
|
|
51
48
|
for (const cssFile of importedFile.css) {
|
|
52
|
-
|
|
53
|
-
cssInputs[keyNormalized] = valueNormalized;
|
|
49
|
+
cssInputs[cssFile] = cssFile + '.css';
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnvironmentModuleGraph, ModuleGraph } from "vite";
|
|
2
|
-
import type { CreateHandlerOptions, CssContent } from "../types.js";
|
|
2
|
+
import type { CreateHandlerOptions, CssContent, InlineCssOpt, PagePropOpt } from "../types.js";
|
|
3
3
|
import { createCssProps } from "./createCssProps.js";
|
|
4
4
|
|
|
5
5
|
type CollectViteModuleGraphCssResult =
|
|
@@ -29,7 +29,8 @@ type CollectViteModuleGraphCssResult =
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export async function collectViteModuleGraphCss<
|
|
32
|
-
|
|
32
|
+
T extends PagePropOpt = PagePropOpt,
|
|
33
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
33
34
|
>({
|
|
34
35
|
moduleGraph,
|
|
35
36
|
onCss,
|
|
@@ -40,7 +41,7 @@ export async function collectViteModuleGraphCss<
|
|
|
40
41
|
onCss?: (cssContent: CssContent, parentUrl: string) => void;
|
|
41
42
|
parentUrl?: string;
|
|
42
43
|
handlerOptions: Pick<
|
|
43
|
-
CreateHandlerOptions<InlineCSS>,
|
|
44
|
+
CreateHandlerOptions<T, InlineCSS>,
|
|
44
45
|
| "pagePath"
|
|
45
46
|
| "moduleBaseURL"
|
|
46
47
|
| "moduleBasePath"
|
|
@@ -48,6 +49,8 @@ export async function collectViteModuleGraphCss<
|
|
|
48
49
|
| "projectRoot"
|
|
49
50
|
| "css"
|
|
50
51
|
| "loader"
|
|
52
|
+
| "normalizer"
|
|
53
|
+
| "moduleID"
|
|
51
54
|
>;
|
|
52
55
|
}): Promise<CollectViteModuleGraphCssResult> {
|
|
53
56
|
const {
|
|
@@ -58,6 +61,8 @@ export async function collectViteModuleGraphCss<
|
|
|
58
61
|
projectRoot,
|
|
59
62
|
css,
|
|
60
63
|
loader,
|
|
64
|
+
normalizer,
|
|
65
|
+
moduleID,
|
|
61
66
|
} = handlerOptions;
|
|
62
67
|
if (!pagePath) return { type: "skip" };
|
|
63
68
|
|
|
@@ -106,6 +111,8 @@ export async function collectViteModuleGraphCss<
|
|
|
106
111
|
moduleRootPath: moduleRootPath,
|
|
107
112
|
projectRoot: projectRoot,
|
|
108
113
|
css: css,
|
|
114
|
+
normalizer: normalizer,
|
|
115
|
+
moduleID: moduleID,
|
|
109
116
|
},
|
|
110
117
|
});
|
|
111
118
|
cssFiles.set(mod?.url, cssContent);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResolvedUserOptions, CssContent } from "../types.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { InlineCssOpt, PagePropOpt } from "../../server.js";
|
|
3
|
+
import { join } from "node:path";
|
|
3
4
|
import { deserializeRegExp } from "./serializeUserOptions.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -21,7 +22,10 @@ import { deserializeRegExp } from "./serializeUserOptions.js";
|
|
|
21
22
|
* @param css - The css options
|
|
22
23
|
* @returns A CssContent object
|
|
23
24
|
*/
|
|
24
|
-
export const createCssProps =
|
|
25
|
+
export const createCssProps = <
|
|
26
|
+
T extends PagePropOpt = PagePropOpt,
|
|
27
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
28
|
+
>({
|
|
25
29
|
id,
|
|
26
30
|
code,
|
|
27
31
|
userOptions,
|
|
@@ -29,29 +33,26 @@ export const createCssProps = ({
|
|
|
29
33
|
id: string;
|
|
30
34
|
code: string;
|
|
31
35
|
userOptions: Pick<
|
|
32
|
-
ResolvedUserOptions,
|
|
36
|
+
ResolvedUserOptions<T, InlineCSS>,
|
|
33
37
|
| "css"
|
|
34
38
|
| "moduleBaseURL"
|
|
35
39
|
| "moduleBasePath"
|
|
36
40
|
| "moduleRootPath"
|
|
37
41
|
| "projectRoot"
|
|
42
|
+
| "normalizer"
|
|
43
|
+
| "moduleID"
|
|
38
44
|
>;
|
|
39
|
-
}): CssContent => {
|
|
40
|
-
const { css,
|
|
41
|
-
userOptions;
|
|
45
|
+
}): CssContent<InlineCSS> => {
|
|
46
|
+
const { css, moduleRootPath } = userOptions;
|
|
42
47
|
// If we don't have a bundle entry, create a linked CSS file
|
|
43
48
|
let inline = typeof code === "string" && code.length > css.inlineThreshold;
|
|
44
49
|
// Normalize the ID to be relative to src/
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
: id;
|
|
48
|
-
|
|
50
|
+
const [, value] = userOptions.normalizer(id);
|
|
51
|
+
const moduleID = userOptions.moduleID(value);
|
|
49
52
|
if (css.inlinePatterns?.length) {
|
|
50
53
|
// Deserialize RegExp patterns if they exist
|
|
51
|
-
const inlinePatterns = css.inlinePatterns
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {
|
|
54
|
+
const inlinePatterns = css.inlinePatterns;
|
|
55
|
+
if (inlinePatterns.some((pattern) => pattern.test?.(id))) {
|
|
55
56
|
inline = true;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -59,46 +60,33 @@ export const createCssProps = ({
|
|
|
59
60
|
const linkPatterns = css.linkPatterns?.map((pattern) =>
|
|
60
61
|
typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
|
|
61
62
|
);
|
|
62
|
-
if (linkPatterns.some((pattern) => pattern.test?.(
|
|
63
|
+
if (linkPatterns.some((pattern) => pattern.test?.(id))) {
|
|
63
64
|
inline = false;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
if (inline) {
|
|
67
68
|
return {
|
|
68
69
|
type: "text/css",
|
|
69
|
-
id:
|
|
70
|
+
id: moduleID,
|
|
70
71
|
as: "style",
|
|
71
72
|
children: code.trim(),
|
|
72
73
|
...(process.env["NODE_ENV"] !== "production"
|
|
73
74
|
? {
|
|
74
|
-
"data-vite-dev-id": join(
|
|
75
|
+
"data-vite-dev-id": join(moduleRootPath, moduleID),
|
|
75
76
|
}
|
|
76
77
|
: {}),
|
|
77
|
-
} as CssContent<
|
|
78
|
+
} as CssContent<InlineCSS>;
|
|
78
79
|
}
|
|
79
|
-
const joined = normalizedId.startsWith(moduleBasePath) ? normalizedId : join(moduleBasePath, normalizedId);
|
|
80
|
-
const moduleBaseHasTrailingSlash = moduleBaseURL.endsWith("/");
|
|
81
|
-
const joinedHasLeadingSlash = joined.startsWith("/");
|
|
82
|
-
const safeParseURL = (() => {
|
|
83
|
-
if(joined.startsWith(moduleBaseHasTrailingSlash ? moduleBaseURL.slice(0, -1) : moduleBaseURL)) {
|
|
84
|
-
return joined;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
if (moduleBaseURL.includes("//")) {
|
|
88
|
-
// relative to moduleBaseURL
|
|
89
|
-
return new URL(joinedHasLeadingSlash ? joined.slice(1) : joined, moduleBaseURL).href;
|
|
90
|
-
}
|
|
91
|
-
} catch (error) {}
|
|
92
|
-
// if the url is not valid, we return the moduleBaseURL + the normalizedId
|
|
93
|
-
// dont make it a argument of join or it will mangle something like http:// into http:/
|
|
94
|
-
return moduleBaseURL + (!moduleBaseHasTrailingSlash && !joinedHasLeadingSlash ? "/" : "") + (moduleBaseHasTrailingSlash ? joined.slice(1) : joined);
|
|
95
|
-
})();
|
|
96
80
|
// Default case
|
|
97
81
|
return {
|
|
98
|
-
id:
|
|
82
|
+
id: moduleID,
|
|
99
83
|
as: "link",
|
|
100
84
|
rel: "stylesheet",
|
|
101
|
-
href:
|
|
85
|
+
href:
|
|
86
|
+
typeof process.env.VITE_PUBLIC_ORIGIN === "string" &&
|
|
87
|
+
process.env.VITE_PUBLIC_ORIGIN !== ""
|
|
88
|
+
? new URL(moduleID, process.env.VITE_PUBLIC_ORIGIN).href
|
|
89
|
+
: moduleID,
|
|
102
90
|
precedence: "high",
|
|
103
|
-
} as CssContent<
|
|
91
|
+
} as CssContent<InlineCSS>;
|
|
104
92
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { CreateHandlerOptions } from "../types.js";
|
|
1
|
+
import type { CreateHandlerOptions, InlineCssOpt } from "../types.js";
|
|
2
|
+
import type { PagePropOpt } from "../../server.js";
|
|
2
3
|
import { createRscStream } from "./createRscStream.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export function createHandler<
|
|
6
|
+
T extends PagePropOpt = PagePropOpt,
|
|
7
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
8
|
+
>(handlerOptions: CreateHandlerOptions<T, InlineCSS>) {
|
|
9
|
+
if (!handlerOptions.PageComponent) {
|
|
7
10
|
throw new Error("PageComponent is required");
|
|
8
11
|
}
|
|
9
12
|
try {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { React, ReactDOMServer } from "../vendor/vendor.server.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
CreateHandlerOptions,
|
|
4
|
+
StreamMetrics,
|
|
5
|
+
PagePropOpt,
|
|
6
|
+
} from "../types.js";
|
|
3
7
|
import { performance } from "node:perf_hooks";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
C extends React.ComponentType<T>,
|
|
7
|
-
InlineCSS extends boolean = true
|
|
8
|
-
>({
|
|
8
|
+
|
|
9
|
+
export function createRscStream<T extends PagePropOpt = PagePropOpt>({
|
|
9
10
|
Html = React.Fragment,
|
|
10
11
|
PageComponent,
|
|
11
12
|
pageProps,
|
|
@@ -22,7 +23,7 @@ export function createRscStream<
|
|
|
22
23
|
onEvent,
|
|
23
24
|
projectRoot,
|
|
24
25
|
}: Pick<
|
|
25
|
-
CreateHandlerOptions<T
|
|
26
|
+
CreateHandlerOptions<T>,
|
|
26
27
|
| "Html"
|
|
27
28
|
| "PageComponent"
|
|
28
29
|
| "pageProps"
|
|
@@ -46,7 +47,7 @@ export function createRscStream<
|
|
|
46
47
|
let streamError: Error | null = null;
|
|
47
48
|
const startTime = performance.now();
|
|
48
49
|
try {
|
|
49
|
-
const htmlIsFragment = Html
|
|
50
|
+
const htmlIsFragment = Html === React.Fragment;
|
|
50
51
|
const url = route.startsWith(moduleBaseURL) ? route : moduleBaseURL + route;
|
|
51
52
|
|
|
52
53
|
if (!PageComponent) {
|
|
@@ -64,10 +65,15 @@ export function createRscStream<
|
|
|
64
65
|
},
|
|
65
66
|
};
|
|
66
67
|
}
|
|
68
|
+
|
|
67
69
|
const elements = htmlIsFragment ? (
|
|
68
|
-
<CssCollector
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
<CssCollector
|
|
71
|
+
key={route}
|
|
72
|
+
as={React.Fragment}
|
|
73
|
+
cssFiles={cssFiles}
|
|
74
|
+
pageProps={pageProps}
|
|
75
|
+
Page={PageComponent}
|
|
76
|
+
/>
|
|
71
77
|
) : (
|
|
72
78
|
<Html
|
|
73
79
|
moduleBase={moduleBase}
|
|
@@ -82,15 +88,16 @@ export function createRscStream<
|
|
|
82
88
|
globalCss={globalCss}
|
|
83
89
|
CssCollector={CssCollector}
|
|
84
90
|
manifest={manifest}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
Page={PageComponent}
|
|
92
|
+
as={"div"}
|
|
93
|
+
/>
|
|
88
94
|
);
|
|
89
95
|
const stream = ReactDOMServer.renderToPipeableStream(
|
|
90
96
|
elements,
|
|
91
97
|
moduleBasePath,
|
|
92
98
|
{
|
|
93
99
|
...pipeableStreamOptions,
|
|
100
|
+
moduleBaseURL: moduleBaseURL,
|
|
94
101
|
onError(error: Error, errorInfo: any) {
|
|
95
102
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
96
103
|
streamError = err;
|
package/plugin/helpers/index.ts
CHANGED
|
@@ -15,10 +15,10 @@ export * from "./inputNormalizer.js";
|
|
|
15
15
|
export * from "./collectBundleManifestCss.js";
|
|
16
16
|
export * from "./collectManifestCss.js";
|
|
17
17
|
export * from "./collectViteModuleGraphCss.js";
|
|
18
|
-
export * from "./createCssProps.
|
|
18
|
+
export * from "./createCssProps.js";
|
|
19
19
|
|
|
20
20
|
// Stream and handler creation
|
|
21
|
-
export * from "./createRscStream.
|
|
21
|
+
export * from "./createRscStream.js";
|
|
22
22
|
export * from "./createHandler.js";
|
|
23
23
|
export * from "./createEventHandler.js";
|
|
24
24
|
|
|
@@ -180,7 +180,7 @@ export function createInputNormalizer({
|
|
|
180
180
|
root,
|
|
181
181
|
moduleBasePath,
|
|
182
182
|
preserveModulesRoot = undefined,
|
|
183
|
-
removeExtension = DEFAULT_CONFIG.
|
|
183
|
+
removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension,
|
|
184
184
|
}: CreateInputNormalizerProps): InputNormalizer {
|
|
185
185
|
if (stashedNormalizer) {
|
|
186
186
|
return stashedNormalizer;
|
|
@@ -246,7 +246,9 @@ export function createInputNormalizer({
|
|
|
246
246
|
? virtualPrefix[0] + normalizedPath
|
|
247
247
|
: normalizedPath
|
|
248
248
|
: normalizedPath;
|
|
249
|
-
|
|
249
|
+
if(virtualPrefix){
|
|
250
|
+
return ['', ''];
|
|
251
|
+
}
|
|
250
252
|
return [key, finalPath];
|
|
251
253
|
};
|
|
252
254
|
return stashedNormalizer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
let stashedResolve: any = null;
|
|
2
|
+
|
|
3
|
+
export function setStashedResolve(resolve: any) {
|
|
4
|
+
stashedResolve = resolve;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function resolveClientImport(specifier: string, parentURL: string) {
|
|
8
|
+
const conditions = ["node", "import"];
|
|
9
|
+
|
|
10
|
+
if (stashedResolve === null) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"Expected resolve to have been called before transformSource"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const result = await stashedResolve(
|
|
18
|
+
specifier,
|
|
19
|
+
{
|
|
20
|
+
conditions,
|
|
21
|
+
parentURL,
|
|
22
|
+
},
|
|
23
|
+
stashedResolve
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (!result) {
|
|
27
|
+
console.warn(`Failed to resolve import: ${specifier}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`Error resolving import ${specifier}:`, error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|