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,39 +1,17 @@
|
|
|
1
1
|
import type { PreRenderedAsset } from "rollup";
|
|
2
2
|
import type { PreRenderedChunk } from "rollup";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
StreamPluginOptions,
|
|
5
|
+
ResolvedUserOptions,
|
|
6
|
+
PagePropOpt,
|
|
7
|
+
InlineCssOpt,
|
|
8
|
+
} from "../types.js";
|
|
4
9
|
import { DEFAULT_CONFIG } from "./defaults.js";
|
|
5
10
|
import { join } from "node:path";
|
|
6
11
|
import { pluginRoot } from "../root.js";
|
|
7
12
|
import { CssCollector } from "../components/css-collector.js";
|
|
8
13
|
import { createInputNormalizer } from "../helpers/inputNormalizer.js";
|
|
9
|
-
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// Utility Functions
|
|
12
|
-
// ============================================================================
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Resolves a matcher pattern to a function that tests paths
|
|
16
|
-
*/
|
|
17
|
-
const resolveAutoDiscoverMatcher = (
|
|
18
|
-
options: undefined | string | RegExp | ((path: string) => boolean),
|
|
19
|
-
fallback: RegExp | ((path: string) => boolean)
|
|
20
|
-
) => {
|
|
21
|
-
if (!options) {
|
|
22
|
-
if (typeof fallback === "function") {
|
|
23
|
-
return fallback;
|
|
24
|
-
} else {
|
|
25
|
-
return (path: string) => fallback.test(path);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (typeof options === "string") {
|
|
29
|
-
const matcher = new RegExp(options);
|
|
30
|
-
return (path: string) => matcher.test(path);
|
|
31
|
-
} else if (typeof options === "function") {
|
|
32
|
-
return options;
|
|
33
|
-
} else {
|
|
34
|
-
return (path: string) => options.test(path);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
14
|
+
import { resolveAutoDiscoverMatcher } from "./resolveAutoDiscoverMatcher.js";
|
|
37
15
|
|
|
38
16
|
/**
|
|
39
17
|
* Ensures a path ends with .js extension
|
|
@@ -72,13 +50,13 @@ const registerPath = (
|
|
|
72
50
|
// ============================================================================
|
|
73
51
|
|
|
74
52
|
export const resolveOptions = <
|
|
75
|
-
|
|
53
|
+
T extends PagePropOpt = PagePropOpt,
|
|
54
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
76
55
|
>(
|
|
77
|
-
options: StreamPluginOptions<InlineCSS>
|
|
56
|
+
options: StreamPluginOptions<T, InlineCSS>
|
|
78
57
|
):
|
|
79
|
-
| { type: "success"; userOptions: ResolvedUserOptions<InlineCSS> }
|
|
58
|
+
| { type: "success"; userOptions: ResolvedUserOptions<T, InlineCSS> }
|
|
80
59
|
| { type: "error"; error: Error } => {
|
|
81
|
-
|
|
82
60
|
// Basic configuration
|
|
83
61
|
const projectRoot = options.projectRoot ?? process.cwd();
|
|
84
62
|
const {
|
|
@@ -102,40 +80,81 @@ export const resolveOptions = <
|
|
|
102
80
|
const assetsDir =
|
|
103
81
|
options.build?.assetsDir ?? `${DEFAULT_CONFIG.CLIENT_ASSETS_DIR}`;
|
|
104
82
|
|
|
105
|
-
//
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
83
|
+
// Build options
|
|
84
|
+
const preserveModulesRoot =
|
|
85
|
+
options.build?.preserveModulesRoot ??
|
|
86
|
+
DEFAULT_CONFIG.BUILD.preserveModulesRoot;
|
|
87
|
+
|
|
88
|
+
// Module path configuration
|
|
89
|
+
const moduleBase =
|
|
90
|
+
typeof options.moduleBase === "string"
|
|
91
|
+
? options.moduleBase
|
|
92
|
+
: DEFAULT_CONFIG.MODULE_BASE;
|
|
93
|
+
|
|
94
|
+
const moduleBasePath =
|
|
95
|
+
typeof options.moduleBasePath === "string"
|
|
96
|
+
? options.moduleBasePath
|
|
97
|
+
: process.env.VITE_BASE_URL ?? DEFAULT_CONFIG.MODULE_BASE_PATH;
|
|
110
98
|
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
const moduleBaseURL =
|
|
100
|
+
typeof options.moduleBaseURL === "string"
|
|
101
|
+
? options.moduleBaseURL
|
|
102
|
+
: process.env.VITE_BASE_URL ?? DEFAULT_CONFIG.MODULE_BASE_URL;
|
|
103
|
+
|
|
104
|
+
const moduleRootPath =
|
|
105
|
+
typeof options.moduleRootPath === "string"
|
|
106
|
+
? options.moduleRootPath
|
|
107
|
+
: join(projectRoot, outDir, client);
|
|
108
|
+
|
|
109
|
+
const publicOrigin =
|
|
110
|
+
typeof options.publicOrigin === "string"
|
|
111
|
+
? options.publicOrigin
|
|
112
|
+
: process.env.VITE_PUBLIC_ORIGIN ?? DEFAULT_CONFIG.PUBLIC_ORIGIN;
|
|
113
|
+
|
|
114
|
+
// Worker and loader paths
|
|
115
|
+
const rscWorkerPath =
|
|
116
|
+
typeof options.rscWorkerPath === "string"
|
|
117
|
+
? join(projectRoot, options.rscWorkerPath)
|
|
118
|
+
: join(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);
|
|
119
|
+
|
|
120
|
+
const htmlWorkerPath =
|
|
121
|
+
typeof options.htmlWorkerPath === "string"
|
|
122
|
+
? join(projectRoot, options.htmlWorkerPath)
|
|
123
|
+
: join(pluginRoot, DEFAULT_CONFIG.HTML_WORKER_PATH);
|
|
124
|
+
|
|
125
|
+
const loaderPath =
|
|
126
|
+
typeof options.loaderPath === "string"
|
|
127
|
+
? join(projectRoot, options.loaderPath)
|
|
128
|
+
: join(pluginRoot, DEFAULT_CONFIG.LOADER_PATH);
|
|
129
|
+
// these will never be cleaned up, because, we are resolving the user options
|
|
130
|
+
// and it's assumed they are relevant until the process stops
|
|
131
|
+
if (process.env.VITE_BASE_URL !== moduleBaseURL) {
|
|
132
|
+
process.env.VITE_BASE_URL = moduleBaseURL;
|
|
114
133
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
// if the path starts with the project root, we remove the project root
|
|
130
|
-
return n.startsWith(projectRoot + "/")
|
|
131
|
-
? n.slice(projectRoot.length + 1)
|
|
132
|
-
: n;
|
|
133
|
-
};
|
|
134
|
+
if (process.env.VITE_PUBLIC_ORIGIN !== publicOrigin) {
|
|
135
|
+
process.env.VITE_PUBLIC_ORIGIN = publicOrigin;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const normalizer =
|
|
139
|
+
options.normalizer ??
|
|
140
|
+
createInputNormalizer({
|
|
141
|
+
root: projectRoot,
|
|
142
|
+
preserveModulesRoot:
|
|
143
|
+
preserveModulesRoot === true ? moduleBase : undefined,
|
|
144
|
+
removeExtension: true,
|
|
145
|
+
moduleBasePath,
|
|
146
|
+
});
|
|
134
147
|
|
|
148
|
+
const testModuleExtension = resolveAutoDiscoverMatcher(
|
|
149
|
+
options.autoDiscover?.moduleExtension,
|
|
150
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension
|
|
151
|
+
);
|
|
135
152
|
// Auto-discovery pattern matchers
|
|
136
153
|
const testModulePattern = resolveAutoDiscoverMatcher(
|
|
137
154
|
options.autoDiscover?.modulePattern,
|
|
138
|
-
|
|
155
|
+
options.autoDiscover?.moduleExtension
|
|
156
|
+
? (id: string) => testModuleExtension(id.toLowerCase())
|
|
157
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.modulePattern
|
|
139
158
|
);
|
|
140
159
|
|
|
141
160
|
const testJson = resolveAutoDiscoverMatcher(
|
|
@@ -160,12 +179,20 @@ export const resolveOptions = <
|
|
|
160
179
|
|
|
161
180
|
const testClientComponents = resolveAutoDiscoverMatcher(
|
|
162
181
|
options.autoDiscover?.clientComponents,
|
|
163
|
-
|
|
182
|
+
options.autoDiscover?.moduleExtension
|
|
183
|
+
? (id: string) =>
|
|
184
|
+
testModuleExtension(id.toLowerCase()) &&
|
|
185
|
+
/(\.|\/)?client(\.|\/)/.test(id.toLowerCase())
|
|
186
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.clientComponents
|
|
164
187
|
);
|
|
165
188
|
|
|
166
189
|
const testServerFunctions = resolveAutoDiscoverMatcher(
|
|
167
190
|
options.autoDiscover?.serverFunctions,
|
|
168
|
-
|
|
191
|
+
options.autoDiscover?.moduleExtension
|
|
192
|
+
? (id: string) =>
|
|
193
|
+
testModuleExtension(id.toLowerCase()) &&
|
|
194
|
+
/(\.|\/)?server(\.|\/)/.test(id.toLowerCase())
|
|
195
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.serverFunctions
|
|
169
196
|
);
|
|
170
197
|
|
|
171
198
|
const testNodeOnly = resolveAutoDiscoverMatcher(
|
|
@@ -175,12 +202,20 @@ export const resolveOptions = <
|
|
|
175
202
|
|
|
176
203
|
const testPropsPattern = resolveAutoDiscoverMatcher(
|
|
177
204
|
options.autoDiscover?.propsPattern,
|
|
178
|
-
|
|
205
|
+
options.autoDiscover?.moduleExtension
|
|
206
|
+
? (id: string) =>
|
|
207
|
+
testModuleExtension(id.toLowerCase()) &&
|
|
208
|
+
/(\.|\/)?props(\.|\/)/.test(id.toLowerCase())
|
|
209
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.propsPattern
|
|
179
210
|
);
|
|
180
211
|
|
|
181
212
|
const testPagePattern = resolveAutoDiscoverMatcher(
|
|
182
213
|
options.autoDiscover?.pagePattern,
|
|
183
|
-
|
|
214
|
+
options.autoDiscover?.moduleExtension
|
|
215
|
+
? (id: string) =>
|
|
216
|
+
testModuleExtension(id.toLowerCase()) &&
|
|
217
|
+
/(\.|\/)?page(\.|\/)/.test(id.toLowerCase())
|
|
218
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.pagePattern
|
|
184
219
|
);
|
|
185
220
|
|
|
186
221
|
const testCssModule = resolveAutoDiscoverMatcher(
|
|
@@ -203,10 +238,21 @@ export const resolveOptions = <
|
|
|
203
238
|
DEFAULT_CONFIG.AUTO_DISCOVER.dotFiles
|
|
204
239
|
);
|
|
205
240
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
options.
|
|
209
|
-
|
|
241
|
+
const isServerFunction = resolveAutoDiscoverMatcher(
|
|
242
|
+
options.autoDiscover?.isServerFunction,
|
|
243
|
+
options.autoDiscover?.serverDirective
|
|
244
|
+
? (code: string) =>
|
|
245
|
+
code.match(options.autoDiscover?.serverDirective!) !== null
|
|
246
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.serverDirective
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const isClientComponent = resolveAutoDiscoverMatcher(
|
|
250
|
+
options.autoDiscover?.isClientComponent,
|
|
251
|
+
options.autoDiscover?.clientDirective
|
|
252
|
+
? (code: string) =>
|
|
253
|
+
code.match(options.autoDiscover?.clientDirective!) !== null
|
|
254
|
+
: DEFAULT_CONFIG.AUTO_DISCOVER.clientDirective
|
|
255
|
+
);
|
|
210
256
|
|
|
211
257
|
const hashOption =
|
|
212
258
|
typeof options.build?.hash === "string"
|
|
@@ -304,45 +350,47 @@ export const resolveOptions = <
|
|
|
304
350
|
return hash(`${n.name}.js`, ssr);
|
|
305
351
|
}
|
|
306
352
|
}
|
|
307
|
-
return hash(
|
|
308
|
-
addModuleExtension(getOutputPath(ensureModuleBase(ensureNoRoot(n.name)))),
|
|
309
|
-
ssr
|
|
310
|
-
);
|
|
353
|
+
return hash(addModuleExtension(getOutputPath(normalizer(n.name)[0])), ssr);
|
|
311
354
|
};
|
|
312
355
|
|
|
313
356
|
const chunkFile = (n: PreRenderedChunk, ssr: boolean) => {
|
|
314
|
-
return hash(
|
|
315
|
-
addModuleExtension(
|
|
316
|
-
getOutputPath(ensureModuleBase(ensureNoRoot("_" + n.name)))
|
|
317
|
-
),
|
|
318
|
-
ssr
|
|
319
|
-
);
|
|
357
|
+
return hash(addModuleExtension(getOutputPath(normalizer(n.name)[0])), ssr);
|
|
320
358
|
};
|
|
321
359
|
|
|
322
360
|
const assetFile = (n: PreRenderedAsset, ssr: boolean) => {
|
|
323
|
-
return hash(getOutputPath(
|
|
361
|
+
return hash(getOutputPath(normalizer(n.names[0])[0]), ssr);
|
|
324
362
|
};
|
|
325
363
|
|
|
326
364
|
const moduleID =
|
|
327
365
|
typeof options.moduleID === "function"
|
|
328
366
|
? options.moduleID
|
|
329
367
|
: (id: string) => {
|
|
330
|
-
|
|
331
|
-
|
|
368
|
+
// First normalize the path to handle any leading/trailing slashes
|
|
369
|
+
let normalizedId = id.replace(/^\/+|\/+$/g, "");
|
|
370
|
+
|
|
371
|
+
// If moduleBasePath is set and id doesn't start with it, add it
|
|
372
|
+
if (
|
|
373
|
+
moduleBasePath !== "" &&
|
|
374
|
+
!normalizedId.startsWith(moduleBasePath)
|
|
375
|
+
) {
|
|
376
|
+
normalizedId = join(moduleBasePath, normalizedId);
|
|
332
377
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
378
|
+
|
|
379
|
+
// Handle moduleBase in production
|
|
380
|
+
if (process.env["NODE_ENV"] === "production") {
|
|
381
|
+
if (normalizedId.startsWith(moduleBase)) {
|
|
382
|
+
normalizedId = normalizedId.slice(moduleBase.length);
|
|
383
|
+
} else if (normalizedId.startsWith("/" + moduleBase)) {
|
|
384
|
+
normalizedId = normalizedId.slice(moduleBase.length + 1);
|
|
336
385
|
}
|
|
337
|
-
id = "/" + id;
|
|
338
386
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
387
|
+
|
|
388
|
+
// Ensure the path starts with a slash
|
|
389
|
+
if (!normalizedId.startsWith("/")) {
|
|
390
|
+
normalizedId = "/" + normalizedId;
|
|
344
391
|
}
|
|
345
|
-
|
|
392
|
+
|
|
393
|
+
return normalizedId;
|
|
346
394
|
};
|
|
347
395
|
|
|
348
396
|
const rscOutputPath =
|
|
@@ -377,59 +425,17 @@ export const resolveOptions = <
|
|
|
377
425
|
: assetFile,
|
|
378
426
|
};
|
|
379
427
|
|
|
380
|
-
// Module path configuration
|
|
381
|
-
const moduleBase =
|
|
382
|
-
typeof options.moduleBase === "string"
|
|
383
|
-
? options.moduleBase
|
|
384
|
-
: DEFAULT_CONFIG.MODULE_BASE;
|
|
385
|
-
|
|
386
|
-
const moduleBasePath =
|
|
387
|
-
typeof options.moduleBasePath === "string"
|
|
388
|
-
? options.moduleBasePath
|
|
389
|
-
: process.env.VITE_BASE_URL ?? DEFAULT_CONFIG.MODULE_BASE_PATH;
|
|
390
|
-
|
|
391
|
-
const moduleBaseURL =
|
|
392
|
-
typeof options.moduleBaseURL === "string"
|
|
393
|
-
? options.moduleBaseURL
|
|
394
|
-
: process.env.VITE_BASE_URL ?? DEFAULT_CONFIG.MODULE_BASE_URL;
|
|
395
|
-
|
|
396
|
-
const moduleRootPath =
|
|
397
|
-
typeof options.moduleRootPath === "string"
|
|
398
|
-
? options.moduleRootPath
|
|
399
|
-
: join(projectRoot, outDir, client);
|
|
400
|
-
|
|
401
|
-
const publicOrigin =
|
|
402
|
-
typeof options.publicOrigin === "string"
|
|
403
|
-
? options.publicOrigin
|
|
404
|
-
: process.env.VITE_PUBLIC_ORIGIN ?? DEFAULT_CONFIG.PUBLIC_ORIGIN;
|
|
405
|
-
|
|
406
|
-
// Worker and loader paths
|
|
407
|
-
const rscWorkerPath =
|
|
408
|
-
typeof options.rscWorkerPath === "string"
|
|
409
|
-
? join(projectRoot, options.rscWorkerPath)
|
|
410
|
-
: join(pluginRoot, DEFAULT_CONFIG.RSC_WORKER_PATH);
|
|
411
|
-
|
|
412
|
-
const htmlWorkerPath =
|
|
413
|
-
typeof options.htmlWorkerPath === "string"
|
|
414
|
-
? join(projectRoot, options.htmlWorkerPath)
|
|
415
|
-
: join(pluginRoot, DEFAULT_CONFIG.HTML_WORKER_PATH);
|
|
416
|
-
|
|
417
|
-
const loaderPath =
|
|
418
|
-
typeof options.loaderPath === "string"
|
|
419
|
-
? join(projectRoot, options.loaderPath)
|
|
420
|
-
: join(pluginRoot, DEFAULT_CONFIG.LOADER_PATH);
|
|
421
|
-
// these will never be cleaned up, because, we are resolving the user options
|
|
422
|
-
// and it's assumed they are relevant until the process stops
|
|
423
|
-
if (process.env.VITE_BASE_URL !== moduleBaseURL) {
|
|
424
|
-
process.env.VITE_BASE_URL = moduleBaseURL;
|
|
425
|
-
}
|
|
426
|
-
if (process.env.VITE_PUBLIC_ORIGIN !== publicOrigin) {
|
|
427
|
-
process.env.VITE_PUBLIC_ORIGIN = publicOrigin;
|
|
428
|
-
}
|
|
429
428
|
// Auto-discovery configuration
|
|
430
429
|
const autoDiscover = {
|
|
431
430
|
moduleExtension:
|
|
432
|
-
options.autoDiscover?.moduleExtension ??
|
|
431
|
+
options.autoDiscover?.moduleExtension ??
|
|
432
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension,
|
|
433
|
+
serverDirective:
|
|
434
|
+
options.autoDiscover?.serverDirective ??
|
|
435
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.serverDirective,
|
|
436
|
+
clientDirective:
|
|
437
|
+
options.autoDiscover?.clientDirective ??
|
|
438
|
+
DEFAULT_CONFIG.AUTO_DISCOVER.clientDirective,
|
|
433
439
|
modulePattern: testModulePattern,
|
|
434
440
|
cssPattern: testCss,
|
|
435
441
|
jsonPattern: testJson,
|
|
@@ -444,17 +450,9 @@ export const resolveOptions = <
|
|
|
444
450
|
virtualPattern: testVirtual,
|
|
445
451
|
htmlPattern: testHtml,
|
|
446
452
|
rscPattern: testRsc,
|
|
453
|
+
isServerFunction: isServerFunction,
|
|
454
|
+
isClientComponent: isClientComponent,
|
|
447
455
|
};
|
|
448
|
-
|
|
449
|
-
const normalizer =
|
|
450
|
-
options.normalizer ??
|
|
451
|
-
createInputNormalizer({
|
|
452
|
-
root: projectRoot,
|
|
453
|
-
preserveModulesRoot:
|
|
454
|
-
preserveModulesRoot === true ? moduleBase : undefined,
|
|
455
|
-
removeExtension: true,
|
|
456
|
-
moduleBasePath,
|
|
457
|
-
});
|
|
458
456
|
const pipeableStreamOptions = options.pipeableStreamOptions
|
|
459
457
|
? options.pipeableStreamOptions
|
|
460
458
|
: {};
|
|
@@ -486,7 +484,6 @@ export const resolveOptions = <
|
|
|
486
484
|
inlineCss: options.css?.inlineCss ?? DEFAULT_CONFIG.CSS.inlineCss,
|
|
487
485
|
inlineThreshold:
|
|
488
486
|
options.css?.inlineThreshold ?? DEFAULT_CONFIG.CSS.inlineThreshold,
|
|
489
|
-
purgeCss: options.css?.purgeCss ?? DEFAULT_CONFIG.CSS.purgeCss,
|
|
490
487
|
inlinePatterns:
|
|
491
488
|
options.css?.inlinePatterns ?? DEFAULT_CONFIG.CSS.inlinePatterns,
|
|
492
489
|
linkPatterns:
|
|
@@ -497,10 +494,10 @@ export const resolveOptions = <
|
|
|
497
494
|
loaderPath: loaderPath,
|
|
498
495
|
clientEntry: options.clientEntry ?? DEFAULT_CONFIG.CLIENT_ENTRY,
|
|
499
496
|
serverEntry: options.serverEntry ?? DEFAULT_CONFIG.SERVER_ENTRY,
|
|
500
|
-
moduleBaseExceptions: options.moduleBaseExceptions ?? [],
|
|
497
|
+
// moduleBaseExceptions: options.moduleBaseExceptions ?? [],
|
|
501
498
|
autoDiscover: autoDiscover,
|
|
502
499
|
pipeableStreamOptions,
|
|
503
|
-
} as ResolvedUserOptions<InlineCSS>,
|
|
500
|
+
} as ResolvedUserOptions<T, InlineCSS>,
|
|
504
501
|
};
|
|
505
502
|
} catch (error) {
|
|
506
503
|
return {
|
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ResolvedUserConfig,
|
|
4
4
|
ResolvedUserOptions,
|
|
5
5
|
AutoDiscoveredFiles,
|
|
6
|
+
PagePropOpt,
|
|
7
|
+
InlineCssOpt,
|
|
6
8
|
} from "../types.js";
|
|
7
9
|
import { join } from "node:path";
|
|
8
10
|
import type { OutputOptions, PreRenderedAsset, PreRenderedChunk } from "rollup";
|
|
@@ -10,11 +12,14 @@ import { DEFAULT_CONFIG } from "./defaults.js";
|
|
|
10
12
|
|
|
11
13
|
let stashedUserConfig: Record<string, ResolvedUserConfig | null> = {};
|
|
12
14
|
|
|
13
|
-
export type ResolveUserConfigProps
|
|
15
|
+
export type ResolveUserConfigProps<
|
|
16
|
+
T extends PagePropOpt = PagePropOpt,
|
|
17
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
18
|
+
> = {
|
|
14
19
|
condition: "react-client" | "react-server";
|
|
15
20
|
config: UserConfig;
|
|
16
21
|
configEnv: ConfigEnv;
|
|
17
|
-
userOptions: ResolvedUserOptions
|
|
22
|
+
userOptions: ResolvedUserOptions<T, InlineCSS>;
|
|
18
23
|
autoDiscoveredFiles: Pick<AutoDiscoveredFiles, "inputs" | "staticManifest">;
|
|
19
24
|
};
|
|
20
25
|
|
|
@@ -22,13 +27,16 @@ export type ResolveUserConfigReturn =
|
|
|
22
27
|
| { type: "success"; userConfig: ResolvedUserConfig }
|
|
23
28
|
| { type: "error"; error: Error };
|
|
24
29
|
|
|
25
|
-
export function resolveUserConfig
|
|
30
|
+
export function resolveUserConfig<
|
|
31
|
+
T extends PagePropOpt = PagePropOpt,
|
|
32
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
33
|
+
>({
|
|
26
34
|
condition,
|
|
27
35
|
config,
|
|
28
36
|
configEnv,
|
|
29
37
|
userOptions,
|
|
30
38
|
autoDiscoveredFiles,
|
|
31
|
-
}: ResolveUserConfigProps): ResolveUserConfigReturn {
|
|
39
|
+
}: ResolveUserConfigProps<T, InlineCSS>): ResolveUserConfigReturn {
|
|
32
40
|
const ssr =
|
|
33
41
|
typeof config.build?.ssr === "boolean"
|
|
34
42
|
? config.build?.ssr
|
|
@@ -62,6 +70,9 @@ export function resolveUserConfig({
|
|
|
62
70
|
fallback: (info: T, ssr: boolean) => string,
|
|
63
71
|
ssr: boolean
|
|
64
72
|
) => {
|
|
73
|
+
if ("source" in info && info.source === "") {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
65
76
|
if (!ssr || !input) {
|
|
66
77
|
return fallback(info, false);
|
|
67
78
|
}
|
|
@@ -234,6 +245,7 @@ export function resolveUserConfig({
|
|
|
234
245
|
// client build options
|
|
235
246
|
build: {
|
|
236
247
|
...config.build,
|
|
248
|
+
modulePreload: config.build?.modulePreload ?? false,
|
|
237
249
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
238
250
|
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
239
251
|
assetsDir: config.build?.assetsDir ?? userOptions.build.assetsDir,
|
|
@@ -246,7 +258,9 @@ export function resolveUserConfig({
|
|
|
246
258
|
minify: minify,
|
|
247
259
|
rollupOptions: {
|
|
248
260
|
...config.build?.rollupOptions,
|
|
249
|
-
input:
|
|
261
|
+
input: {
|
|
262
|
+
...autoDiscoveredFiles.inputs,
|
|
263
|
+
},
|
|
250
264
|
output: newOutput,
|
|
251
265
|
preserveEntrySignatures:
|
|
252
266
|
config.build?.rollupOptions?.preserveEntrySignatures ??
|
|
@@ -285,6 +299,7 @@ export function resolveUserConfig({
|
|
|
285
299
|
// server build options
|
|
286
300
|
build: {
|
|
287
301
|
...config.build,
|
|
302
|
+
modulePreload: config.build?.modulePreload ?? false,
|
|
288
303
|
emptyOutDir: config.build?.emptyOutDir ?? true,
|
|
289
304
|
outDir: config.build?.outDir ?? join(userOptions.build.outDir, envDir),
|
|
290
305
|
target: config.build?.target ?? "node18",
|
package/plugin/error/toError.ts
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
|
+
import type { Logger } from "vite";
|
|
2
|
+
|
|
1
3
|
export function toError(error: unknown): {
|
|
2
4
|
name: string;
|
|
3
5
|
message: string;
|
|
4
6
|
stack?: string;
|
|
7
|
+
cause?: unknown;
|
|
5
8
|
} {
|
|
9
|
+
if(typeof error === "string") {
|
|
10
|
+
return {
|
|
11
|
+
name: "Error",
|
|
12
|
+
message: error,
|
|
13
|
+
stack: undefined,
|
|
14
|
+
cause: undefined,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
return error instanceof Error
|
|
7
18
|
? error
|
|
8
19
|
: typeof error === "object" && error !== null
|
|
9
20
|
? {
|
|
10
21
|
name: "name" in error ? String(error.name) : "Unknown Error",
|
|
11
|
-
message: "message" in error ?
|
|
22
|
+
message: "message" in error ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : "Unknown Error",
|
|
12
23
|
stack: "stack" in error ? String(error.stack) : undefined,
|
|
24
|
+
cause: "cause" in error ? toError(error.cause) : error,
|
|
13
25
|
}
|
|
14
26
|
: {
|
|
15
27
|
name: "Unknown Error",
|
|
16
28
|
message: typeof error === "string" ? error : "Unknown Error",
|
|
17
29
|
stack: undefined,
|
|
30
|
+
cause: error,
|
|
18
31
|
};
|
|
19
32
|
}
|
|
33
|
+
|
|
34
|
+
export function logError(error: unknown, logger: Logger | Console = console) {
|
|
35
|
+
const err = toError(error);
|
|
36
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
37
|
+
console.trace(err)
|
|
38
|
+
|
|
39
|
+
if (err.stack && err.stack.includes(err.message)) {
|
|
40
|
+
logger.error(err.stack);
|
|
41
|
+
} else if (err.stack) {
|
|
42
|
+
logger.error(err.message + "\n" + err.stack, {
|
|
43
|
+
error: err,
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
logger.error(err.message, {
|
|
47
|
+
error: err,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
logger.error(err.message);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,44 +1,105 @@
|
|
|
1
1
|
import type { SerializableRecord } from "../types.js";
|
|
2
2
|
|
|
3
3
|
// Helper function to serialize RegExp objects
|
|
4
|
-
function serializeRegExp(regex: RegExp): {
|
|
4
|
+
function serializeRegExp(regex: RegExp): {
|
|
5
|
+
source: string;
|
|
6
|
+
flags: string;
|
|
7
|
+
__isRegExp: boolean;
|
|
8
|
+
} {
|
|
5
9
|
return {
|
|
6
10
|
source: regex.source,
|
|
7
11
|
flags: regex.flags,
|
|
8
|
-
__isRegExp: true
|
|
12
|
+
__isRegExp: true,
|
|
9
13
|
};
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const isSerializable = (
|
|
17
|
+
x: unknown
|
|
18
|
+
): x is
|
|
19
|
+
| number
|
|
20
|
+
| bigint
|
|
21
|
+
| boolean
|
|
22
|
+
| string
|
|
23
|
+
| undefined
|
|
24
|
+
| null
|
|
25
|
+
| Uint8Array
|
|
26
|
+
| Uint16Array
|
|
27
|
+
| Uint32Array
|
|
28
|
+
| Int8Array
|
|
29
|
+
| Int16Array
|
|
30
|
+
| Int32Array => {
|
|
31
|
+
return (
|
|
32
|
+
typeof x === "number" ||
|
|
33
|
+
typeof x === "bigint" ||
|
|
34
|
+
typeof x === "boolean" ||
|
|
35
|
+
typeof x === "string" ||
|
|
36
|
+
x instanceof Buffer ||
|
|
37
|
+
(Array.isArray(x) &&
|
|
38
|
+
(!x.length ||
|
|
39
|
+
x instanceof Uint8Array ||
|
|
40
|
+
x instanceof Uint16Array ||
|
|
41
|
+
x instanceof Uint32Array ||
|
|
42
|
+
x instanceof Int8Array ||
|
|
43
|
+
x instanceof Int16Array ||
|
|
44
|
+
x instanceof Int32Array))
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export function cleanObject<T>(
|
|
49
|
+
obj: T,
|
|
50
|
+
knownNonSerializableFunctions: Set<string> = new Set(),
|
|
51
|
+
currentPath: string = ""
|
|
52
|
+
): SerializableRecord & T {
|
|
53
|
+
if (typeof obj !== "object" || obj == null) return obj as Extract<SerializableRecord, T>;
|
|
54
|
+
if (isSerializable(obj)) return obj as Extract<SerializableRecord, T>;
|
|
55
|
+
|
|
16
56
|
if (Array.isArray(obj)) {
|
|
17
|
-
return obj
|
|
57
|
+
return obj
|
|
58
|
+
.map((x, i) =>
|
|
59
|
+
cleanObject(x, knownNonSerializableFunctions, `${currentPath}[${i}]`)
|
|
60
|
+
)
|
|
61
|
+
.filter((x) => x !== undefined) as Extract<SerializableRecord, T>;
|
|
18
62
|
}
|
|
19
|
-
|
|
63
|
+
if (obj instanceof RegExp)
|
|
64
|
+
return serializeRegExp(obj) as unknown as Extract<SerializableRecord, T>;
|
|
65
|
+
|
|
20
66
|
const result: Record<string, any> = {};
|
|
21
67
|
for (const [key, value] of Object.entries(obj)) {
|
|
22
68
|
const fullPath = currentPath ? `${currentPath}.${key}` : key;
|
|
23
|
-
const normalizedPath = fullPath.replace(/\[\d+\]/g,
|
|
69
|
+
const normalizedPath = fullPath.replace(/\[\d+\]/g, "[]");
|
|
24
70
|
// Skip if it's a function or known non-serializable property
|
|
25
|
-
if
|
|
71
|
+
if(isSerializable(value)) {
|
|
72
|
+
result[key] = value;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (
|
|
76
|
+
typeof value === "function" ||
|
|
77
|
+
knownNonSerializableFunctions.has(normalizedPath) ||
|
|
78
|
+
knownNonSerializableFunctions.has(key)
|
|
79
|
+
) {
|
|
26
80
|
continue;
|
|
27
81
|
}
|
|
28
82
|
|
|
29
83
|
// Handle nested objects
|
|
30
|
-
if (typeof value ===
|
|
84
|
+
if (typeof value === "object" && value !== null) {
|
|
31
85
|
// Check if the object has any functions
|
|
32
86
|
const hasFunctions = Object.entries(value).some(([k, v]) => {
|
|
33
87
|
const nestedPath = `${normalizedPath}.${k}`;
|
|
34
|
-
return
|
|
88
|
+
return (
|
|
89
|
+
typeof v === "function" ||
|
|
90
|
+
knownNonSerializableFunctions.has(nestedPath)
|
|
91
|
+
);
|
|
35
92
|
});
|
|
36
93
|
|
|
37
94
|
if (hasFunctions) {
|
|
38
95
|
continue;
|
|
39
96
|
}
|
|
40
97
|
|
|
41
|
-
const cleaned = cleanObject(
|
|
98
|
+
const cleaned = cleanObject(
|
|
99
|
+
value,
|
|
100
|
+
knownNonSerializableFunctions,
|
|
101
|
+
`${normalizedPath}.${key}`
|
|
102
|
+
);
|
|
42
103
|
if (cleaned !== undefined && Object.keys(cleaned).length > 0) {
|
|
43
104
|
result[key] = cleaned;
|
|
44
105
|
}
|
|
@@ -46,5 +107,8 @@ export function cleanObject<T>(obj: T, knownNonSerializableFunctions: Set<string
|
|
|
46
107
|
result[key] = value;
|
|
47
108
|
}
|
|
48
109
|
}
|
|
49
|
-
return (Object.keys(result).length > 0 ? result : {}) as Extract<
|
|
50
|
-
|
|
110
|
+
return (Object.keys(result).length > 0 ? result : {}) as Extract<
|
|
111
|
+
SerializableRecord,
|
|
112
|
+
T
|
|
113
|
+
>;
|
|
114
|
+
}
|