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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-loader.js","sources":["../../../plugin/loader/react-loader.ts"],"sourcesContent":["import * as acorn from \"acorn-loose\";\nimport { basename } from \"path\";\n\nimport {\n // @ts-ignore\n setSourceMapsSupport,\n SourceMap,\n type LoadHookContext,\n type ResolveHookContext,\n} from \"node:module\";\nimport type { MessagePort } from \"node:worker_threads\";\nimport type { LoaderContext } from \"../types.js\";\nimport { env } from '../utils/env.js';\n\nlet stashedGetSource: any = null;\nlet stashedResolve: any = null;\n\n// Enable source maps with full support\nsetSourceMapsSupport(true, {\n nodeModules: true, // Enable for node_modules files\n generatedCode: true, // Enable for generated code\n});\n\n\n// Store port globally for use in load hook\nexport let loaderPort: MessagePort | undefined;\n// during development, we actually just want to be explicit about the .node extension\nlet isDev = process.env[\"NODE_ENV\"] === \"development\";\n\nexport async function getSource(\n url: string,\n context: any,\n defaultGetSource: any\n) {\n // We stash this in case we end up needing to resolve export * statements later.\n stashedGetSource = defaultGetSource;\n return defaultGetSource(url, context, defaultGetSource);\n}\n\nfunction addExportedEntry(\n exportedEntries: any,\n localNames: any,\n localName: any,\n exportedName: any,\n type: any,\n loc: any\n) {\n if (localNames.has(localName)) {\n // If the same local name is exported more than once, we only need one of the names.\n return;\n }\n\n exportedEntries.push({\n localName,\n exportedName,\n type,\n loc,\n originalLine: -1,\n originalColumn: -1,\n originalSource: -1,\n nameIndex: -1,\n });\n}\n\nfunction addLocalExportedNames(\n exportedEntries: any,\n localNames: any,\n node: any\n) {\n switch (node.type) {\n case \"Identifier\":\n addExportedEntry(\n exportedEntries,\n localNames,\n node.name,\n node.name,\n null,\n node.loc\n );\n return;\n\n case \"ObjectPattern\":\n for (let i = 0; i < node.properties.length; i++)\n addLocalExportedNames(exportedEntries, localNames, node.properties[i]);\n\n return;\n\n case \"ArrayPattern\":\n for (let i = 0; i < node.elements.length; i++) {\n const element = node.elements[i];\n if (element)\n addLocalExportedNames(exportedEntries, localNames, element);\n }\n\n return;\n\n case \"Property\":\n addLocalExportedNames(exportedEntries, localNames, node.value);\n return;\n\n case \"AssignmentPattern\":\n addLocalExportedNames(exportedEntries, localNames, node.left);\n return;\n\n case \"RestElement\":\n addLocalExportedNames(exportedEntries, localNames, node.argument);\n return;\n\n case \"ParenthesizedExpression\":\n addLocalExportedNames(exportedEntries, localNames, node.expression);\n return;\n }\n}\n\nfunction transformServerModule(\n source: string,\n program: any,\n url: string,\n sourceMap: any,\n _loader: any,\n port: MessagePort | undefined\n) {\n const body = program.body; // This entry list needs to be in source location order.\n\n const exportedEntries: any[] = []; // Dedupe set.\n\n const localNames = new Set();\n\n for (let i = 0; i < body.length; i++) {\n const node = body[i];\n\n switch (node.type) {\n case \"ExportAllDeclaration\":\n // If export * is used, the other file needs to explicitly opt into \"use server\" too.\n break;\n\n case \"ExportDefaultDeclaration\":\n if (node.declaration.type === \"Identifier\") {\n addExportedEntry(\n exportedEntries,\n localNames,\n node.declaration.name,\n \"default\",\n null,\n node.declaration.loc\n );\n } else if (node.declaration.type === \"FunctionDeclaration\") {\n if (node.declaration.id) {\n addExportedEntry(\n exportedEntries,\n localNames,\n node.declaration.id.name,\n \"default\",\n \"function\",\n node.declaration.id.loc\n );\n }\n }\n\n continue;\n\n case \"ExportNamedDeclaration\":\n if (node.declaration) {\n if (node.declaration.type === \"VariableDeclaration\") {\n const declarations = node.declaration.declarations;\n\n for (let j = 0; j < declarations.length; j++) {\n addLocalExportedNames(\n exportedEntries,\n localNames,\n declarations[j].id\n );\n }\n } else {\n const name = node.declaration.id.name;\n addExportedEntry(\n exportedEntries,\n localNames,\n name,\n name,\n node.declaration.type === \"FunctionDeclaration\"\n ? \"function\"\n : null,\n node.declaration.id.loc\n );\n }\n }\n\n if (node.specifiers) {\n const specifiers = node.specifiers;\n\n for (let j = 0; j < specifiers.length; j++) {\n const specifier = specifiers[j];\n addExportedEntry(\n exportedEntries,\n localNames,\n specifier.local.name,\n specifier.exported.name,\n null,\n specifier.local.loc\n );\n }\n }\n\n continue;\n }\n }\n\n let mappings =\n sourceMap && typeof sourceMap.mappings === \"string\"\n ? sourceMap.mappings\n : \"\";\n let newSrc = source;\n\n if (exportedEntries.length > 0) {\n let lastSourceIndex = 0;\n let lastOriginalLine = 0;\n let lastOriginalColumn = 0;\n let lastNameIndex = 0;\n let sourceLineCount = 0;\n let lastMappedLine = 0;\n\n if (sourceMap) {\n // We iterate source mapping entries and our matched exports in parallel to source map\n // them to their original location.\n let nextEntryIdx = 0;\n let nextEntryLine = exportedEntries[nextEntryIdx].loc.start.line;\n let nextEntryColumn = exportedEntries[nextEntryIdx].loc.start.column;\n readMappings(\n mappings,\n (\n generatedLine: number,\n generatedColumn: number,\n sourceIndex: number,\n originalLine: number,\n originalColumn: number,\n nameIndex: number\n ) => {\n if (\n generatedLine > nextEntryLine ||\n (generatedLine === nextEntryLine &&\n generatedColumn > nextEntryColumn)\n ) {\n // We're past the entry which means that the best match we have is the previous entry.\n if (lastMappedLine === nextEntryLine) {\n // Match\n exportedEntries[nextEntryIdx].originalLine = lastOriginalLine;\n exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;\n exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;\n exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;\n }\n\n nextEntryIdx++;\n\n if (nextEntryIdx < exportedEntries.length) {\n nextEntryLine = exportedEntries[nextEntryIdx].loc.start.line;\n nextEntryColumn = exportedEntries[nextEntryIdx].loc.start.column;\n } else {\n nextEntryLine = -1;\n nextEntryColumn = -1;\n }\n }\n\n lastMappedLine = generatedLine;\n\n if (sourceIndex > -1) {\n lastSourceIndex = sourceIndex;\n }\n\n if (originalLine > -1) {\n lastOriginalLine = originalLine;\n }\n\n if (originalColumn > -1) {\n lastOriginalColumn = originalColumn;\n }\n\n if (nameIndex > -1) {\n lastNameIndex = nameIndex;\n }\n }\n );\n\n if (nextEntryIdx < exportedEntries.length) {\n if (lastMappedLine === nextEntryLine) {\n // Match\n exportedEntries[nextEntryIdx].originalLine = lastOriginalLine;\n exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;\n exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;\n exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;\n }\n }\n\n for (\n let lastIdx = mappings.length - 1;\n lastIdx >= 0 && mappings[lastIdx] === \";\";\n lastIdx--\n ) {\n // If the last mapped lines don't contain any segments, we don't get a callback from readMappings\n // so we need to pad the number of mapped lines, with one for each empty line.\n lastMappedLine++;\n }\n\n sourceLineCount = program.loc.end.line;\n\n if (sourceLineCount < lastMappedLine) {\n throw new Error(\n \"The source map has more mappings than there are lines.\"\n );\n } // If the original source string had more lines than there are mappings in the source map.\n // Add some extra padding of unmapped lines so that any lines that we add line up.\n\n for (\n let extraLines = sourceLineCount - lastMappedLine;\n extraLines > 0;\n extraLines--\n ) {\n mappings += \";\";\n }\n } else {\n // If a file doesn't have a source map then we generate a blank source map that just\n // contains the original content and segments pointing to the original lines.\n sourceLineCount = 1;\n let idx = -1;\n\n while ((idx = source.indexOf(\"\\n\", idx + 1)) !== -1) {\n sourceLineCount++;\n }\n\n mappings = \"AAAA\" + \";AACA\".repeat(sourceLineCount - 1);\n sourceMap = new SourceMap({\n version: 3,\n file: basename(url),\n sources: [url],\n sourcesContent: [source],\n names: [],\n mappings: mappings,\n sourceRoot: \"\",\n });\n lastSourceIndex = 0;\n lastOriginalLine = sourceLineCount;\n lastOriginalColumn = 0;\n lastNameIndex = -1;\n lastMappedLine = sourceLineCount;\n\n for (let i = 0; i < exportedEntries.length; i++) {\n // Point each entry to original location.\n const entry = exportedEntries[i];\n entry.originalSource = 0;\n entry.originalLine = entry.loc.start.line; // We use column zero since we do the short-hand line-only source maps above.\n\n entry.originalColumn = 0; // entry.loc.start.column;\n }\n }\n\n newSrc = \"\";\n newSrc += `import ReactDOMServerESM from \"react-server-dom-esm/server${\n isDev ? \".node\" : \"\"\n }\";\\n`;\n // include stack trace where module is imported from\n newSrc += `if(ReactDOMServerESM instanceof Error){ throw ReactDOMServerESM; }`;\n newSrc += `export const registerServerReference = ReactDOMServerESM.registerServerReference;\\n`;\n\n if (mappings) {\n mappings += \";;\";\n }\n\n const createMapping = createMappingsSerializer(); // Create an empty mapping pointing to where we last left off to reset the counters.\n\n let generatedLine = 1;\n createMapping(\n generatedLine,\n 0,\n lastSourceIndex,\n lastOriginalLine,\n lastOriginalColumn,\n lastNameIndex\n );\n\n for (let i = 0; i < exportedEntries.length; i++) {\n const entry = exportedEntries[i];\n generatedLine++;\n\n if (entry.type !== \"function\") {\n // We first check if the export is a function and if so annotate it.\n newSrc += \"if (typeof \" + entry.localName + ' === \"function\") ';\n }\n\n newSrc += \"registerServerReference(\" + entry.localName + \",\";\n newSrc += JSON.stringify(url) + \",\";\n newSrc += JSON.stringify(entry.exportedName) + \");\\n\";\n mappings += createMapping(\n generatedLine,\n 0,\n entry.originalSource,\n entry.originalLine,\n entry.originalColumn,\n entry.nameIndex\n );\n }\n }\n\n if (sourceMap) {\n // Override with an new mappings and serialize an inline source map.\n sourceMap.mappings = mappings;\n newSrc +=\n \"//# sourceMappingURL=data:application/json;charset=utf-8;base64,\" +\n Buffer.from(JSON.stringify(sourceMap)).toString(\"base64\");\n }\n if (port) {\n port.postMessage({\n type: \"SERVER_MODULE\",\n url,\n source: newSrc,\n });\n }\n\n return newSrc;\n}\n\nfunction addExportNames(names: any, node: any) {\n switch (node.type) {\n case \"Identifier\":\n names.push(node.name);\n return;\n\n case \"ObjectPattern\":\n for (let i = 0; i < node.properties.length; i++)\n addExportNames(names, node.properties[i]);\n\n return;\n\n case \"ArrayPattern\":\n for (let i = 0; i < node.elements.length; i++) {\n const element = node.elements[i];\n if (element) addExportNames(names, element);\n }\n\n return;\n\n case \"Property\":\n addExportNames(names, node.value);\n return;\n\n case \"AssignmentPattern\":\n addExportNames(names, node.left);\n return;\n\n case \"RestElement\":\n addExportNames(names, node.argument);\n return;\n\n case \"ParenthesizedExpression\":\n addExportNames(names, node.expression);\n return;\n }\n}\n\nfunction resolveClientImport(specifier: string, parentURL: string) {\n const conditions = [\"node\", \"import\"];\n\n if (stashedResolve === null) {\n throw new Error(\n \"Expected resolve to have been called before transformSource\"\n );\n }\n\n return stashedResolve(\n specifier,\n {\n conditions,\n parentURL,\n },\n stashedResolve\n );\n}\n\nasync function parseExportNamesInto(\n body: any,\n names: any,\n parentURL: string,\n loader: any\n) {\n for (let i = 0; i < body.length; i++) {\n const node = body[i];\n\n switch (node.type) {\n case \"ExportAllDeclaration\":\n if (node.exported) {\n addExportNames(names, node.exported);\n continue;\n } else {\n const _await$resolveClientI = await resolveClientImport(\n node.source.value,\n parentURL\n ),\n url = _await$resolveClientI.url;\n\n const _await$loader = await loader(\n url,\n {\n format: \"module\",\n conditions: [],\n importAttributes: {},\n },\n loader\n ),\n source = _await$loader.source;\n\n if (typeof source !== \"string\") {\n throw new Error(\"Expected the transformed source to be a string.\");\n }\n\n let childBody;\n\n try {\n childBody = acorn.parse(source, {\n ecmaVersion: \"2024\" as never,\n sourceType: \"module\",\n }).body;\n } catch (x) {\n // eslint-disable-next-line react-internal/no-production-logging\n console.error(\"Error parsing %s %s\", url, (x as Error)?.message);\n continue;\n }\n\n await parseExportNamesInto(childBody, names, url, loader);\n continue;\n }\n\n case \"ExportDefaultDeclaration\":\n names.push(\"default\");\n continue;\n\n case \"ExportNamedDeclaration\":\n if (node.declaration) {\n if (node.declaration.type === \"VariableDeclaration\") {\n const declarations = node.declaration.declarations;\n\n for (let j = 0; j < declarations.length; j++) {\n addExportNames(names, declarations[j].id);\n }\n } else {\n addExportNames(names, node.declaration.id);\n }\n }\n\n if (node.specifiers) {\n const specifiers = node.specifiers;\n\n for (let j = 0; j < specifiers.length; j++) {\n addExportNames(names, specifiers[j].exported);\n }\n }\n\n continue;\n }\n }\n}\n\nasync function transformClientModule(\n program: any,\n url: string,\n sourceMap: any,\n loader: any\n) {\n const body = program.body;\n const names: any[] = [];\n await parseExportNamesInto(body, names, url, loader);\n\n if (names.length === 0) {\n return null;\n }\n\n let newSrc = `import ReactDOMServerESM from \"react-server-dom-esm/server${\n isDev ? \".node\" : \"\"\n }\";\\n`;\n // check if the module is poisoned\n newSrc += `if(ReactDOMServerESM instanceof Error){ throw new Error(ReactDOMServerESM); }`;\n newSrc += `export const registerClientReference = ReactDOMServerESM.registerClientReference;\\n`;\n\n for (let i = 0; i < names.length; i++) {\n const name = names[i];\n\n const errorMessage =\n name === \"default\"\n ? `Attempted to call the default export of ${url} from the server but it's on the client`\n : `Attempted to call ${name}() from the server but ${name} is on the client`;\n\n const fullError = `${errorMessage}. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;\n\n // Convert file:// URL to relative path for the browser\n const browserUrl = url.replace(\"file://\", \"\").replace(process.cwd(), \"\");\n\n if (name === \"default\") {\n newSrc += `export default registerClientReference(function() { throw new Error(${JSON.stringify(\n fullError\n )}); }, ${JSON.stringify(browserUrl)}, ${JSON.stringify(name)});\\n`;\n } else {\n newSrc += `export const ${name} = registerClientReference(function() { throw new Error(${JSON.stringify(\n fullError\n )}); }, ${JSON.stringify(browserUrl)}, ${JSON.stringify(name)});\\n`;\n }\n }\n\n // Create source map\n if (sourceMap) {\n const newSourceMap = {\n version: 3,\n file: basename(url),\n sources: [url],\n sourcesContent: [program.source],\n names: [],\n mappings: \"AAAA;\" + \";\".repeat(names.length), // Simple line mapping\n sourceRoot: \"\",\n };\n\n newSrc +=\n \"\\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,\";\n newSrc += Buffer.from(JSON.stringify(newSourceMap)).toString(\"base64\");\n }\n\n return newSrc;\n}\n\nasync function loadClientImport(url: string, defaultTransformSource: any) {\n if (stashedGetSource === null) {\n throw new Error(\n \"Expected getSource to have been called before transformSource\"\n );\n } // TODO: Validate that this is another module by calling getFormat.\n\n const _await$stashedGetSour = await stashedGetSource(\n url,\n {\n format: \"module\",\n },\n stashedGetSource\n ),\n source = _await$stashedGetSour.source;\n\n const result = await defaultTransformSource(\n source,\n {\n format: \"module\",\n url,\n },\n defaultTransformSource\n );\n return {\n format: \"module\",\n source: result.source,\n };\n}\n\nexport async function transformModuleIfNeeded(\n source: string,\n url: string,\n loader: any,\n port?: MessagePort // Make port parameter optional\n) {\n if (\n source.indexOf(\"use client\") === -1 &&\n source.indexOf(\"use server\") === -1\n ) {\n return source;\n }\n\n let program;\n try {\n program = acorn.parse(source, {\n ecmaVersion: \"2024\" as never,\n sourceType: \"module\",\n locations: true,\n });\n } catch (x) {\n console.error(\n \"[react-loader] Error parsing %s: %s\",\n url,\n (x as Error)?.message\n );\n return source;\n }\n\n let useClient = false;\n let useServer = false; // Keep this for server transforms\n\n // Check for directives\n for (const node of program.body) {\n if (node.type !== \"ExpressionStatement\" || !node.directive) continue;\n\n if (node.directive === \"use client\") {\n useClient = true;\n\n break;\n }\n if (node.directive === \"use server\") {\n useServer = true;\n break;\n }\n }\n if (useClient && useServer) {\n throw new Error(\n \"Cannot use both use client and use server directives in the same module\"\n );\n }\n if (!useClient && !useServer) {\n return source;\n }\n\n if (useClient) {\n return transformClientModule(program, url, undefined, loader);\n }\n return transformServerModule(source, program, url, undefined, loader, port);\n}\n\nfunction readMappings(\n mappings: string,\n callback: (\n generatedLine: number,\n generatedColumn: number,\n sourceIndex: number,\n originalLine: number,\n originalColumn: number,\n nameIndex: number\n ) => void\n) {\n let line = 1;\n let column = 0;\n let sourceIndex = 0;\n let originalLine = 0;\n let originalColumn = 0;\n let nameIndex = 0;\n\n let index = 0;\n while (index < mappings.length) {\n if (mappings[index] === \";\") {\n line++;\n column = 0;\n index++;\n continue;\n }\n if (mappings[index] === \",\") {\n index++;\n continue;\n }\n\n let [\n generatedColumnDelta = 0,\n sourceIndexDelta = 0,\n originalLineDelta = 0,\n originalColumnDelta = 0,\n nameIndexDelta = 0,\n ] = decodeVLQ(mappings.slice(index));\n\n // Update positions\n column += generatedColumnDelta;\n sourceIndex += sourceIndexDelta;\n originalLine += originalLineDelta;\n originalColumn += originalColumnDelta;\n nameIndex += nameIndexDelta;\n\n // Skip the encoded segment\n while (index < mappings.length && !/[,;]/.test(mappings[index])) {\n index++;\n }\n\n callback(\n line,\n column,\n sourceIndex,\n originalLine,\n originalColumn,\n nameIndex\n );\n }\n}\n\nfunction createMappingsSerializer() {\n let previousGeneratedLine = 1;\n let previousGeneratedColumn = 0;\n let previousOriginalFile = 0;\n let previousOriginalLine = 0;\n let previousOriginalColumn = 0;\n let previousNameIndex = 0;\n\n return function (\n generatedLine: number,\n generatedColumn: number,\n originalFile: number,\n originalLine: number,\n originalColumn: number,\n nameIndex: number\n ): string {\n // Reset column when moving to a new line\n if (generatedLine > previousGeneratedLine) {\n previousGeneratedColumn = 0;\n let lines = \"\";\n for (let i = previousGeneratedLine; i < generatedLine; i++) {\n lines += \";\";\n }\n previousGeneratedLine = generatedLine;\n if (lines) return lines;\n }\n\n // Calculate deltas\n const segment = [\n generatedColumn - previousGeneratedColumn,\n originalFile - previousOriginalFile,\n originalLine - previousOriginalLine,\n originalColumn - previousOriginalColumn,\n ];\n\n if (nameIndex >= 0) {\n segment.push(nameIndex - previousNameIndex);\n }\n\n // Update previous values\n previousGeneratedColumn = generatedColumn;\n previousOriginalFile = originalFile;\n previousOriginalLine = originalLine;\n previousOriginalColumn = originalColumn;\n previousNameIndex = nameIndex;\n\n return encodeVLQ(segment) + \",\";\n };\n}\n\n// VLQ encoding helpers\nconst VLQ_SHIFT = 5;\nconst VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;\nconst VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;\nconst BASE64_CHARS =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\nfunction encodeVLQ(numbers: number[]): string {\n return numbers\n .map((num) => {\n // Convert to VLQ\n const vlq = num < 0 ? (-num << 1) | 1 : num << 1;\n\n let result = \"\";\n let value = vlq;\n\n do {\n let digit = value & VLQ_VALUE_MASK;\n value >>>= VLQ_SHIFT;\n if (value > 0) {\n digit |= VLQ_CONTINUATION_BIT;\n }\n result += BASE64_CHARS[digit];\n } while (value > 0);\n\n return result;\n })\n .join(\"\");\n}\n\nfunction decodeVLQ(str: string): number[] {\n const numbers: number[] = [];\n let value = 0;\n let shift = 0;\n let index = 0;\n\n while (index < str.length && !/[,;]/.test(str[index])) {\n const digit = BASE64_CHARS.indexOf(str[index]);\n if (digit === -1) break;\n\n value += (digit & VLQ_VALUE_MASK) << shift;\n\n if ((digit & VLQ_CONTINUATION_BIT) === 0) {\n const negate = value & 1;\n value >>>= 1;\n numbers.push(negate ? -value : value);\n value = shift = 0;\n } else {\n shift += VLQ_SHIFT;\n }\n\n index++;\n }\n\n return numbers;\n}\n\n// Initialize hook\nexport async function initialize(data: { port: MessagePort }) {\n loaderPort = data.port; // Store port\n data.port.postMessage({ type: \"INITIALIZED_REACT_LOADER\" });\n data.port.unref();\n}\n\n// Resolve hook\nexport async function resolve(\n specifier: string,\n context: ResolveHookContext,\n nextResolve: any\n) {\n return nextResolve(specifier, context);\n}\n\n// Load hook\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext,\n nextLoad: any\n) {\n const result = await nextLoad(url, {\n ...context,\n env: env,\n });\n\n // If not a module, return as is\n if (result.format !== \"module\") {\n return result;\n }\n\n // Convert source to string if it's a Buffer or Uint8Array\n let sourceStr: string;\n if (typeof result.source === \"string\") {\n sourceStr = result.source;\n } else if (\n result.source instanceof Uint8Array ||\n Buffer.isBuffer(result.source)\n ) {\n sourceStr = result.source.toString(\"utf-8\");\n } else {\n console.warn(\n `[react-loader] Unexpected source type: ${typeof result.source}`\n );\n return result;\n }\n\n // Transform the module if needed\n const transformResult = await transformModuleIfNeeded(\n sourceStr,\n url,\n nextLoad,\n loaderPort ?? undefined\n );\n\n // Handle different return types from transformModuleIfNeeded\n if (transformResult === null) {\n return result;\n } else if (typeof transformResult === \"string\") {\n return { ...result, source: transformResult };\n } else if (typeof transformResult === \"object\") {\n // Type assertion for object with code and map properties\n const typedResult = transformResult as { code: string; map?: any };\n if (!(\"code\" in typedResult)) {\n throw new Error(\"Failed to transform module\");\n }\n return {\n ...result,\n source: typedResult.code,\n map: typedResult.map || result.map,\n };\n } else {\n console.warn(\n `[react-loader] Unexpected transform result type: ${typeof transformResult}`\n );\n return result;\n }\n}\n\n// Transform hook\nexport async function transformSource(\n source: string,\n context: any,\n defaultTransformSource: any\n) {\n const transformed = await defaultTransformSource(\n source,\n context,\n defaultTransformSource\n );\n if (context.format === \"module\") {\n // Convert transformedSource to string if it's a Buffer or Uint8Array\n let transformedSourceStr: string;\n if (typeof transformed.source === \"string\") {\n transformedSourceStr = transformed.source;\n } else if (\n transformed.source instanceof Uint8Array ||\n Buffer.isBuffer(transformed.source)\n ) {\n transformedSourceStr = transformed.source.toString(\"utf-8\");\n } else {\n console.warn(\n `[react-loader] Unexpected transformed source type: ${typeof transformed.source}`\n );\n return transformed;\n }\n\n const newSrc = await transformModuleIfNeeded(\n transformedSourceStr,\n context.url,\n (url: string) => loadClientImport(url, defaultTransformSource),\n context.data?.port!\n );\n return { source: newSrc };\n }\n\n return transformed;\n}\n"],"names":["generatedLine"],"mappings":";;;;;;;;;;AAcA,IAAI,gBAAwB,GAAA,IAAA;AAI5B,oBAAA,CAAqB,IAAM,EAAA;AAAA,EACzB,WAAa,EAAA,IAAA;AAAA;AAAA,EACb,aAAe,EAAA;AAAA;AACjB,CAAC,CAAA;AAIU,IAAA;AAEX,IAAI,KAAQ,GAAA,OAAA,CAAQ,GAAI,CAAA,UAAU,CAAM,KAAA,aAAA;AAExC,eAAsB,SAAA,CACpB,GACA,EAAA,OAAA,EACA,gBACA,EAAA;AAEA,EAAmB,gBAAA,GAAA,gBAAA;AACnB,EAAO,OAAA,gBAAA,CAAiB,GAAK,EAAA,OAAA,EAAS,gBAAgB,CAAA;AACxD;AAEA,SAAS,iBACP,eACA,EAAA,UAAA,EACA,SACA,EAAA,YAAA,EACA,MACA,GACA,EAAA;AACA,EAAI,IAAA,UAAA,CAAW,GAAI,CAAA,SAAS,CAAG,EAAA;AAE7B,IAAA;AAAA;AAGF,EAAA,eAAA,CAAgB,IAAK,CAAA;AAAA,IACnB,SAAA;AAAA,IACA,YAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAA;AAAA,IACA,YAAc,EAAA,EAAA;AAAA,IACd,cAAgB,EAAA,EAAA;AAAA,IAChB,cAAgB,EAAA,EAAA;AAAA,IAChB,SAAW,EAAA;AAAA,GACZ,CAAA;AACH;AAEA,SAAS,qBAAA,CACP,eACA,EAAA,UAAA,EACA,IACA,EAAA;AACA,EAAA,QAAQ,KAAK,IAAM;AAAA,IACjB,KAAK,YAAA;AACH,MAAA,gBAAA;AAAA,QACE,eAAA;AAAA,QACA,UAAA;AAAA,QACA,IAAK,CAAA,IAAA;AAAA,QACL,IAAK,CAAA,IAAA;AAAA,QACL,IAA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GA,eAAsB,eAAA,CACpB,MACA,EAAA,OAAA,EACA,sBACA,EAAA;AACA,EAAA,MAAM,cAAc,MAAM,sBAAA;AAAA,IACxB,MAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACA,EAAI,IAAA,OAAA,CAAQ,WAAW,QAAU,EAAA;AAE/B,IAAI,IAAA,oBAAA;AACJ,IAAI,IAAA,OAAO,WAAY,CAAA,MAAA,KAAW,QAAU,EAAA;AAC1C,MAAA,oBAAA,GAAuB,WAAY,CAAA,MAAA;AAAA,KACrC,MAAA,IACE,YAAY,MAAkB,YAAA,UAAA,IAC9B,OAAO,QAAS,CAAA,WAAA,CAAY,MAAM,CAClC,EAAA;AACA,MAAuB,oBAAA,GAAA,WAAA,CAAY,MAAO,CAAA,QAAA,CAAS,OAAO,CAAA;AAAA,KACrD,MAAA;AACL,MAAQ,OAAA,CAAA,IAAA;AAAA,QACN,CAAA,mDAAA,EAAsD,OAAO,WAAA,CAAY,MAAM,CAAA;AAAA,OACjF;AACA,MAAO,OAAA,WAAA;AAAA;AAGT,IAAA,MAAM,SAAS,MAAM,uBAAA;AAAA,MACnB,oBAAA;AAAA,MACA,OAAQ,CAAA,GAAA;AAAA,MACR,CAAC,GAAA,KAAgB,gBAAiB,CAAA,GAAA,EAAK,sBAAsB,CAAA;AAAA,MAC7D,QAAQ,IAAM,EAAA;AAAA,KAChB;AACA,IAAO,OAAA,EAAE,QAAQ,MAAO,EAAA;AAAA;AAG1B,EAAO,OAAA,WAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"react-loader.js","sources":["../../../plugin/loader/react-loader.ts"],"sourcesContent":["import { getCondition } from \"../config/getCondition.js\"\n\nconst condition = getCondition('')\nconst loader = await import(`react-loader.${condition}.ts`);\n\nexport const { load, resolve, transformModuleIfNeeded } = loader;\n"],"names":[],"mappings":";;;;;;;AAEA,MAAM,SAAA,GAAa,aAAa,EAAE,CAAA;AAClC,MAAM,MAAS,GAAA,MAAM,OAAO,CAAA,aAAA,EAAgB,SAAS,CAAA,GAAA,CAAA,CAAA;AAE9C,MAAM,EAAE,IAAA,EAAM,OAAS,EAAA,uBAAA,EAA4B,GAAA;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LoaderContext } from "../types.js";
|
|
2
|
+
import type { ModuleInfo } from "rollup";
|
|
3
|
+
import type { MessagePort } from "node:worker_threads";
|
|
4
|
+
export interface LoaderOptions {
|
|
5
|
+
id: string;
|
|
6
|
+
resolveDependencies?: boolean;
|
|
7
|
+
format?: string;
|
|
8
|
+
conditions?: string[];
|
|
9
|
+
importAssertions?: Record<string, any>;
|
|
10
|
+
importAttributes?: Record<string, any>;
|
|
11
|
+
source: string;
|
|
12
|
+
}
|
|
13
|
+
export type LoaderFunction = (options: LoaderOptions) => Promise<ModuleInfo>;
|
|
14
|
+
export declare function initialize(data: {
|
|
15
|
+
id: string;
|
|
16
|
+
port: MessagePort;
|
|
17
|
+
userOptions: any;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
export declare function load(url: string, context: LoaderContext, nextLoad: any): Promise<any>;
|
|
20
|
+
export declare function resolve(specifier: string, context: any, nextResolve: any): Promise<any>;
|
|
21
|
+
//# sourceMappingURL=react-loader.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-loader.server.d.ts","sourceRoot":"","sources":["../../../plugin/loader/react-loader.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAI7E,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,GAAG,CAAA;CAAE,iBAQzF;AAED,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,gBAgE5E;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,GAAG,gBAGjB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
|
|
2
|
+
import { hydrateUserOptions } from "../helpers/index.js";
|
|
3
|
+
import { resolveOptions } from "../config/index.js";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
let userOptions;
|
|
7
|
+
let loaderPort;
|
|
8
|
+
export async function initialize(data) {
|
|
9
|
+
const userOptionsResult = resolveOptions(hydrateUserOptions(data.userOptions));
|
|
10
|
+
loaderPort = data.port;
|
|
11
|
+
loaderPort.postMessage({ type: "INITIALIZED_REACT_LOADER", id: data.id });
|
|
12
|
+
if (userOptionsResult.type === "error") {
|
|
13
|
+
throw userOptionsResult.error;
|
|
14
|
+
}
|
|
15
|
+
userOptions = userOptionsResult.userOptions;
|
|
16
|
+
}
|
|
17
|
+
export async function load(url, context, nextLoad) {
|
|
18
|
+
const { format } = context;
|
|
19
|
+
if (format === "module") {
|
|
20
|
+
const result = await nextLoad(url, context);
|
|
21
|
+
const source = typeof result.source === 'string' ? result.source :
|
|
22
|
+
result.source instanceof Uint8Array ? new TextDecoder().decode(result.source) :
|
|
23
|
+
String(result.source);
|
|
24
|
+
// Handle file URLs
|
|
25
|
+
const filePath = url.startsWith("file://") ? fileURLToPath(url) : url;
|
|
26
|
+
// Normalize the URL using the same logic as plugin.server.ts
|
|
27
|
+
let moduleID = filePath;
|
|
28
|
+
let finalID = filePath;
|
|
29
|
+
if (userOptions?.normalizer) {
|
|
30
|
+
const [, value] = userOptions.normalizer(filePath);
|
|
31
|
+
moduleID = join(userOptions.moduleBasePath, value);
|
|
32
|
+
finalID = userOptions.moduleID(moduleID);
|
|
33
|
+
}
|
|
34
|
+
if (userOptions?.verbose) {
|
|
35
|
+
console.log("[react-loader] moduleID:", moduleID);
|
|
36
|
+
console.log("[react-loader] finalID:", finalID);
|
|
37
|
+
}
|
|
38
|
+
const transformed = transformModuleIfNeeded(source, finalID, userOptions?.autoDiscover?.isServerFunction(source), userOptions?.autoDiscover?.isClientComponent(source), true);
|
|
39
|
+
if (userOptions?.verbose) {
|
|
40
|
+
console.log("[react-loader] Transformed source:", transformed);
|
|
41
|
+
}
|
|
42
|
+
if (loaderPort) {
|
|
43
|
+
if (userOptions?.verbose) {
|
|
44
|
+
console.log("[react-loader] Sending SERVER_MODULE message:", { id: finalID, url: filePath });
|
|
45
|
+
}
|
|
46
|
+
loaderPort.postMessage({
|
|
47
|
+
type: "SERVER_MODULE",
|
|
48
|
+
id: finalID,
|
|
49
|
+
url: filePath,
|
|
50
|
+
source: transformed,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// If we have a source map, update it to point to the transformed source
|
|
54
|
+
const map = result.map ? {
|
|
55
|
+
...result.map,
|
|
56
|
+
sourcesContent: [transformed],
|
|
57
|
+
mappings: result.map.mappings
|
|
58
|
+
} : null;
|
|
59
|
+
return {
|
|
60
|
+
...result,
|
|
61
|
+
source: transformed,
|
|
62
|
+
map
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return nextLoad(url, context);
|
|
66
|
+
}
|
|
67
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
68
|
+
return nextResolve(specifier, context);
|
|
69
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { SourceMap } from "../types/sourceMap.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a basic source map for a module
|
|
4
|
+
*/
|
|
5
|
+
export declare function createBasicSourceMap(url: string, source: string): SourceMap;
|
|
6
|
+
/**
|
|
7
|
+
* Extends an existing source map with new lines
|
|
8
|
+
*/
|
|
9
|
+
export declare function extendSourceMap(sourceMap: SourceMap, newLines: number, originalSource: string): SourceMap;
|
|
10
|
+
/**
|
|
11
|
+
* Adds a source map as a base64 data URL to the source code
|
|
12
|
+
*/
|
|
13
|
+
export declare function addSourceMapToSource(source: string, sourceMap: SourceMap): string;
|
|
14
|
+
/**
|
|
15
|
+
* Detects and extracts source map URL from source code
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectSourceMapURL(source: string): {
|
|
18
|
+
url: string | null;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
lines: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Strips source map URL comment from source code
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripSourceMapURL(source: string, sourceMapInfo: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
lines: number;
|
|
30
|
+
}): string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a source map with the given parameters
|
|
33
|
+
*/
|
|
34
|
+
export declare function createSourceMap(id: string, code: string, mappings: string): SourceMap;
|
|
35
|
+
//# sourceMappingURL=sourceMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceMap.d.ts","sourceRoot":"","sources":["../../../plugin/loader/sourceMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAuB3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,SAAS,CAgBzG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAQjF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAqBpH;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAOtH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAUrF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import createMappingsSerializer from 'webpack-sources/lib/helpers/createMappingsSerializer.js';
|
|
2
|
+
import { basename } from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a basic source map for a module
|
|
5
|
+
*/
|
|
6
|
+
export function createBasicSourceMap(url, source) {
|
|
7
|
+
const createMapping = createMappingsSerializer();
|
|
8
|
+
let mappings = '';
|
|
9
|
+
let lineCount = 1;
|
|
10
|
+
let idx = -1;
|
|
11
|
+
// Map each line with VLQ encoding
|
|
12
|
+
while ((idx = source.indexOf('\n', idx + 1)) !== -1) {
|
|
13
|
+
createMapping(lineCount, 0, 0, lineCount, 0, -1);
|
|
14
|
+
lineCount++;
|
|
15
|
+
}
|
|
16
|
+
// Add final line
|
|
17
|
+
createMapping(lineCount, 0, 0, lineCount, 0, -1);
|
|
18
|
+
return {
|
|
19
|
+
version: 3,
|
|
20
|
+
file: basename(url),
|
|
21
|
+
sources: [url],
|
|
22
|
+
sourcesContent: [source],
|
|
23
|
+
mappings,
|
|
24
|
+
sourceRoot: '',
|
|
25
|
+
names: []
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extends an existing source map with new lines
|
|
30
|
+
*/
|
|
31
|
+
export function extendSourceMap(sourceMap, newLines, originalSource) {
|
|
32
|
+
const createMapping = createMappingsSerializer();
|
|
33
|
+
let mappings = sourceMap.mappings || '';
|
|
34
|
+
let lineCount = originalSource.split('\n').length;
|
|
35
|
+
// Add padding for new lines
|
|
36
|
+
for (let i = 0; i < newLines; i++) {
|
|
37
|
+
createMapping(lineCount + i, 0, 0, lineCount + i, 0, -1);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...sourceMap,
|
|
41
|
+
version: 3,
|
|
42
|
+
sourcesContent: [originalSource],
|
|
43
|
+
mappings
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Adds a source map as a base64 data URL to the source code
|
|
48
|
+
*/
|
|
49
|
+
export function addSourceMapToSource(source, sourceMap) {
|
|
50
|
+
// Convert version to number for serialization
|
|
51
|
+
const serializedMap = {
|
|
52
|
+
...sourceMap,
|
|
53
|
+
version: Number(sourceMap.version)
|
|
54
|
+
};
|
|
55
|
+
return source + '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
|
|
56
|
+
Buffer.from(JSON.stringify(serializedMap)).toString('base64');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Detects and extracts source map URL from source code
|
|
60
|
+
*/
|
|
61
|
+
export function detectSourceMapURL(source) {
|
|
62
|
+
let sourceMappingURL = null;
|
|
63
|
+
let sourceMappingStart = 0;
|
|
64
|
+
let sourceMappingEnd = 0;
|
|
65
|
+
let sourceMappingLines = 0;
|
|
66
|
+
const lines = source.split('\n');
|
|
67
|
+
for (let i = 0; i < lines.length; i++) {
|
|
68
|
+
const line = lines[i];
|
|
69
|
+
if (line.includes('# sourceMappingURL=') || line.includes('@ sourceMappingURL=')) {
|
|
70
|
+
const match = line.match(/(?:#|@) sourceMappingURL=(.+)/);
|
|
71
|
+
if (match) {
|
|
72
|
+
sourceMappingURL = match[1];
|
|
73
|
+
sourceMappingStart = source.indexOf(line);
|
|
74
|
+
sourceMappingEnd = sourceMappingStart + line.length;
|
|
75
|
+
sourceMappingLines = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { url: sourceMappingURL, start: sourceMappingStart, end: sourceMappingEnd, lines: sourceMappingLines };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Strips source map URL comment from source code
|
|
83
|
+
*/
|
|
84
|
+
export function stripSourceMapURL(source, sourceMapInfo) {
|
|
85
|
+
if (sourceMapInfo.start === 0 && sourceMapInfo.end === 0) {
|
|
86
|
+
return source;
|
|
87
|
+
}
|
|
88
|
+
return source.slice(0, sourceMapInfo.start) +
|
|
89
|
+
'\n'.repeat(sourceMapInfo.lines) +
|
|
90
|
+
source.slice(sourceMapInfo.end);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Creates a source map with the given parameters
|
|
94
|
+
*/
|
|
95
|
+
export function createSourceMap(id, code, mappings) {
|
|
96
|
+
return {
|
|
97
|
+
version: 3,
|
|
98
|
+
file: basename(id),
|
|
99
|
+
sources: [id],
|
|
100
|
+
sourcesContent: [code],
|
|
101
|
+
names: [],
|
|
102
|
+
mappings,
|
|
103
|
+
sourceRoot: "",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const temporaryReferences:
|
|
1
|
+
export declare const temporaryReferences: any;
|
|
2
2
|
//# sourceMappingURL=temporaryReferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporaryReferences.d.ts","sourceRoot":"","sources":["../../../plugin/loader/temporaryReferences.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"temporaryReferences.d.ts","sourceRoot":"","sources":["../../../plugin/loader/temporaryReferences.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,KAAgC,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function transformModuleIfNeeded(source: string, moduleId: string, isServerFunction?: boolean | RegExpMatchArray | null, isClientComponent?: boolean | RegExpMatchArray | null, isServerEnvironment?: boolean): string;
|
|
2
|
+
//# sourceMappingURL=transformModuleIfNeeded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformModuleIfNeeded.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"names":[],"mappings":"AAKA,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,gBAAgB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAA4D,EAC3G,iBAAiB,GAAE,OAAO,GAAG,gBAAgB,GAAG,IAA6D,EAC7G,mBAAmB,UAAoC,UAsBxD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { getCondition } from '../config/getCondition.js';
|
|
7
|
+
import { transformModuleWithPreservedFunctions } from './transformModuleWithPreservedFunctions.js';
|
|
8
|
+
import { parse } from './parse.js';
|
|
9
|
+
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
10
|
+
|
|
11
|
+
function transformModuleIfNeeded(source, moduleId, isServerFunction = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunction(source), isClientComponent = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponent(source), isServerEnvironment = getCondition() === "react-server") {
|
|
12
|
+
const ast = parse(source);
|
|
13
|
+
if (isServerEnvironment && !isServerFunction && !isClientComponent || !isServerEnvironment && isClientComponent) {
|
|
14
|
+
return source;
|
|
15
|
+
}
|
|
16
|
+
const result = transformModuleWithPreservedFunctions(
|
|
17
|
+
source,
|
|
18
|
+
moduleId,
|
|
19
|
+
ast,
|
|
20
|
+
isServerFunction,
|
|
21
|
+
isClientComponent
|
|
22
|
+
);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { transformModuleIfNeeded };
|
|
27
|
+
//# sourceMappingURL=transformModuleIfNeeded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformModuleIfNeeded.js","sources":["../../../plugin/loader/transformModuleIfNeeded.ts"],"sourcesContent":["import { getCondition } from \"../config/getCondition.js\";\nimport { transformModuleWithPreservedFunctions } from \"./transformModuleWithPreservedFunctions.js\";\nimport { parse } from \"./parse.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nexport function transformModuleIfNeeded(\n source: string,\n moduleId: string,\n isServerFunction: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isServerFunction(source),\n isClientComponent: boolean | RegExpMatchArray | null = DEFAULT_CONFIG.AUTO_DISCOVER.isClientComponent(source),\n isServerEnvironment = getCondition() === \"react-server\"\n) {\n // Parse source and handle source maps\n const ast = parse(source); \n\n // Handle environment-specific cases\n if (\n (isServerEnvironment && !isServerFunction && !isClientComponent) ||\n (!isServerEnvironment && isClientComponent)\n ) {\n return source\n }\n\n const result = transformModuleWithPreservedFunctions(\n source,\n moduleId,\n ast,\n isServerFunction,\n isClientComponent\n );\n\n return result\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKO,SAAS,wBACd,MACA,EAAA,QAAA,EACA,mBAAsD,cAAe,CAAA,aAAA,CAAc,iBAAiB,MAAM,CAAA,EAC1G,iBAAuD,GAAA,cAAA,CAAe,cAAc,iBAAkB,CAAA,MAAM,GAC5G,mBAAsB,GAAA,YAAA,OAAmB,cACzC,EAAA;AAEA,EAAM,MAAA,GAAA,GAAM,MAAM,MAAM,CAAA;AAGxB,EAAA,IACG,uBAAuB,CAAC,gBAAA,IAAoB,CAAC,iBAC7C,IAAA,CAAC,uBAAuB,iBACzB,EAAA;AACA,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,MAAM,MAAS,GAAA,qCAAA;AAAA,IACb,MAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Program } from "./types.js";
|
|
2
|
+
export interface TransformOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
exportNames: string[];
|
|
5
|
+
beforeExports: string;
|
|
6
|
+
afterExports: string;
|
|
7
|
+
isServerModule?: boolean;
|
|
8
|
+
isClientModule?: boolean;
|
|
9
|
+
program?: Program;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Transforms a module for RSC boundaries.
|
|
13
|
+
* - Server modules: exports are wrapped with server references while preserving functionality.
|
|
14
|
+
* - Client modules: exports are replaced with client references or errors, depending on environment.
|
|
15
|
+
* - Only the correct references are exported; implementation is never leaked across boundaries.
|
|
16
|
+
*
|
|
17
|
+
* @param source - The original module source code.
|
|
18
|
+
* @param moduleId - The module's unique identifier.
|
|
19
|
+
* @param url - The module's URL.
|
|
20
|
+
* @param program - The parsed AST.
|
|
21
|
+
* @param map - The source map for the source code.
|
|
22
|
+
* @param isServerFunction - Whether the module is a server function.
|
|
23
|
+
* @param isClientComponent - Whether the module is a client component.
|
|
24
|
+
* @returns The transformed source code.
|
|
25
|
+
*/
|
|
26
|
+
export declare function transformModuleWithPreservedFunctions(source: string, moduleId: string, program: Program, isServerFunction: boolean | RegExpMatchArray | null, isClientComponent: boolean | RegExpMatchArray | null): string;
|
|
27
|
+
//# sourceMappingURL=transformModuleWithPreservedFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformModuleWithPreservedFunctions.d.ts","sourceRoot":"","sources":["../../../plugin/loader/transformModuleWithPreservedFunctions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,EACnD,iBAAiB,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,GACnD,MAAM,CA2DR"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { handleExports } from './handleExports.js';
|
|
7
|
+
|
|
8
|
+
function createClientReferenceError(name) {
|
|
9
|
+
return `Attempted to call ${name}() from the server but ${name} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;
|
|
10
|
+
}
|
|
11
|
+
function transformModuleWithPreservedFunctions(source, moduleId, program, isServerFunction, isClientComponent) {
|
|
12
|
+
const { exportNames, exports } = handleExports(source, program, isServerFunction, isClientComponent);
|
|
13
|
+
const moduleIdLiteral = JSON.stringify(moduleId);
|
|
14
|
+
if (isServerFunction) {
|
|
15
|
+
const imports = ['import { registerServerReference } from "react-server-dom-esm/server.node";'];
|
|
16
|
+
const registrations = [];
|
|
17
|
+
for (const name of exportNames) {
|
|
18
|
+
const exportInfo = exports.get(name);
|
|
19
|
+
if (exportInfo) {
|
|
20
|
+
const exportName = name === "default" && exportInfo.localName ? exportInfo.localName : name;
|
|
21
|
+
registrations.push(
|
|
22
|
+
`registerServerReference(${exportName}, ${moduleIdLiteral}, ${JSON.stringify(name)});`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const newSource = [...imports, source].join("\n\n");
|
|
27
|
+
const finalSource = newSource + "\n\n" + registrations.join("\n");
|
|
28
|
+
return finalSource;
|
|
29
|
+
}
|
|
30
|
+
if (isClientComponent) {
|
|
31
|
+
const imports = ['import { registerClientReference } from "react-server-dom-esm/server.node";'];
|
|
32
|
+
const declarations = [];
|
|
33
|
+
for (const name of exportNames) {
|
|
34
|
+
const errorMessage = createClientReferenceError(name);
|
|
35
|
+
if (name === "default") {
|
|
36
|
+
declarations.push(`export default registerClientReference(function() {
|
|
37
|
+
throw new Error("${errorMessage}");
|
|
38
|
+
}, ${moduleIdLiteral}, "default");`);
|
|
39
|
+
} else {
|
|
40
|
+
declarations.push(`export const ${name} = registerClientReference(function() {
|
|
41
|
+
throw new Error("${errorMessage}");
|
|
42
|
+
}, ${moduleIdLiteral}, ${JSON.stringify(name)});`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const newSource = [...imports, ...declarations].join("\n\n");
|
|
46
|
+
return newSource;
|
|
47
|
+
}
|
|
48
|
+
return source;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { transformModuleWithPreservedFunctions };
|
|
52
|
+
//# sourceMappingURL=transformModuleWithPreservedFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformModuleWithPreservedFunctions.js","sources":["../../../plugin/loader/transformModuleWithPreservedFunctions.ts"],"sourcesContent":["/**\n * # RSC Boundary Handling\n *\n * This file provides the core transformation logic for React Server Components (RSC) boundaries.\n *\n * - **Server Loader**: Always strips implementation for client modules, exports error-throwing references.\n * - **Client Loader**: Always strips implementation for server modules, exports error-throwing references.\n * - **Browser**: Only client modules are passed through as-is.\n *\n * All transformations are handled by `transformModuleWithPreservedFunctions` for consistency.\n *\n * ## Error Behavior\n *\n * - If a client component is imported on the server, the export is a function that throws a clear error.\n * - If a server action is imported on the client, the export is a function that throws a clear error.\n *\n * This ensures that implementation details are never leaked across boundaries and errors are easy to debug.\n */\nimport { handleExports } from \"./handleExports.js\";\nimport type { Program } from \"./types.js\";\n\nexport interface TransformOptions {\n id: string;\n exportNames: string[];\n beforeExports: string;\n afterExports: string;\n isServerModule?: boolean;\n isClientModule?: boolean;\n program?: Program;\n}\n\n/**\n * Creates a client reference error message\n */\nfunction createClientReferenceError(name: string): string {\n return `Attempted to call ${name}() from the server but ${name} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;\n}\n\n/**\n * Transforms a module for RSC boundaries.\n * - Server modules: exports are wrapped with server references while preserving functionality.\n * - Client modules: exports are replaced with client references or errors, depending on environment.\n * - Only the correct references are exported; implementation is never leaked across boundaries.\n *\n * @param source - The original module source code.\n * @param moduleId - The module's unique identifier.\n * @param url - The module's URL.\n * @param program - The parsed AST.\n * @param map - The source map for the source code.\n * @param isServerFunction - Whether the module is a server function.\n * @param isClientComponent - Whether the module is a client component.\n * @returns The transformed source code.\n */\nexport function transformModuleWithPreservedFunctions(\n source: string,\n moduleId: string,\n program: Program,\n isServerFunction: boolean | RegExpMatchArray | null,\n isClientComponent: boolean | RegExpMatchArray | null,\n): string {\n\n // Get export names and create module ID literal\n const { exportNames, exports } = handleExports(source, program, isServerFunction, isClientComponent);\n const moduleIdLiteral = JSON.stringify(moduleId);\n\n // For server modules in server environment, register server references\n if (isServerFunction) {\n const imports = ['import { registerServerReference } from \"react-server-dom-esm/server.node\";'];\n const registrations: string[] = [];\n\n // Register each export\n for (const name of exportNames) {\n const exportInfo = exports.get(name);\n if (exportInfo) {\n // For default exports, use the localName if available\n const exportName = name === \"default\" && exportInfo.localName ? exportInfo.localName : name;\n // Register all exports in server modules\n registrations.push(\n `registerServerReference(${exportName}, ${moduleIdLiteral}, ${JSON.stringify(name)});`\n );\n }\n }\n\n // Create new source with registrations\n // First, add the imports at the top\n const newSource = [...imports, source].join(\"\\n\\n\");\n // Then, add the registrations at the end\n const finalSource = newSource + \"\\n\\n\" + registrations.join(\"\\n\");\n\n return finalSource;\n }\n\n // For client modules in server environment, register client references\n if (isClientComponent) {\n const imports = ['import { registerClientReference } from \"react-server-dom-esm/server.node\";'];\n const declarations: string[] = [];\n\n for (const name of exportNames) {\n const errorMessage = createClientReferenceError(name);\n if (name === \"default\") {\n declarations.push(`export default registerClientReference(function() {\n throw new Error(\"${errorMessage}\");\n}, ${moduleIdLiteral}, \"default\");`);\n } else {\n declarations.push(`export const ${name} = registerClientReference(function() {\n throw new Error(\"${errorMessage}\");\n}, ${moduleIdLiteral}, ${JSON.stringify(name)});`);\n }\n }\n\n // Create new source with declarations\n const newSource = [...imports, ...declarations].join(\"\\n\\n\");\n\n return newSource;\n }\n\n // For other cases, return original source\n return source;\n}\n"],"names":[],"mappings":";;;;;;;AAkCA,SAAS,2BAA2B,IAAsB,EAAA;AACxD,EAAO,OAAA,CAAA,kBAAA,EAAqB,IAAI,CAAA,uBAAA,EAA0B,IAAI,CAAA,kKAAA,CAAA;AAChE;AAiBO,SAAS,qCACd,CAAA,MAAA,EACA,QACA,EAAA,OAAA,EACA,kBACA,iBACQ,EAAA;AAGR,EAAM,MAAA,EAAE,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,CAAA;AAAA,OACtB,MAAA;AACL,QAAa,YAAA,CAAA,IAAA,CAAK,gBAAgB,IAAI,CAAA;AAAA,mBAAA,EACzB,YAAY,CAAA;AAAA,GAAA,EAC5B,eAAe,CAAK,EAAA,EAAA,IAAA,CAAK,SAAU,CAAA,IAAI,CAAC,CAAI,EAAA,CAAA,CAAA;AAAA;AAC3C;AAIF,IAAM,MAAA,SAAA,GAAY,CAAC,GAAG,OAAA,EAAS,GAAG,YAAY,CAAA,CAAE,KAAK,MAAM,CAAA;AAE3D,IAAO,OAAA,SAAA;AAAA;AAIT,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../plugin/loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGhE,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,OAAQ,SAAQ,YAAY;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
2
|
-
export declare function vitePluginReactServer(options?: StreamPluginOptions): import("vite").Plugin[];
|
|
1
|
+
import type { StreamPluginOptions, InlineCssOpt, PagePropOpt } from "../types.js";
|
|
2
|
+
export declare function vitePluginReactServer<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(options?: StreamPluginOptions<T, InlineCSS>): import("vite").Plugin[];
|
|
3
3
|
//# sourceMappingURL=plugin.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../plugin/plugin.client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.client.d.ts","sourceRoot":"","sources":["../../plugin/plugin.client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AAKrB,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAC7C,OAAO,GAAS,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,OAAO,MAAM,EAAE,MAAM,EAAE,CAO5E"}
|
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { reactPreservePlugin } from './preserver/plugin.js';
|
|
7
|
-
import { reactTransformPlugin } from './transformer/plugin.client.js';
|
|
8
7
|
import { reactClientPlugin } from './react-client/plugin.js';
|
|
9
8
|
import { envPlugin } from './env.js';
|
|
10
9
|
|
|
11
10
|
function vitePluginReactServer(options = {}) {
|
|
12
11
|
return [
|
|
13
12
|
envPlugin(),
|
|
13
|
+
//reactTransformPlugin(options),
|
|
14
14
|
reactClientPlugin(options),
|
|
15
|
-
|
|
16
|
-
reactPreservePlugin()
|
|
15
|
+
reactPreservePlugin(options)
|
|
17
16
|
];
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.client.js","sources":["../../plugin/plugin.client.ts"],"sourcesContent":["import { reactPreservePlugin } from \"./preserver/plugin.js\"
|
|
1
|
+
{"version":3,"file":"plugin.client.js","sources":["../../plugin/plugin.client.ts"],"sourcesContent":["import { reactPreservePlugin } from \"./preserver/plugin.js\";\nimport type {\n StreamPluginOptions,\n InlineCssOpt,\n PagePropOpt,\n} from \"../types.js\";\nimport { reactClientPlugin } from \"./react-client/plugin.js\";\nimport { envPlugin } from \"./env/plugin.js\";\n//import { reactTransformPlugin } from \"./transformer/plugin.client.js\";\n\nexport function vitePluginReactServer<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>(options = {} as StreamPluginOptions<T, InlineCSS>): import(\"vite\").Plugin[] {\n return [\n envPlugin(),\n //reactTransformPlugin(options),\n reactClientPlugin(options),\n reactPreservePlugin(options),\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;AAUO,SAAS,qBAAA,CAGd,OAAU,GAAA,EAAkE,EAAA;AAC5E,EAAO,OAAA;AAAA,IACL,SAAU,EAAA;AAAA;AAAA,IAEV,kBAAkB,OAAO,CAAA;AAAA,IACzB,oBAAoB,OAAO;AAAA,GAC7B;AACF;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StreamPluginOptions } from "./types.js";
|
|
2
|
-
export declare function vitePluginReactServer(options?: StreamPluginOptions): import("vite").Plugin[];
|
|
1
|
+
import type { StreamPluginOptions, PagePropOpt, InlineCssOpt } from "./types.js";
|
|
2
|
+
export declare function vitePluginReactServer<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(options?: StreamPluginOptions<T, InlineCSS>): import("vite").Plugin[];
|
|
3
3
|
//# sourceMappingURL=plugin.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../plugin/plugin.server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.server.d.ts","sourceRoot":"","sources":["../../plugin/plugin.server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKjF,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAE7C,OAAO,GAAS,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,GAChD,OAAO,MAAM,EAAE,MAAM,EAAE,CAiBzB"}
|
|
@@ -15,7 +15,7 @@ function vitePluginReactServer(options = {}) {
|
|
|
15
15
|
envPlugin(),
|
|
16
16
|
reactTransformPlugin(options),
|
|
17
17
|
reactServerPlugin(options),
|
|
18
|
-
reactPreservePlugin()
|
|
18
|
+
reactPreservePlugin(options)
|
|
19
19
|
];
|
|
20
20
|
}
|
|
21
21
|
return [
|
|
@@ -23,7 +23,7 @@ function vitePluginReactServer(options = {}) {
|
|
|
23
23
|
reactTransformPlugin(options),
|
|
24
24
|
reactServerPlugin(options),
|
|
25
25
|
reactStaticPlugin(options),
|
|
26
|
-
reactPreservePlugin()
|
|
26
|
+
reactPreservePlugin(options)
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.server.js","sources":["../../plugin/plugin.server.ts"],"sourcesContent":["import { reactPreservePlugin } from \"./preserver/plugin.js\";\nimport { reactStaticPlugin } from \"./react-static/plugin.js\";\nimport { reactTransformPlugin } from \"./transformer/plugin.server.js\";\nimport type { StreamPluginOptions } from \"./types.js\";\nimport { reactServerPlugin } from \"./react-server/plugin.js\";\nimport { envPlugin } from \"./env/plugin.js\";\n\n\nexport function vitePluginReactServer(\n options = {} as StreamPluginOptions
|
|
1
|
+
{"version":3,"file":"plugin.server.js","sources":["../../plugin/plugin.server.ts"],"sourcesContent":["import { reactPreservePlugin } from \"./preserver/plugin.js\";\nimport { reactStaticPlugin } from \"./react-static/plugin.js\";\nimport { reactTransformPlugin } from \"./transformer/plugin.server.js\";\nimport type { StreamPluginOptions, PagePropOpt, InlineCssOpt } from \"./types.js\";\nimport { reactServerPlugin } from \"./react-server/plugin.js\";\nimport { envPlugin } from \"./env/plugin.js\";\n\n\nexport function vitePluginReactServer<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>(\n options = {} as StreamPluginOptions<T, InlineCSS>\n): import(\"vite\").Plugin[] {\n if(!options.build?.pages || (Array.isArray(options.build.pages) && options.build.pages.length === 0)) {\n // in this case we do not need the static plugin at all\n return [\n envPlugin(),\n reactTransformPlugin(options),\n reactServerPlugin(options),\n reactPreservePlugin(options),\n ];\n }\n return [\n envPlugin(),\n reactTransformPlugin(options),\n reactServerPlugin(options),\n reactStaticPlugin(options),\n reactPreservePlugin(options),\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAQO,SAAS,qBAAA,CAId,OAAU,GAAA,EACe,EAAA;AACzB,EAAA,IAAG,CAAC,OAAA,CAAQ,KAAO,EAAA,KAAA,IAAU,MAAM,OAAQ,CAAA,OAAA,CAAQ,KAAM,CAAA,KAAK,CAAK,IAAA,OAAA,CAAQ,KAAM,CAAA,KAAA,CAAM,WAAW,CAAI,EAAA;AAEpG,IAAO,OAAA;AAAA,MACL,SAAU,EAAA;AAAA,MACV,qBAAqB,OAAO,CAAA;AAAA,MAC5B,kBAAkB,OAAO,CAAA;AAAA,MACzB,oBAAoB,OAAO;AAAA,KAC7B;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,SAAU,EAAA;AAAA,IACV,qBAAqB,OAAO,CAAA;AAAA,IAC5B,kBAAkB,OAAO,CAAA;AAAA,IACzB,kBAAkB,OAAO,CAAA;AAAA,IACzB,oBAAoB,OAAO;AAAA,GAC7B;AACF;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
2
|
-
export declare function reactPreservePlugin(
|
|
1
|
+
import type { InlineCssOpt, PagePropOpt, StreamPluginOptions } from "../types.js";
|
|
2
|
+
export declare function reactPreservePlugin<T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(options: StreamPluginOptions<T, InlineCSS>): import("vite").Plugin;
|
|
3
3
|
//# sourceMappingURL=plugin.d.ts.map
|