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,276 @@
|
|
|
1
|
+
import type { Program } from "./types.js";
|
|
2
|
+
import type { FunctionDeclaration, VariableDeclaration, VariableDeclarator } from "acorn";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collects and organizes export information from a module.
|
|
6
|
+
*
|
|
7
|
+
* For all modules:
|
|
8
|
+
* - Collects import statements
|
|
9
|
+
* - Collects export names
|
|
10
|
+
* - Collects declarations
|
|
11
|
+
*
|
|
12
|
+
* The actual transformation of exports (like wrapping with registerServerReference)
|
|
13
|
+
* happens in transformModuleWithPreservedFunctions.
|
|
14
|
+
*
|
|
15
|
+
* @param source - The source code of the module
|
|
16
|
+
* @param url - The URL of the module
|
|
17
|
+
* @param program - The parsed AST program
|
|
18
|
+
* @param isServerFunction - Whether this is a server module
|
|
19
|
+
* @param isClientComponent - Whether this is a client module
|
|
20
|
+
* @returns Object containing imports, declarations, and export names
|
|
21
|
+
*/
|
|
22
|
+
export function handleExports(
|
|
23
|
+
source: string,
|
|
24
|
+
program: Program,
|
|
25
|
+
isServerFunction: boolean | RegExpMatchArray | null,
|
|
26
|
+
isClientComponent: boolean | RegExpMatchArray | null
|
|
27
|
+
): {
|
|
28
|
+
imports: string[];
|
|
29
|
+
declarations: string[];
|
|
30
|
+
exportNames: string[];
|
|
31
|
+
exports: Map<
|
|
32
|
+
string,
|
|
33
|
+
{
|
|
34
|
+
type: "function" | "class" | "variable" | "default" | "all";
|
|
35
|
+
declaration?: string;
|
|
36
|
+
localName?: string;
|
|
37
|
+
before?: string[];
|
|
38
|
+
after?: string[];
|
|
39
|
+
isAsync?: boolean;
|
|
40
|
+
}
|
|
41
|
+
>;
|
|
42
|
+
} {
|
|
43
|
+
const imports: string[] = [];
|
|
44
|
+
const declarations: string[] = [];
|
|
45
|
+
const exportNames: string[] = [];
|
|
46
|
+
// Track exports and their types
|
|
47
|
+
const exports = new Map<
|
|
48
|
+
string,
|
|
49
|
+
{
|
|
50
|
+
type: "function" | "class" | "variable" | "default" | "all";
|
|
51
|
+
declaration?: string;
|
|
52
|
+
localName?: string;
|
|
53
|
+
before?: string[];
|
|
54
|
+
after?: string[];
|
|
55
|
+
isAsync?: boolean;
|
|
56
|
+
}
|
|
57
|
+
>();
|
|
58
|
+
|
|
59
|
+
let lastEnd = 0;
|
|
60
|
+
let currentBefore: string[] = [];
|
|
61
|
+
let foundFirstExport = false;
|
|
62
|
+
|
|
63
|
+
// First pass: collect all exports and code between them
|
|
64
|
+
for (const node of program.body) {
|
|
65
|
+
// Add any code before this node
|
|
66
|
+
if (node.start > lastEnd) {
|
|
67
|
+
const beforeCode = source.slice(lastEnd, node.start);
|
|
68
|
+
if (beforeCode.trim()) {
|
|
69
|
+
currentBefore.push(beforeCode);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (node.type === "ImportDeclaration") {
|
|
74
|
+
imports.push(source.slice(node.start, node.end));
|
|
75
|
+
} else if (node.type === "ExportAllDeclaration") {
|
|
76
|
+
// For export * from './other', just add the * export
|
|
77
|
+
exports.set("*", {
|
|
78
|
+
type: "all",
|
|
79
|
+
before: [...currentBefore],
|
|
80
|
+
});
|
|
81
|
+
currentBefore = [];
|
|
82
|
+
exportNames.push("*");
|
|
83
|
+
} else if (node.type === "ExportNamedDeclaration") {
|
|
84
|
+
if (!foundFirstExport) {
|
|
85
|
+
// This is the first export, so all code before it goes into its before array
|
|
86
|
+
foundFirstExport = true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (node.declaration) {
|
|
90
|
+
if (
|
|
91
|
+
node.declaration.type === "FunctionDeclaration" &&
|
|
92
|
+
node.declaration.id
|
|
93
|
+
) {
|
|
94
|
+
const name = node.declaration.id.name;
|
|
95
|
+
exports.set(name, {
|
|
96
|
+
type: "function",
|
|
97
|
+
declaration: source.slice(node.declaration.start, node.declaration.end),
|
|
98
|
+
before: [...currentBefore], // Copy the current before array
|
|
99
|
+
isAsync: node.declaration.async,
|
|
100
|
+
});
|
|
101
|
+
exportNames.push(name);
|
|
102
|
+
currentBefore = []; // Reset for next export
|
|
103
|
+
} else if (
|
|
104
|
+
node.declaration.type === "ClassDeclaration" &&
|
|
105
|
+
node.declaration.id
|
|
106
|
+
) {
|
|
107
|
+
const name = node.declaration.id.name;
|
|
108
|
+
exports.set(name, {
|
|
109
|
+
type: "class",
|
|
110
|
+
declaration: source.slice(node.declaration.start, node.declaration.end),
|
|
111
|
+
before: [...currentBefore], // Copy the current before array
|
|
112
|
+
});
|
|
113
|
+
exportNames.push(name);
|
|
114
|
+
currentBefore = []; // Reset for next export
|
|
115
|
+
} else if (node.declaration.type === "VariableDeclaration") {
|
|
116
|
+
for (const decl of node.declaration.declarations) {
|
|
117
|
+
if (decl.id && decl.id.type === "Identifier") {
|
|
118
|
+
const name = decl.id.name;
|
|
119
|
+
// Check if the declaration is a function expression or arrow function
|
|
120
|
+
const init = decl.init;
|
|
121
|
+
const isFunction = init && (
|
|
122
|
+
init.type === "FunctionExpression" ||
|
|
123
|
+
init.type === "ArrowFunctionExpression"
|
|
124
|
+
);
|
|
125
|
+
// For function expressions and arrow functions, we want to mark them as async
|
|
126
|
+
// if they are explicitly marked as async
|
|
127
|
+
const isAsync = isFunction && (
|
|
128
|
+
(init.type === "FunctionExpression" && init.async === true) ||
|
|
129
|
+
(init.type === "ArrowFunctionExpression" && init.async === true)
|
|
130
|
+
);
|
|
131
|
+
exports.set(name, {
|
|
132
|
+
type: isFunction ? "function" : "variable",
|
|
133
|
+
declaration: source.slice(decl.start, decl.end),
|
|
134
|
+
before: [...currentBefore], // Copy the current before array
|
|
135
|
+
isAsync: isAsync || false
|
|
136
|
+
});
|
|
137
|
+
exportNames.push(name);
|
|
138
|
+
currentBefore = []; // Reset for next export
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
} else if (node.specifiers) {
|
|
143
|
+
// For named exports (export { a, b, c })
|
|
144
|
+
for (const spec of node.specifiers) {
|
|
145
|
+
if (spec.type === "ExportSpecifier") {
|
|
146
|
+
const localName = spec.local.type === "Identifier" ? spec.local.name : "";
|
|
147
|
+
const exportedName = spec.exported.type === "Identifier" ? spec.exported.name : "";
|
|
148
|
+
if (localName && exportedName) {
|
|
149
|
+
// Find the function declaration in the AST
|
|
150
|
+
const functionDecl = program.body.find(
|
|
151
|
+
(node): node is FunctionDeclaration =>
|
|
152
|
+
node.type === "FunctionDeclaration" &&
|
|
153
|
+
node.id?.name === localName
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
if (functionDecl) {
|
|
157
|
+
exports.set(exportedName, {
|
|
158
|
+
type: "function",
|
|
159
|
+
localName,
|
|
160
|
+
declaration: source.slice(functionDecl.start, functionDecl.end),
|
|
161
|
+
before: [...currentBefore],
|
|
162
|
+
isAsync: functionDecl.async
|
|
163
|
+
});
|
|
164
|
+
exportNames.push(exportedName);
|
|
165
|
+
} else {
|
|
166
|
+
// If we can't find a function declaration, check if it's a variable declaration
|
|
167
|
+
const varDecl = program.body.find(
|
|
168
|
+
(node): node is VariableDeclaration =>
|
|
169
|
+
node.type === "VariableDeclaration" &&
|
|
170
|
+
node.declarations.some(
|
|
171
|
+
(decl) =>
|
|
172
|
+
decl.id.type === "Identifier" &&
|
|
173
|
+
decl.id.name === localName &&
|
|
174
|
+
decl.init &&
|
|
175
|
+
(decl.init.type === "FunctionExpression" ||
|
|
176
|
+
decl.init.type === "ArrowFunctionExpression")
|
|
177
|
+
)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (varDecl) {
|
|
181
|
+
const decl = varDecl.declarations.find(
|
|
182
|
+
(d: VariableDeclarator) => d.id.type === "Identifier" && d.id.name === localName
|
|
183
|
+
);
|
|
184
|
+
if (decl && decl.init) {
|
|
185
|
+
const isAsync = decl.init.type === "FunctionExpression" ? decl.init.async :
|
|
186
|
+
decl.init.type === "ArrowFunctionExpression" ? decl.init.async : false;
|
|
187
|
+
exports.set(exportedName, {
|
|
188
|
+
type: "function",
|
|
189
|
+
localName,
|
|
190
|
+
declaration: source.slice(decl.start, decl.end),
|
|
191
|
+
before: [...currentBefore],
|
|
192
|
+
isAsync
|
|
193
|
+
});
|
|
194
|
+
exportNames.push(exportedName);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
exports.set(exportedName, {
|
|
198
|
+
type: "variable",
|
|
199
|
+
localName,
|
|
200
|
+
before: [...currentBefore],
|
|
201
|
+
});
|
|
202
|
+
exportNames.push(exportedName);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
currentBefore = []; // Reset for next export
|
|
209
|
+
}
|
|
210
|
+
} else if (node.type === "ExportDefaultDeclaration") {
|
|
211
|
+
if (node.declaration && node.declaration.type === "FunctionDeclaration" && node.declaration.id) {
|
|
212
|
+
exports.set("default", {
|
|
213
|
+
type: "default",
|
|
214
|
+
before: [...currentBefore],
|
|
215
|
+
localName: node.declaration.id.name, // Capture the function name
|
|
216
|
+
isAsync: node.declaration.async
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
exports.set("default", {
|
|
220
|
+
type: "default",
|
|
221
|
+
before: [...currentBefore]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
currentBefore = []; // Reset for next export
|
|
225
|
+
} else if (
|
|
226
|
+
node.type === "FunctionDeclaration" ||
|
|
227
|
+
node.type === "VariableDeclaration" ||
|
|
228
|
+
node.type === "ClassDeclaration"
|
|
229
|
+
) {
|
|
230
|
+
// For non-exported declarations:
|
|
231
|
+
// - Keep all declarations for server functions
|
|
232
|
+
// - Remove function declarations for client components
|
|
233
|
+
if (
|
|
234
|
+
isServerFunction ||
|
|
235
|
+
!isClientComponent ||
|
|
236
|
+
node.type !== "FunctionDeclaration"
|
|
237
|
+
) {
|
|
238
|
+
declarations.push(source.slice(node.start, node.end));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
lastEnd = node.end;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Add any remaining code after the last node
|
|
246
|
+
if (lastEnd < source.length) {
|
|
247
|
+
const afterCode = source.slice(lastEnd);
|
|
248
|
+
if (afterCode.trim()) {
|
|
249
|
+
// Add to the last export's after array
|
|
250
|
+
const lastExport = Array.from(exports.values()).pop();
|
|
251
|
+
if (lastExport) {
|
|
252
|
+
lastExport.after = [afterCode];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Second pass: generate transformed exports
|
|
258
|
+
// Process all exports regardless of environment - the actual transformation
|
|
259
|
+
// happens in transformModuleWithPreservedFunctions
|
|
260
|
+
for (const [name, info] of exports) {
|
|
261
|
+
if (info.before) {
|
|
262
|
+
declarations.push(...info.before);
|
|
263
|
+
}
|
|
264
|
+
if (info.declaration) {
|
|
265
|
+
declarations.push(info.declaration);
|
|
266
|
+
}
|
|
267
|
+
if (info.after) {
|
|
268
|
+
declarations.push(...info.after);
|
|
269
|
+
}
|
|
270
|
+
if (!exportNames.includes(name)) {
|
|
271
|
+
exportNames.push(name);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return { imports, declarations, exportNames, exports };
|
|
276
|
+
}
|
package/plugin/loader/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as acorn from "acorn-loose";
|
|
2
|
+
import type { Program } from "./types.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parses source code and handles source maps
|
|
6
|
+
*/
|
|
7
|
+
export function parse(source: string): Program {
|
|
8
|
+
let program: Program;
|
|
9
|
+
|
|
10
|
+
// Parse the transformed code with acorn
|
|
11
|
+
program = acorn.parse(source, {
|
|
12
|
+
ecmaVersion: "latest" as const,
|
|
13
|
+
sourceType: "module",
|
|
14
|
+
locations: true,
|
|
15
|
+
allowAwaitOutsideFunction: true,
|
|
16
|
+
allowImportExportEverywhere: true,
|
|
17
|
+
allowReturnOutsideFunction: true,
|
|
18
|
+
allowReserved: true,
|
|
19
|
+
}) as Program;
|
|
20
|
+
|
|
21
|
+
return program
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
throw new Error("Not supported on the client");
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { LoaderContext, ResolvedUserOptions } from "../types.js";
|
|
2
|
+
import type { ModuleInfo } from "rollup";
|
|
3
|
+
import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
|
|
4
|
+
import type { MessagePort } from "node:worker_threads";
|
|
5
|
+
import type { InitializedReactLoaderMessage, ServerModuleMessage } from "../worker/types.js";
|
|
6
|
+
import { hydrateUserOptions } from "../helpers/index.js";
|
|
7
|
+
import { resolveOptions } from "../config/index.js";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
export interface LoaderOptions {
|
|
12
|
+
id: string;
|
|
13
|
+
resolveDependencies?: boolean;
|
|
14
|
+
format?: string;
|
|
15
|
+
conditions?: string[];
|
|
16
|
+
importAssertions?: Record<string, any>;
|
|
17
|
+
importAttributes?: Record<string, any>;
|
|
18
|
+
source: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type LoaderFunction = (options: LoaderOptions) => Promise<ModuleInfo>;
|
|
22
|
+
|
|
23
|
+
let userOptions: ResolvedUserOptions | undefined;
|
|
24
|
+
let loaderPort: MessagePort | undefined;
|
|
25
|
+
export async function initialize(data: { id: string, port: MessagePort, userOptions: any }) {
|
|
26
|
+
const userOptionsResult = resolveOptions(hydrateUserOptions(data.userOptions));
|
|
27
|
+
loaderPort = data.port;
|
|
28
|
+
loaderPort.postMessage({ type: "INITIALIZED_REACT_LOADER", id: data.id } satisfies InitializedReactLoaderMessage);
|
|
29
|
+
if(userOptionsResult.type === "error") {
|
|
30
|
+
throw userOptionsResult.error
|
|
31
|
+
}
|
|
32
|
+
userOptions = userOptionsResult.userOptions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function load(url: string, context: LoaderContext, nextLoad: any) {
|
|
36
|
+
const { format } = context;
|
|
37
|
+
|
|
38
|
+
if (format === "module") {
|
|
39
|
+
const result = await nextLoad(url, context);
|
|
40
|
+
const source = typeof result.source === 'string' ? result.source :
|
|
41
|
+
result.source instanceof Uint8Array ? new TextDecoder().decode(result.source) :
|
|
42
|
+
String(result.source);
|
|
43
|
+
|
|
44
|
+
// Handle file URLs
|
|
45
|
+
const filePath = url.startsWith("file://") ? fileURLToPath(url) : url;
|
|
46
|
+
|
|
47
|
+
// Normalize the URL using the same logic as plugin.server.ts
|
|
48
|
+
let moduleID = filePath;
|
|
49
|
+
let finalID = filePath;
|
|
50
|
+
if (userOptions?.normalizer) {
|
|
51
|
+
const [, value] = userOptions.normalizer(filePath);
|
|
52
|
+
moduleID = join(userOptions.moduleBasePath, value);
|
|
53
|
+
finalID = userOptions.moduleID(moduleID);
|
|
54
|
+
}
|
|
55
|
+
if (userOptions?.verbose) {
|
|
56
|
+
console.log("[react-loader] moduleID:", moduleID);
|
|
57
|
+
console.log("[react-loader] finalID:", finalID);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const transformed = transformModuleIfNeeded(
|
|
61
|
+
source,
|
|
62
|
+
finalID,
|
|
63
|
+
userOptions?.autoDiscover?.isServerFunction(source),
|
|
64
|
+
userOptions?.autoDiscover?.isClientComponent(source),
|
|
65
|
+
true, // isServerEnvironment
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (userOptions?.verbose) {
|
|
69
|
+
console.log("[react-loader] Transformed source:", transformed);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (loaderPort) {
|
|
73
|
+
if (userOptions?.verbose) {
|
|
74
|
+
console.log("[react-loader] Sending SERVER_MODULE message:", { id: finalID, url: filePath });
|
|
75
|
+
}
|
|
76
|
+
loaderPort.postMessage({
|
|
77
|
+
type: "SERVER_MODULE",
|
|
78
|
+
id: finalID,
|
|
79
|
+
url: filePath,
|
|
80
|
+
source: transformed,
|
|
81
|
+
} satisfies ServerModuleMessage);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// If we have a source map, update it to point to the transformed source
|
|
85
|
+
const map = result.map ? {
|
|
86
|
+
...result.map,
|
|
87
|
+
sourcesContent: [transformed],
|
|
88
|
+
mappings: result.map.mappings
|
|
89
|
+
} : null;
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
...result,
|
|
93
|
+
source: transformed,
|
|
94
|
+
map
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return nextLoad(url, context);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function resolve(
|
|
102
|
+
specifier: string,
|
|
103
|
+
context: any,
|
|
104
|
+
nextResolve: any
|
|
105
|
+
) {
|
|
106
|
+
return nextResolve(specifier, context);
|
|
107
|
+
}
|