vite-plugin-react-server 1.1.12 → 1.1.13
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 +10 -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 +59 -87
- 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 +33 -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/collectViteModuleGraphCss.d.ts +3 -3
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- 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 +7 -2
- 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 +15 -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/createBuildLoader.d.ts +7 -22
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +79 -65
- package/dist/plugin/loader/createBuildLoader.js.map +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 +47 -0
- package/dist/plugin/loader/css-loader.development.d.ts +1 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +1 -1
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/handleExports.d.ts +33 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -0
- package/dist/plugin/loader/handleExports.js +174 -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 +69 -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/temporaryReferences.d.ts +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -1
- 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 +52 -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 +2 -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} +11 -8
- 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 +18 -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 +61 -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 +14 -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 +9 -3
- 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} +26 -8
- 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 +145 -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/plugin.d.ts +2 -2
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +28 -12
- 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/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 +89 -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 +8 -8
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +166 -107
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +112 -52
- 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 +5 -64
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +5 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- 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 +52 -53
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -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 +72 -16
- package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
- package/plugin/config/resolveEnv.ts +20 -12
- package/plugin/config/resolveOptions.ts +152 -155
- package/plugin/config/resolveUserConfig.ts +20 -5
- package/plugin/error/toError.ts +35 -1
- package/plugin/helpers/cleanObject.ts +79 -15
- package/plugin/helpers/collectViteModuleGraphCss.ts +4 -3
- package/plugin/helpers/createCssProps.tsx +26 -9
- package/plugin/helpers/createHandler.ts +7 -4
- package/plugin/helpers/createRscStream.tsx +20 -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/createBuildLoader.ts +124 -104
- package/plugin/loader/createDefaultLoader.ts +62 -0
- package/plugin/loader/css-loader.development.ts +3 -2
- package/plugin/loader/handleExports.ts +276 -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 +107 -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 +119 -0
- package/plugin/loader/types.ts +10 -0
- package/plugin/plugin.client.ts +18 -11
- package/plugin/plugin.server.ts +6 -3
- package/plugin/preserver/plugin.ts +37 -17
- package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +22 -12
- package/plugin/react-client/createMessageHandlers.ts +21 -13
- package/plugin/react-client/createWorkerStream.ts +71 -33
- package/plugin/react-client/handleWorkerRscStream.ts +15 -5
- package/plugin/react-client/plugin.ts +18 -13
- package/plugin/react-client/restartWorker.ts +17 -5
- package/plugin/react-server/{server.ts → configureReactServer.ts} +40 -9
- package/plugin/react-server/handleServerAction.ts +177 -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/plugin.ts +45 -22
- 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 +169 -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 +15 -12
- package/plugin/worker/rsc/messageHandler.tsx +191 -120
- package/plugin/worker/rsc/rsc-worker.development.ts +148 -77
- package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
- package/plugin/worker/rsc/state.ts +10 -0
- package/plugin/worker/sendMessage.ts +32 -14
- package/plugin/worker/types.ts +99 -64
- 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/transformer/upgradeCssModuleCode.ts +0 -42
- package/plugin/worker/loader.ts +0 -7
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// alternative to webpack-sources/lib/helpers/createMappingsSerializer.js
|
|
2
|
+
// unused for now, but it's a dependency of react-server-dom-esm and you may or may not want to download webpack-sources
|
|
3
|
+
export function createMappingsSerializer() {
|
|
4
|
+
let generatedLine = 1;
|
|
5
|
+
let generatedColumn = 0;
|
|
6
|
+
let sourceIndex = 0;
|
|
7
|
+
let originalLine = 1;
|
|
8
|
+
let originalColumn = 0;
|
|
9
|
+
let nameIndex = 0;
|
|
10
|
+
let mappings = "";
|
|
11
|
+
return function serializeMapping(newGeneratedLine, newGeneratedColumn, newSourceIndex, newOriginalLine, newOriginalColumn, newNameIndex) {
|
|
12
|
+
if (newGeneratedLine !== generatedLine) {
|
|
13
|
+
generatedLine = newGeneratedLine;
|
|
14
|
+
generatedColumn = newGeneratedColumn;
|
|
15
|
+
if (mappings) {
|
|
16
|
+
mappings += ";";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (mappings) {
|
|
20
|
+
mappings += ",";
|
|
21
|
+
}
|
|
22
|
+
// Encode the generated column.
|
|
23
|
+
let value = newGeneratedColumn - generatedColumn;
|
|
24
|
+
generatedColumn = newGeneratedColumn;
|
|
25
|
+
let isNegative = value < 0;
|
|
26
|
+
if (isNegative) {
|
|
27
|
+
value = -value;
|
|
28
|
+
}
|
|
29
|
+
value = value << 1;
|
|
30
|
+
if (isNegative) {
|
|
31
|
+
value = value | 1;
|
|
32
|
+
}
|
|
33
|
+
while (value > 0) {
|
|
34
|
+
let digit = value & 63;
|
|
35
|
+
value = value >>> 6;
|
|
36
|
+
if (value > 0) {
|
|
37
|
+
digit = digit | 64;
|
|
38
|
+
}
|
|
39
|
+
mappings += String.fromCharCode(digit < 26
|
|
40
|
+
? digit + 65
|
|
41
|
+
: digit < 52
|
|
42
|
+
? digit + 97 - 26
|
|
43
|
+
: digit < 62
|
|
44
|
+
? digit + 48 - 52
|
|
45
|
+
: digit === 62
|
|
46
|
+
? 43
|
|
47
|
+
: 47);
|
|
48
|
+
}
|
|
49
|
+
// Encode the source index.
|
|
50
|
+
value = newSourceIndex - sourceIndex;
|
|
51
|
+
sourceIndex = newSourceIndex;
|
|
52
|
+
isNegative = value < 0;
|
|
53
|
+
if (isNegative) {
|
|
54
|
+
value = -value;
|
|
55
|
+
}
|
|
56
|
+
value = value << 1;
|
|
57
|
+
if (isNegative) {
|
|
58
|
+
value = value | 1;
|
|
59
|
+
}
|
|
60
|
+
while (value > 0) {
|
|
61
|
+
let digit = value & 63;
|
|
62
|
+
value = value >>> 6;
|
|
63
|
+
if (value > 0) {
|
|
64
|
+
digit = digit | 64;
|
|
65
|
+
}
|
|
66
|
+
mappings += String.fromCharCode(digit < 26
|
|
67
|
+
? digit + 65
|
|
68
|
+
: digit < 52
|
|
69
|
+
? digit + 97 - 26
|
|
70
|
+
: digit < 62
|
|
71
|
+
? digit + 48 - 52
|
|
72
|
+
: digit === 62
|
|
73
|
+
? 43
|
|
74
|
+
: 47);
|
|
75
|
+
}
|
|
76
|
+
// Encode the original line.
|
|
77
|
+
value = newOriginalLine - originalLine;
|
|
78
|
+
originalLine = newOriginalLine;
|
|
79
|
+
isNegative = value < 0;
|
|
80
|
+
if (isNegative) {
|
|
81
|
+
value = -value;
|
|
82
|
+
}
|
|
83
|
+
value = value << 1;
|
|
84
|
+
if (isNegative) {
|
|
85
|
+
value = value | 1;
|
|
86
|
+
}
|
|
87
|
+
while (value > 0) {
|
|
88
|
+
let digit = value & 63;
|
|
89
|
+
value = value >>> 6;
|
|
90
|
+
if (value > 0) {
|
|
91
|
+
digit = digit | 64;
|
|
92
|
+
}
|
|
93
|
+
mappings += String.fromCharCode(digit < 26
|
|
94
|
+
? digit + 65
|
|
95
|
+
: digit < 52
|
|
96
|
+
? digit + 97 - 26
|
|
97
|
+
: digit < 62
|
|
98
|
+
? digit + 48 - 52
|
|
99
|
+
: digit === 62
|
|
100
|
+
? 43
|
|
101
|
+
: 47);
|
|
102
|
+
}
|
|
103
|
+
// Encode the original column.
|
|
104
|
+
value = newOriginalColumn - originalColumn;
|
|
105
|
+
originalColumn = newOriginalColumn;
|
|
106
|
+
isNegative = value < 0;
|
|
107
|
+
if (isNegative) {
|
|
108
|
+
value = -value;
|
|
109
|
+
}
|
|
110
|
+
value = value << 1;
|
|
111
|
+
if (isNegative) {
|
|
112
|
+
value = value | 1;
|
|
113
|
+
}
|
|
114
|
+
while (value > 0) {
|
|
115
|
+
let digit = value & 63;
|
|
116
|
+
value = value >>> 6;
|
|
117
|
+
if (value > 0) {
|
|
118
|
+
digit = digit | 64;
|
|
119
|
+
}
|
|
120
|
+
mappings += String.fromCharCode(digit < 26
|
|
121
|
+
? digit + 65
|
|
122
|
+
: digit < 52
|
|
123
|
+
? digit + 97 - 26
|
|
124
|
+
: digit < 62
|
|
125
|
+
? digit + 48 - 52
|
|
126
|
+
: digit === 62
|
|
127
|
+
? 43
|
|
128
|
+
: 47);
|
|
129
|
+
}
|
|
130
|
+
// Encode the name index.
|
|
131
|
+
value = newNameIndex - nameIndex;
|
|
132
|
+
nameIndex = newNameIndex;
|
|
133
|
+
isNegative = value < 0;
|
|
134
|
+
if (isNegative) {
|
|
135
|
+
value = -value;
|
|
136
|
+
}
|
|
137
|
+
value = value << 1;
|
|
138
|
+
if (isNegative) {
|
|
139
|
+
value = value | 1;
|
|
140
|
+
}
|
|
141
|
+
while (value > 0) {
|
|
142
|
+
let digit = value & 63;
|
|
143
|
+
value = value >>> 6;
|
|
144
|
+
if (value > 0) {
|
|
145
|
+
digit = digit | 64;
|
|
146
|
+
}
|
|
147
|
+
mappings += String.fromCharCode(digit < 26
|
|
148
|
+
? digit + 65
|
|
149
|
+
: digit < 52
|
|
150
|
+
? digit + 97 - 26
|
|
151
|
+
: digit < 62
|
|
152
|
+
? digit + 48 - 52
|
|
153
|
+
: digit === 62
|
|
154
|
+
? 43
|
|
155
|
+
: 47);
|
|
156
|
+
}
|
|
157
|
+
return mappings;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readMappings.d.ts","sourceRoot":"","sources":["../../../plugin/source-map/readMappings.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CACT,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,KACd,IAAI,QAuLV"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// alternative to webpack-sources/lib/helpers/readMappings.js
|
|
2
|
+
// unused for now, but it's a dependency of react-server-dom-esm and you may or may not want to download webpack-sources
|
|
3
|
+
export function readMappings(mappings, onMapping) {
|
|
4
|
+
let generatedLine = 1;
|
|
5
|
+
let generatedColumn = 0;
|
|
6
|
+
let sourceIndex = 0;
|
|
7
|
+
let originalLine = 1;
|
|
8
|
+
let originalColumn = 0;
|
|
9
|
+
let nameIndex = 0;
|
|
10
|
+
let i = 0;
|
|
11
|
+
while (i < mappings.length) {
|
|
12
|
+
if (mappings[i] === ";") {
|
|
13
|
+
generatedLine++;
|
|
14
|
+
generatedColumn = 0;
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
else if (mappings[i] === ",") {
|
|
18
|
+
i++;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
let value = 0;
|
|
22
|
+
let shift = 0;
|
|
23
|
+
let hasMore = true;
|
|
24
|
+
while (hasMore) {
|
|
25
|
+
const c = mappings.charCodeAt(i++);
|
|
26
|
+
if (c >= 65 && c <= 90) {
|
|
27
|
+
value += (c - 65) << shift;
|
|
28
|
+
}
|
|
29
|
+
else if (c >= 97 && c <= 122) {
|
|
30
|
+
value += (c - 97) << shift;
|
|
31
|
+
}
|
|
32
|
+
else if (c >= 48 && c <= 57) {
|
|
33
|
+
value += (c - 48 + 26) << shift;
|
|
34
|
+
}
|
|
35
|
+
else if (c === 43) {
|
|
36
|
+
value += 62 << shift;
|
|
37
|
+
}
|
|
38
|
+
else if (c === 47) {
|
|
39
|
+
value += 63 << shift;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
hasMore = false;
|
|
43
|
+
}
|
|
44
|
+
if (hasMore) {
|
|
45
|
+
shift += 6;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
let isNegative = value & 1;
|
|
49
|
+
value = value >> 1;
|
|
50
|
+
if (isNegative) {
|
|
51
|
+
value = -value;
|
|
52
|
+
}
|
|
53
|
+
generatedColumn += value;
|
|
54
|
+
if (i < mappings.length && mappings[i] !== ";" && mappings[i] !== ",") {
|
|
55
|
+
value = 0;
|
|
56
|
+
shift = 0;
|
|
57
|
+
hasMore = true;
|
|
58
|
+
while (hasMore) {
|
|
59
|
+
const c = mappings.charCodeAt(i++);
|
|
60
|
+
if (c >= 65 && c <= 90) {
|
|
61
|
+
value += (c - 65) << shift;
|
|
62
|
+
}
|
|
63
|
+
else if (c >= 97 && c <= 122) {
|
|
64
|
+
value += (c - 97) << shift;
|
|
65
|
+
}
|
|
66
|
+
else if (c >= 48 && c <= 57) {
|
|
67
|
+
value += (c - 48 + 26) << shift;
|
|
68
|
+
}
|
|
69
|
+
else if (c === 43) {
|
|
70
|
+
value += 62 << shift;
|
|
71
|
+
}
|
|
72
|
+
else if (c === 47) {
|
|
73
|
+
value += 63 << shift;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
hasMore = false;
|
|
77
|
+
}
|
|
78
|
+
if (hasMore) {
|
|
79
|
+
shift += 6;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
isNegative = value & 1;
|
|
83
|
+
value = value >> 1;
|
|
84
|
+
if (isNegative) {
|
|
85
|
+
value = -value;
|
|
86
|
+
}
|
|
87
|
+
sourceIndex += value;
|
|
88
|
+
if (i < mappings.length && mappings[i] !== ";" && mappings[i] !== ",") {
|
|
89
|
+
value = 0;
|
|
90
|
+
shift = 0;
|
|
91
|
+
hasMore = true;
|
|
92
|
+
while (hasMore) {
|
|
93
|
+
const c = mappings.charCodeAt(i++);
|
|
94
|
+
if (c >= 65 && c <= 90) {
|
|
95
|
+
value += (c - 65) << shift;
|
|
96
|
+
}
|
|
97
|
+
else if (c >= 97 && c <= 122) {
|
|
98
|
+
value += (c - 97) << shift;
|
|
99
|
+
}
|
|
100
|
+
else if (c >= 48 && c <= 57) {
|
|
101
|
+
value += (c - 48 + 26) << shift;
|
|
102
|
+
}
|
|
103
|
+
else if (c === 43) {
|
|
104
|
+
value += 62 << shift;
|
|
105
|
+
}
|
|
106
|
+
else if (c === 47) {
|
|
107
|
+
value += 63 << shift;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
hasMore = false;
|
|
111
|
+
}
|
|
112
|
+
if (hasMore) {
|
|
113
|
+
shift += 6;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
isNegative = value & 1;
|
|
117
|
+
value = value >> 1;
|
|
118
|
+
if (isNegative) {
|
|
119
|
+
value = -value;
|
|
120
|
+
}
|
|
121
|
+
originalLine += value;
|
|
122
|
+
if (i < mappings.length &&
|
|
123
|
+
mappings[i] !== ";" &&
|
|
124
|
+
mappings[i] !== ",") {
|
|
125
|
+
value = 0;
|
|
126
|
+
shift = 0;
|
|
127
|
+
hasMore = true;
|
|
128
|
+
while (hasMore) {
|
|
129
|
+
const c = mappings.charCodeAt(i++);
|
|
130
|
+
if (c >= 65 && c <= 90) {
|
|
131
|
+
value += (c - 65) << shift;
|
|
132
|
+
}
|
|
133
|
+
else if (c >= 97 && c <= 122) {
|
|
134
|
+
value += (c - 97) << shift;
|
|
135
|
+
}
|
|
136
|
+
else if (c >= 48 && c <= 57) {
|
|
137
|
+
value += (c - 48 + 26) << shift;
|
|
138
|
+
}
|
|
139
|
+
else if (c === 43) {
|
|
140
|
+
value += 62 << shift;
|
|
141
|
+
}
|
|
142
|
+
else if (c === 47) {
|
|
143
|
+
value += 63 << shift;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
hasMore = false;
|
|
147
|
+
}
|
|
148
|
+
if (hasMore) {
|
|
149
|
+
shift += 6;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
isNegative = value & 1;
|
|
153
|
+
value = value >> 1;
|
|
154
|
+
if (isNegative) {
|
|
155
|
+
value = -value;
|
|
156
|
+
}
|
|
157
|
+
originalColumn += value;
|
|
158
|
+
if (i < mappings.length &&
|
|
159
|
+
mappings[i] !== ";" &&
|
|
160
|
+
mappings[i] !== ",") {
|
|
161
|
+
value = 0;
|
|
162
|
+
shift = 0;
|
|
163
|
+
hasMore = true;
|
|
164
|
+
while (hasMore) {
|
|
165
|
+
const c = mappings.charCodeAt(i++);
|
|
166
|
+
if (c >= 65 && c <= 90) {
|
|
167
|
+
value += (c - 65) << shift;
|
|
168
|
+
}
|
|
169
|
+
else if (c >= 97 && c <= 122) {
|
|
170
|
+
value += (c - 97) << shift;
|
|
171
|
+
}
|
|
172
|
+
else if (c >= 48 && c <= 57) {
|
|
173
|
+
value += (c - 48 + 26) << shift;
|
|
174
|
+
}
|
|
175
|
+
else if (c === 43) {
|
|
176
|
+
value += 62 << shift;
|
|
177
|
+
}
|
|
178
|
+
else if (c === 47) {
|
|
179
|
+
value += 63 << shift;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
hasMore = false;
|
|
183
|
+
}
|
|
184
|
+
if (hasMore) {
|
|
185
|
+
shift += 6;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
isNegative = value & 1;
|
|
189
|
+
value = value >> 1;
|
|
190
|
+
if (isNegative) {
|
|
191
|
+
value = -value;
|
|
192
|
+
}
|
|
193
|
+
nameIndex += value;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
onMapping(generatedLine, generatedColumn, sourceIndex, originalLine, originalColumn, nameIndex);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.client.ts"],"names":[],"mappings":""}
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { resolveOptions } from '../config/resolveOptions.js';
|
|
7
|
-
import 'vite';
|
|
8
|
-
import { transformModuleIfNeeded } from '../loader/react-loader.js';
|
|
9
|
-
import { join } from 'node:path';
|
|
10
|
-
import { tryManifest } from '../helpers/tryManifest.js';
|
|
11
|
-
|
|
12
|
-
let isBuild = true;
|
|
13
|
-
function reactTransformPlugin(options) {
|
|
14
|
-
let userOptions;
|
|
15
|
-
const resolvedOptionsResult = resolveOptions(options);
|
|
16
|
-
if (resolvedOptionsResult.type === "error") throw resolvedOptionsResult.error;
|
|
17
|
-
userOptions = resolvedOptionsResult.userOptions;
|
|
18
|
-
let staticManifest;
|
|
19
|
-
return {
|
|
20
|
-
name: "vite:react-server-action-transform",
|
|
21
|
-
enforce: "pre",
|
|
22
|
-
async config(_, configEnv) {
|
|
23
|
-
isBuild = configEnv.command !== "serve";
|
|
24
|
-
if (!configEnv.isSsrBuild) {
|
|
25
|
-
staticManifest = {};
|
|
26
|
-
} else {
|
|
27
|
-
const staticManifestResult = await tryManifest({
|
|
28
|
-
root: userOptions.projectRoot,
|
|
29
|
-
ssrManifest: false,
|
|
30
|
-
outDir: join(userOptions.build.outDir, userOptions.build.static)
|
|
31
|
-
});
|
|
32
|
-
if (staticManifestResult.type === "error") {
|
|
33
|
-
staticManifest = {};
|
|
34
|
-
} else {
|
|
35
|
-
staticManifest = staticManifestResult.manifest;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
async transform(code, id, options2) {
|
|
40
|
-
const ssr = options2?.ssr;
|
|
41
|
-
const isServer = code.match('"use server"') !== null;
|
|
42
|
-
const isClient = code.match('"use client"') !== null;
|
|
43
|
-
if (!ssr) return null;
|
|
44
|
-
if (!isServer && !isClient) return null;
|
|
45
|
-
if (isServer && isClient) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"Server and client components cannot be used in the same file"
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
if (isClient) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const [key, value] = userOptions.normalizer(id);
|
|
54
|
-
if (isServer && isBuild) {
|
|
55
|
-
id = key + ".js";
|
|
56
|
-
}
|
|
57
|
-
const finalID = userOptions.moduleID(value);
|
|
58
|
-
const transformed = await transformModuleIfNeeded(code, finalID, null);
|
|
59
|
-
if (!transformed) return null;
|
|
60
|
-
return {
|
|
61
|
-
code: transformed,
|
|
62
|
-
id: finalID,
|
|
63
|
-
map: null
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
renderChunk(code, chunk, _options) {
|
|
67
|
-
if (!chunk.fileName.includes(".client")) return null;
|
|
68
|
-
const originalName = chunk.fileName.replace(userOptions.autoDiscover.moduleExtension, "");
|
|
69
|
-
const manifestEntry = Object.entries(staticManifest).find(
|
|
70
|
-
([_, info]) => info.file.startsWith(originalName)
|
|
71
|
-
);
|
|
72
|
-
if (manifestEntry) {
|
|
73
|
-
return {
|
|
74
|
-
code,
|
|
75
|
-
fileName: manifestEntry[1].file
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { reactTransformPlugin };
|
|
84
|
-
//# sourceMappingURL=plugin.client.js.map
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
1
|
+
import type { InlineCssOpt, PagePropOpt, StreamPluginOptions } from "../types.js";
|
|
2
2
|
import type { Plugin } from "vite";
|
|
3
|
-
export declare function reactTransformPlugin(options: StreamPluginOptions): Plugin;
|
|
3
|
+
export declare function reactTransformPlugin<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(options: StreamPluginOptions<T, InlineCSS>): Plugin;
|
|
4
4
|
//# sourceMappingURL=plugin.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../../plugin/transformer/plugin.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EAEX,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,MAAM,CAAC;AAkC7C,wBAAgB,oBAAoB,CAClC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAC7C,OAAO,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,MAAM,CA6HpD"}
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { resolveOptions } from '../config/resolveOptions.js';
|
|
7
|
-
import { transformModuleIfNeeded } from '../loader/react-loader.js';
|
|
8
7
|
import { tryManifest } from '../helpers/tryManifest.js';
|
|
9
8
|
import { join } from 'node:path';
|
|
9
|
+
import { transformModuleIfNeeded } from '../loader/transformModuleIfNeeded.js';
|
|
10
10
|
|
|
11
11
|
let isBuild = true;
|
|
12
|
+
let isSSR = false;
|
|
12
13
|
function reactTransformPlugin(options) {
|
|
13
14
|
let userOptions;
|
|
14
15
|
const resolvedOptionsResult = resolveOptions(options);
|
|
@@ -17,11 +18,12 @@ function reactTransformPlugin(options) {
|
|
|
17
18
|
let staticManifest;
|
|
18
19
|
return {
|
|
19
20
|
name: "vite:react-server-transform",
|
|
20
|
-
enforce: "
|
|
21
|
-
// Run
|
|
22
|
-
async config
|
|
23
|
-
isBuild =
|
|
24
|
-
|
|
21
|
+
enforce: "post",
|
|
22
|
+
// Run after Vite's transforms
|
|
23
|
+
async configResolved(config) {
|
|
24
|
+
isBuild = config.command === "build";
|
|
25
|
+
isSSR = config.build?.ssr === true;
|
|
26
|
+
if (isBuild && isSSR) {
|
|
25
27
|
const staticManifestResult = await tryManifest({
|
|
26
28
|
root: userOptions.projectRoot,
|
|
27
29
|
ssrManifest: false,
|
|
@@ -33,16 +35,22 @@ function reactTransformPlugin(options) {
|
|
|
33
35
|
staticManifest = staticManifestResult.manifest;
|
|
34
36
|
}
|
|
35
37
|
},
|
|
38
|
+
async resolveId(_id, importer, options2) {
|
|
39
|
+
if (!options2?.ssr) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
},
|
|
36
44
|
async transform(code, id, options2) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!code.match('"use client"')) return null;
|
|
45
|
+
if (!options2?.ssr || !userOptions.autoDiscover.modulePattern(id)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
41
48
|
const [key, value] = userOptions.normalizer(id);
|
|
49
|
+
let moduleID = value;
|
|
42
50
|
if (isBuild) {
|
|
43
51
|
if (staticManifest) {
|
|
44
52
|
if (value in staticManifest) {
|
|
45
|
-
|
|
53
|
+
moduleID = staticManifest[value].file;
|
|
46
54
|
} else {
|
|
47
55
|
const hash = this.emitFile({
|
|
48
56
|
id,
|
|
@@ -51,24 +59,48 @@ function reactTransformPlugin(options) {
|
|
|
51
59
|
name: value
|
|
52
60
|
});
|
|
53
61
|
const fileName = this.getFileName(hash);
|
|
54
|
-
|
|
62
|
+
moduleID = fileName;
|
|
55
63
|
}
|
|
56
64
|
} else {
|
|
57
|
-
throw new Error(`
|
|
65
|
+
throw new Error(`Static manifest not found during dev build.`);
|
|
58
66
|
}
|
|
59
67
|
} else {
|
|
60
|
-
|
|
68
|
+
moduleID = join(userOptions.moduleBasePath, value);
|
|
61
69
|
}
|
|
62
|
-
|
|
70
|
+
let finalID = userOptions.moduleID(moduleID);
|
|
71
|
+
const transformed = transformModuleIfNeeded(
|
|
63
72
|
code,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
finalID,
|
|
74
|
+
userOptions.autoDiscover.isServerFunction(code),
|
|
75
|
+
userOptions.autoDiscover.isClientComponent(code),
|
|
76
|
+
true
|
|
67
77
|
);
|
|
68
|
-
if (
|
|
78
|
+
if (userOptions.verbose) {
|
|
79
|
+
if (transformed !== code) {
|
|
80
|
+
if (id !== finalID) {
|
|
81
|
+
this.environment.logger.info(
|
|
82
|
+
"[react-server-transform] " + id.split("/").pop() + " -> " + finalID
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
this.environment.logger.info(
|
|
86
|
+
"[react-server-transform] " + id.split("/").pop() + (code.startsWith('"use client"') ? " (client)" : "")
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
this.environment.logger.info(
|
|
90
|
+
"[react-server-transform] " + transformed
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!transformed) {
|
|
95
|
+
return {
|
|
96
|
+
id: finalID,
|
|
97
|
+
code: "",
|
|
98
|
+
map: null
|
|
99
|
+
};
|
|
100
|
+
}
|
|
69
101
|
return {
|
|
102
|
+
id: finalID,
|
|
70
103
|
code: transformed,
|
|
71
|
-
id,
|
|
72
104
|
map: null
|
|
73
105
|
};
|
|
74
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.server.js","sources":["../../../plugin/transformer/plugin.server.ts"],"sourcesContent":["import { resolveOptions } from \"../config/resolveOptions.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"plugin.server.js","sources":["../../../plugin/transformer/plugin.server.ts"],"sourcesContent":["import { resolveOptions } from \"../config/resolveOptions.js\";\nimport type {\n InlineCssOpt,\n PagePropOpt,\n ResolvedUserOptions,\n StreamPluginOptions,\n} from \"../types.js\";\nimport type { Manifest, Plugin } from \"vite\";\nimport { tryManifest } from \"../helpers/tryManifest.js\";\nimport { join } from \"node:path\";\nimport { setStashedResolve } from \"../helpers/moduleResolver.js\";\nimport { transformModuleIfNeeded } from \"../loader/transformModuleIfNeeded.js\";\nimport { logError } from \"../error/toError.js\";\n\n/**\n * Plugin for transforming React Client Components.\n *\n * Core responsibilities:\n * 1. Detects \"use client\" directives\n * 2. Transforms client components for RSC boundaries\n * 3. Adds client reference metadata for RSC\n *\n * When a component is marked with \"use client\", it:\n * - Gets transformed into a client reference\n * - Maintains module ID for RSC boundaries\n * - Preserves class/function behavior\n *\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [\n * viteReactClientTransformPlugin({\n * projectRoot: process.cwd(),\n * })\n * ]\n * });\n * ```\n */\nlet isBuild = true;\nlet isSSR = false;\n\nexport function reactTransformPlugin<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>(options: StreamPluginOptions<T, InlineCSS>): Plugin {\n let userOptions: ResolvedUserOptions<T, InlineCSS>;\n const resolvedOptionsResult = resolveOptions(options);\n if (resolvedOptionsResult.type === \"error\") throw resolvedOptionsResult.error;\n userOptions = resolvedOptionsResult.userOptions;\n\n let staticManifest: Manifest;\n\n return {\n name: \"vite:react-server-transform\",\n enforce: \"post\", // Run after Vite's transforms\n async configResolved(config) {\n isBuild = config.command === \"build\";\n isSSR = config.build?.ssr === true;\n if (isBuild && isSSR) {\n const staticManifestResult = await tryManifest({\n root: userOptions.projectRoot,\n ssrManifest: false,\n outDir: join(userOptions.build.outDir, userOptions.build.static),\n });\n if (staticManifestResult.type === \"error\") {\n throw staticManifestResult.error;\n }\n staticManifest = staticManifestResult.manifest;\n }\n },\n async resolveId(\n _id: string,\n importer: string | undefined,\n options: {\n attributes: Record<string, string>;\n custom?: any;\n ssr?: boolean;\n isEntry: boolean;\n }\n ) {\n if (!options?.ssr) {\n return null;\n }\n // Set stashedResolve before any transform operations\n setStashedResolve(async (specifier: string) => {\n try {\n const resolved = await this.resolve(specifier, importer, {\n custom: { conditions: [\"react-server\"] },\n });\n if (!resolved) return null;\n return { id: resolved.id };\n } catch (error) {\n logError(error, this.environment.logger);\n return null;\n }\n });\n return null; // Let Vite handle the resolution\n },\n async transform(code, id, options) {\n if (!options?.ssr || !userOptions.autoDiscover.modulePattern(id)) {\n return null;\n }\n const [key, value] = userOptions.normalizer(id);\n let moduleID = value;\n if (isBuild) {\n if (staticManifest) {\n if (value in staticManifest) {\n moduleID = staticManifest[value].file;\n } else {\n const hash = this.emitFile({\n id,\n type: \"chunk\",\n fileName: key + \".js\",\n name: value,\n });\n const fileName = this.getFileName(hash);\n moduleID = fileName;\n }\n } else {\n throw new Error(`Static manifest not found during dev build.`);\n }\n } else {\n // For non-SSR builds, just use the normalized path\n moduleID = join(userOptions.moduleBasePath, value);\n }\n let finalID = userOptions.moduleID(moduleID);\n // Always transform in server context\n const transformed = transformModuleIfNeeded(\n code,\n finalID,\n userOptions.autoDiscover.isServerFunction(code),\n userOptions.autoDiscover.isClientComponent(code),\n true\n );\n if (userOptions.verbose)\n if (transformed !== code) {\n if (id !== finalID) {\n this.environment.logger.info(\n \"[react-server-transform] \" +\n id.split(\"/\").pop() +\n \" -> \" +\n finalID\n );\n } else {\n this.environment.logger.info(\n \"[react-server-transform] \" +\n id.split(\"/\").pop() +\n (code.startsWith('\"use client\"') ? \" (client)\" : \"\")\n );\n }\n this.environment.logger.info(\n \"[react-server-transform] \" + transformed\n );\n }\n if (!transformed) {\n return {\n id: finalID,\n code: \"\",\n map: null,\n };\n }\n\n return {\n id: finalID,\n code: transformed,\n map: null,\n };\n },\n };\n}\n"],"names":["options"],"mappings":"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"}
|