vite-plugin-react-server 1.1.20 → 1.2.0-alpha.1
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/README.md +95 -396
- package/dist/_virtual/dynamic-import-helper.js +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -2
- package/dist/index.js +1 -1
- package/dist/package.json +58 -25
- package/dist/plugin/components/{css-collector-elements.d.ts → css.d.ts} +2 -2
- package/dist/plugin/components/css.d.ts.map +1 -0
- package/dist/plugin/components/css.js +33 -0
- 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 +5 -5
- package/dist/plugin/components/index.d.ts +3 -3
- package/dist/plugin/components/index.d.ts.map +1 -1
- package/dist/plugin/components/index.js +9 -3
- package/dist/plugin/components/root.d.ts +7 -0
- package/dist/plugin/components/root.d.ts.map +1 -0
- package/dist/plugin/components/root.js +18 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +1 -1
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +1 -1
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +5 -4
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +26 -7
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +25 -2
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +84 -5
- package/dist/plugin/config/createModuleID.d.ts +3 -6
- package/dist/plugin/config/createModuleID.d.ts.map +1 -1
- package/dist/plugin/config/createModuleID.js +42 -32
- package/dist/plugin/config/defaults.d.ts +294 -121
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +156 -89
- package/dist/plugin/config/extMap.d.ts +6 -2
- package/dist/plugin/config/extMap.d.ts.map +1 -1
- package/dist/plugin/config/extMap.js +38 -48
- package/dist/plugin/config/flightBindings.d.ts +4 -0
- package/dist/plugin/config/flightBindings.d.ts.map +1 -0
- package/dist/plugin/config/flightBindings.js +215 -0
- package/dist/plugin/config/getCondition.d.ts +2 -0
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +4 -2
- package/dist/plugin/config/getPaths.js +1 -1
- package/dist/plugin/config/index.d.ts +17 -4
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +29 -7
- package/dist/plugin/config/interpolatePattern.d.ts +13 -0
- package/dist/plugin/config/interpolatePattern.d.ts.map +1 -0
- package/dist/plugin/config/interpolatePattern.js +13 -0
- package/dist/plugin/config/mimeTypes.js +1 -1
- package/dist/plugin/config/parsePattern.d.ts +25 -0
- package/dist/plugin/config/parsePattern.d.ts.map +1 -0
- package/dist/plugin/config/parsePattern.js +30 -0
- package/dist/plugin/config/resolveAllowedDirectives.d.ts +26 -0
- package/dist/plugin/config/resolveAllowedDirectives.d.ts.map +1 -0
- package/dist/plugin/config/resolveAllowedDirectives.js +35 -0
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts +25 -0
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts.map +1 -0
- package/dist/plugin/config/resolveDirectiveMatcher.js +33 -0
- package/dist/plugin/config/resolveEnv.d.ts +1 -1
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +45 -28
- package/dist/plugin/config/resolveOptions.d.ts +13 -3
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +230 -219
- package/dist/plugin/config/resolvePages.js +1 -1
- package/dist/plugin/config/resolvePatternWithValues.d.ts +39 -0
- package/dist/plugin/config/resolvePatternWithValues.d.ts.map +1 -0
- package/dist/plugin/config/resolvePatternWithValues.js +36 -0
- package/dist/plugin/config/resolveRegExp.d.ts +29 -0
- package/dist/plugin/config/resolveRegExp.d.ts.map +1 -0
- package/dist/plugin/config/resolveRegExp.js +39 -0
- package/dist/plugin/config/resolveUrlOption.d.ts +37 -6
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
- package/dist/plugin/config/resolveUrlOption.js +42 -12
- package/dist/plugin/config/resolveUserConfig.d.ts +5 -4
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +98 -47
- package/dist/plugin/env/createConfigEnv.d.ts +7 -0
- package/dist/plugin/env/createConfigEnv.d.ts.map +1 -0
- package/dist/plugin/env/createConfigEnv.js +30 -0
- package/dist/plugin/env/getArgValue.d.ts +8 -0
- package/dist/plugin/env/getArgValue.d.ts.map +1 -0
- package/dist/plugin/env/getArgValue.js +32 -0
- package/dist/plugin/env/getEnvKey.d.ts +40 -0
- package/dist/plugin/env/getEnvKey.d.ts.map +1 -0
- package/dist/plugin/env/getEnvKey.js +24 -0
- package/dist/plugin/env/index.d.ts +3 -0
- package/dist/plugin/env/index.d.ts.map +1 -1
- package/dist/plugin/env/index.js +3 -0
- package/dist/plugin/env/plugin.d.ts +6 -0
- package/dist/plugin/env/plugin.d.ts.map +1 -1
- package/dist/plugin/env/plugin.js +69 -93
- package/dist/plugin/env/userConfigEnv.d.ts +2 -0
- package/dist/plugin/env/userConfigEnv.d.ts.map +1 -0
- package/dist/plugin/env/userConfigEnv.js +21 -0
- package/dist/plugin/error/directiveError.d.ts +13 -0
- package/dist/plugin/error/directiveError.d.ts.map +1 -0
- package/dist/plugin/error/directiveError.js +21 -0
- package/dist/plugin/error/enhanceError.d.ts +14 -0
- package/dist/plugin/error/enhanceError.d.ts.map +1 -0
- package/dist/plugin/error/enhanceError.js +24 -0
- package/dist/plugin/error/index.d.ts +4 -0
- package/dist/plugin/error/index.d.ts.map +1 -0
- package/dist/plugin/error/index.js +9 -0
- package/dist/plugin/error/logError.d.ts +3 -0
- package/dist/plugin/error/logError.d.ts.map +1 -0
- package/dist/plugin/error/logError.js +50 -0
- package/dist/plugin/error/serializeError.d.ts +7 -0
- package/dist/plugin/error/serializeError.d.ts.map +1 -0
- package/dist/plugin/error/serializeError.js +37 -0
- package/dist/plugin/error/toError.d.ts +1 -8
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +62 -34
- package/dist/plugin/file-preserver/plugin.js +93 -105
- package/dist/plugin/getNodeEnv.d.ts +11 -0
- package/dist/plugin/getNodeEnv.d.ts.map +1 -0
- package/dist/plugin/getNodeEnv.js +17 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
- package/dist/plugin/helpers/cleanObject.js +2 -1
- package/dist/plugin/helpers/collectManifestCss.js +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +6 -4
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +15 -9
- package/dist/plugin/helpers/createCssProps.d.ts +3 -4
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +16 -15
- package/dist/plugin/helpers/createEventHandler.d.ts +2 -2
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createEventHandler.js +1 -1
- package/dist/plugin/helpers/createHandler.d.ts +10 -8
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +11 -5
- package/dist/plugin/helpers/createRscStream.d.ts +18 -5
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +53 -15
- package/dist/plugin/helpers/formatMetrics.d.ts +1 -5
- package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/helpers/formatMetrics.js +2 -39
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +9 -2
- package/dist/plugin/helpers/getRouteFiles.d.ts +30 -2
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.js +100 -8
- package/dist/plugin/helpers/handleServerAction.d.ts +8 -7
- package/dist/plugin/helpers/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/helpers/handleServerAction.js +7 -3
- package/dist/plugin/helpers/hydrateUserOptions.d.ts +9 -0
- package/dist/plugin/helpers/hydrateUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/hydrateUserOptions.js +22 -0
- package/dist/plugin/helpers/index.d.ts +2 -0
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +31 -31
- package/dist/plugin/helpers/inputNormalizer.d.ts +1 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +33 -20
- package/dist/plugin/helpers/metrics.d.ts +4 -10
- package/dist/plugin/helpers/metrics.d.ts.map +1 -1
- package/dist/plugin/helpers/metrics.js +3 -59
- package/dist/plugin/helpers/moduleRefs.js +1 -1
- package/dist/plugin/helpers/moduleResolver.d.ts +24 -2
- package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -1
- package/dist/plugin/helpers/moduleResolver.js +61 -22
- package/dist/plugin/helpers/requestInfo.d.ts +31 -4
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +62 -35
- package/dist/plugin/helpers/requestToRoute.d.ts +1 -1
- package/dist/plugin/helpers/requestToRoute.d.ts.map +1 -1
- package/dist/plugin/helpers/requestToRoute.js +17 -9
- package/dist/plugin/helpers/resolveComponent.d.ts +57 -0
- package/dist/plugin/helpers/resolveComponent.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveComponent.js +71 -0
- package/dist/plugin/helpers/resolveComponents.d.ts +27 -0
- package/dist/plugin/helpers/resolveComponents.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveComponents.js +146 -0
- package/dist/plugin/helpers/resolvePage.d.ts +15 -11
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePage.js +11 -7
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +3 -10
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js +28 -18
- package/dist/plugin/helpers/resolveProps.d.ts +13 -7
- package/dist/plugin/helpers/resolveProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolveProps.js +55 -25
- package/dist/plugin/helpers/resolveUserComponents.d.ts +33 -0
- package/dist/plugin/helpers/resolveUserComponents.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveUserComponents.js +163 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +7 -7
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +127 -42
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -1
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -1
- package/dist/plugin/helpers/stashReturnValue.js +6 -3
- package/dist/plugin/helpers/tryManifest.d.ts +1 -2
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts +19 -8
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.js +69 -107
- package/dist/plugin/loader/createTransformer.d.ts +6 -0
- package/dist/plugin/loader/createTransformer.d.ts.map +1 -0
- package/dist/plugin/loader/createTransformer.js +92 -0
- package/dist/plugin/loader/{css-loader.development.d.ts → css-loader.d.ts} +6 -8
- package/dist/plugin/loader/css-loader.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.js +134 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.d.ts +4 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.d.ts.map +1 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.js +57 -0
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts +9 -0
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeDirectives.js +221 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts +7 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeModule.js +48 -0
- package/dist/plugin/loader/directives/collectExports.d.ts +13 -0
- package/dist/plugin/loader/directives/collectExports.d.ts.map +1 -0
- package/dist/plugin/loader/directives/collectExports.js +116 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.d.ts +6 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.js +24 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.d.ts +3 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.d.ts.map +1 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.js +46 -0
- package/dist/plugin/loader/directives/getExportedName.d.ts +3 -0
- package/dist/plugin/loader/directives/getExportedName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getExportedName.js +59 -0
- package/dist/plugin/loader/directives/getExports.d.ts +7 -0
- package/dist/plugin/loader/directives/getExports.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getExports.js +28 -0
- package/dist/plugin/loader/directives/getFunctionBody.d.ts +3 -0
- package/dist/plugin/loader/directives/getFunctionBody.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getFunctionBody.js +31 -0
- package/dist/plugin/loader/directives/getFunctionName.d.ts +10 -0
- package/dist/plugin/loader/directives/getFunctionName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getFunctionName.js +42 -0
- package/dist/plugin/loader/directives/getQualifiedName.d.ts +3 -0
- package/dist/plugin/loader/directives/getQualifiedName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getQualifiedName.js +65 -0
- package/dist/plugin/loader/directives/index.d.ts +14 -0
- package/dist/plugin/loader/directives/index.d.ts.map +1 -0
- package/dist/plugin/loader/directives/index.js +18 -0
- package/dist/plugin/loader/directives/processFunctionNode.d.ts +4 -0
- package/dist/plugin/loader/directives/processFunctionNode.d.ts.map +1 -0
- package/dist/plugin/loader/directives/processFunctionNode.js +86 -0
- package/dist/plugin/loader/directives/typeGuards.d.ts +37 -0
- package/dist/plugin/loader/directives/typeGuards.d.ts.map +1 -0
- package/dist/plugin/loader/directives/typeGuards.js +100 -0
- package/dist/plugin/loader/directives/types.d.ts +154 -0
- package/dist/plugin/loader/directives/types.d.ts.map +1 -0
- package/dist/plugin/loader/directives/utils.d.ts +14 -0
- package/dist/plugin/loader/directives/utils.d.ts.map +1 -0
- package/dist/plugin/loader/directives/utils.js +21 -0
- package/dist/plugin/loader/env-loader.d.ts +12 -0
- package/dist/plugin/loader/env-loader.d.ts.map +1 -0
- package/dist/plugin/loader/env-loader.js +88 -0
- package/dist/plugin/loader/index.d.ts +8 -1
- package/dist/plugin/loader/index.d.ts.map +1 -1
- package/dist/plugin/loader/index.js +13 -4
- package/dist/plugin/loader/parse.d.ts +12 -2
- package/dist/plugin/loader/parse.d.ts.map +1 -1
- package/dist/plugin/loader/parse.js +28 -5
- package/dist/plugin/loader/react-loader.d.ts +22 -1
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +169 -6
- package/dist/plugin/loader/removeDirectives.d.ts +5 -0
- package/dist/plugin/loader/removeDirectives.d.ts.map +1 -0
- package/dist/plugin/loader/removeDirectives.js +17 -0
- package/dist/plugin/loader/removeRanges.d.ts +5 -0
- package/dist/plugin/loader/removeRanges.d.ts.map +1 -0
- package/dist/plugin/loader/removeRanges.js +20 -0
- package/dist/plugin/loader/sourceMap.d.ts +16 -24
- package/dist/plugin/loader/sourceMap.d.ts.map +1 -1
- package/dist/plugin/loader/sourceMap.js +125 -97
- package/dist/plugin/loader/transformClientModule.d.ts +9 -0
- package/dist/plugin/loader/transformClientModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformClientModule.js +46 -0
- package/dist/plugin/loader/transformModule.d.ts +6 -0
- package/dist/plugin/loader/transformModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformModule.js +37 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +12 -1
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js +9 -20
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts +10 -0
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts.map +1 -0
- package/dist/plugin/loader/transformNonServerEnvironment.js +72 -0
- package/dist/plugin/loader/transformServerModule.d.ts +10 -0
- package/dist/plugin/loader/transformServerModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformServerModule.js +103 -0
- package/dist/plugin/loader/transformWithAcornLoose.d.ts +12 -0
- package/dist/plugin/loader/transformWithAcornLoose.d.ts.map +1 -0
- package/dist/plugin/loader/transformWithAcornLoose.js +16 -0
- package/dist/plugin/loader/types.d.ts +48 -13
- package/dist/plugin/loader/types.d.ts.map +1 -1
- package/dist/plugin/metrics/collectStreamMetrics.d.ts +9 -0
- package/dist/plugin/metrics/collectStreamMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/collectStreamMetrics.js +35 -0
- package/dist/plugin/metrics/createRenderMetrics.d.ts +3 -0
- package/dist/plugin/metrics/createRenderMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createRenderMetrics.js +24 -0
- package/dist/plugin/metrics/createStreamMetrics.d.ts +3 -0
- package/dist/plugin/metrics/createStreamMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createStreamMetrics.js +19 -0
- package/dist/plugin/metrics/formatMetrics.d.ts +6 -3
- package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/formatMetrics.js +5 -2
- package/dist/plugin/metrics/index.d.ts +3 -1
- package/dist/plugin/metrics/index.d.ts.map +1 -1
- package/dist/plugin/metrics/index.js +9 -1
- package/dist/plugin/metrics/types.d.ts +23 -0
- package/dist/plugin/metrics/types.d.ts.map +1 -0
- package/dist/plugin/metrics/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +23 -2
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +14 -9
- package/dist/plugin/plugin.server.d.ts +13 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +15 -16
- package/dist/plugin/process-env.d.ts +18 -6
- package/dist/plugin/process-env.d.ts.map +1 -1
- package/dist/plugin/process-env.js +17 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts +11 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts.map +1 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.js +18 -0
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts +9 -9
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js +31 -26
- 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 +15 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts +12 -10
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +27 -29
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +13 -8
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +51 -24
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts +2 -1
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerServerAction.js +43 -28
- package/dist/plugin/react-client/index.d.ts +4 -1
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +10 -1
- package/dist/plugin/react-client/plugin.d.ts +5 -3
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +9 -11
- package/dist/plugin/react-client/restartWorker.d.ts +5 -4
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +14 -13
- package/dist/plugin/react-server/configureReactServer.d.ts +5 -4
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
- package/dist/plugin/react-server/configureReactServer.js +106 -47
- package/dist/plugin/react-server/handleServerAction.d.ts +3 -2
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/react-server/handleServerAction.js +14 -20
- package/dist/plugin/react-server/plugin.d.ts +3 -4
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +30 -31
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +8 -6
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +4 -4
- package/dist/plugin/react-static/collectRscContent.d.ts +8 -6
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js +4 -4
- package/dist/plugin/react-static/configurePreviewServer.d.ts +6 -4
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +32 -36
- package/dist/plugin/react-static/createBuildLoader.d.ts +5 -5
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.js +122 -30
- package/dist/plugin/react-static/fileWriter.js +1 -1
- package/dist/plugin/react-static/plugin.d.ts +3 -4
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +62 -47
- package/dist/plugin/react-static/renderPage.d.ts +4 -2
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js +21 -17
- package/dist/plugin/react-static/renderPages.d.ts +4 -2
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js +7 -6
- package/dist/plugin/react-static/renderStreams.d.ts +5 -22
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +6 -6
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -1
- package/dist/plugin/react-static/rscToHtmlStream.js +1 -1
- package/dist/plugin/react-static/temporaryReferences.js +1 -1
- package/dist/plugin/react-static/types.d.ts +0 -1
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -1
- package/dist/plugin/transformer/plugin.client.d.ts +29 -1
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +96 -1
- package/dist/plugin/transformer/plugin.js +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +5 -3
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +60 -69
- package/dist/plugin/types/css-tracking.d.ts +2 -2
- package/dist/plugin/types/css-tracking.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +451 -192
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +2 -1
- package/dist/plugin/utils/callServer.js +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 +1 -1
- package/dist/plugin/utils/createReactFetcher.d.ts +2 -3
- package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
- package/dist/plugin/utils/createReactFetcher.js +1 -1
- package/dist/plugin/utils/env.js +1 -1
- package/dist/plugin/utils/envUrls.node.d.ts.map +1 -1
- package/dist/plugin/utils/envUrls.node.js +3 -2
- 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 +12 -5
- package/dist/plugin/utils/routeToURL.d.ts +12 -0
- package/dist/plugin/utils/routeToURL.d.ts.map +1 -0
- package/dist/plugin/utils/routeToURL.js +26 -0
- package/dist/plugin/utils/urls.d.ts.map +1 -1
- package/dist/plugin/utils/urls.js +5 -3
- package/dist/plugin/vendor/index.js +7 -1
- package/dist/plugin/vendor/vendor.client.js +1 -1
- package/dist/plugin/vendor/vendor.js +1 -1
- package/dist/plugin/vendor/vendor.server.js +1 -1
- package/dist/plugin/worker/createWorker.d.ts +31 -17
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +18 -12
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +2 -2
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +5 -2
- package/dist/plugin/worker/html/html-worker.development.js +3 -3
- package/dist/plugin/worker/html/html-worker.production.js +1 -1
- package/dist/plugin/worker/html/index.d.ts +1 -1
- package/dist/plugin/worker/html/index.d.ts.map +1 -1
- package/dist/plugin/worker/html/index.js +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +9 -11
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts +3 -0
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts.map +1 -0
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.js +2 -0
- package/dist/plugin/worker/html/types.d.ts +20 -2
- package/dist/plugin/worker/html/types.d.ts.map +1 -1
- package/dist/plugin/worker/index.d.ts +3 -0
- package/dist/plugin/worker/index.d.ts.map +1 -0
- package/dist/plugin/worker/index.js +7 -0
- package/dist/plugin/worker/registerLoaders.js +2 -2
- package/dist/plugin/worker/rsc/handleRender.d.ts +5 -3
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +57 -38
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handlers.js +19 -15
- package/dist/plugin/worker/rsc/index.d.ts +1 -1
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/index.js +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +22 -8
- package/dist/plugin/worker/rsc/rsc-worker.development.js +77 -11
- package/dist/plugin/worker/rsc/rsc-worker.production.js +37 -8
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts +3 -0
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.js +11 -0
- package/dist/plugin/worker/rsc/state.js +1 -1
- package/dist/plugin/worker/rsc/types.d.ts +95 -0
- package/dist/plugin/worker/rsc/types.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/types.js +1 -0
- package/dist/plugin/worker/rsc/userOptions.d.ts +1 -1
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/userOptions.js +3 -4
- package/dist/plugin/worker/sendMessage.d.ts +3 -4
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +15 -5
- package/dist/plugin/worker/types.d.ts +109 -260
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -26
- package/plugin/components/{css-collector-elements.tsx → css.tsx} +3 -3
- package/plugin/components/html.tsx +4 -4
- package/plugin/components/index.ts +3 -3
- package/plugin/components/root.tsx +20 -0
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +173 -134
- package/plugin/config/autoDiscover/resolveBuildPages.ts +120 -7
- package/plugin/config/createModuleID.ts +60 -39
- package/plugin/config/defaults.tsx +189 -96
- package/plugin/config/extMap.ts +51 -56
- package/plugin/config/flightBindings.ts +221 -0
- package/plugin/config/getCondition.ts +6 -0
- package/plugin/config/index.ts +17 -4
- package/plugin/config/interpolatePattern.ts +19 -0
- package/plugin/config/parsePattern.ts +81 -0
- package/plugin/config/resolveAllowedDirectives.ts +59 -0
- package/plugin/config/resolveDirectiveMatcher.ts +57 -0
- package/plugin/config/resolveEnv.ts +41 -37
- package/plugin/config/resolveOptions.ts +437 -318
- package/plugin/config/resolvePatternWithValues.ts +70 -0
- package/plugin/config/resolveRegExp.ts +89 -0
- package/plugin/config/resolveUrlOption.ts +92 -20
- package/plugin/config/resolveUserConfig.ts +427 -351
- package/plugin/env/createConfigEnv.ts +40 -0
- package/plugin/env/getArgValue.ts +56 -0
- package/plugin/env/getEnvKey.ts +61 -0
- package/plugin/env/index.ts +4 -1
- package/plugin/env/plugin.ts +13 -18
- package/plugin/env/userConfigEnv.ts +22 -0
- package/plugin/error/directiveError.ts +29 -0
- package/plugin/error/enhanceError.ts +41 -0
- package/plugin/error/index.ts +3 -0
- package/plugin/error/logError.ts +48 -0
- package/plugin/error/serializeError.ts +34 -0
- package/plugin/error/toError.ts +75 -45
- package/plugin/file-preserver/plugin.ts +3 -3
- package/plugin/getNodeEnv.ts +24 -0
- package/plugin/helpers/cleanObject.ts +2 -1
- package/plugin/helpers/collectViteModuleGraphCss.ts +138 -118
- package/plugin/helpers/createCssProps.tsx +29 -30
- package/plugin/helpers/createEventHandler.ts +1 -1
- package/plugin/helpers/createHandler.ts +40 -12
- package/plugin/helpers/createRscStream.tsx +103 -36
- package/plugin/helpers/formatMetrics.ts +2 -37
- package/plugin/helpers/getBundleManifest.ts +10 -1
- package/plugin/helpers/getRouteFiles.ts +154 -9
- package/plugin/helpers/handleServerAction.ts +12 -7
- package/plugin/helpers/hydrateUserOptions.ts +23 -0
- package/plugin/helpers/index.ts +4 -0
- package/plugin/helpers/inputNormalizer.ts +44 -24
- package/plugin/helpers/metrics.ts +4 -64
- package/plugin/helpers/moduleResolver.ts +74 -19
- package/plugin/helpers/requestInfo.ts +95 -61
- package/plugin/helpers/requestToRoute.ts +38 -12
- package/plugin/helpers/resolveComponent.ts +173 -0
- package/plugin/helpers/resolveComponents.ts +202 -0
- package/plugin/helpers/resolvePage.ts +35 -29
- package/plugin/helpers/resolvePageAndProps.ts +82 -61
- package/plugin/helpers/resolveProps.ts +100 -37
- package/plugin/helpers/resolveUserComponents.ts +190 -0
- package/plugin/helpers/serializeUserOptions.ts +190 -69
- package/plugin/helpers/stashReturnValue.ts +7 -4
- package/plugin/helpers/tryManifest.ts +1 -1
- package/plugin/loader/createDefaultLoader.ts +119 -119
- package/plugin/loader/createTransformer.ts +110 -0
- package/plugin/loader/css-loader.ts +206 -0
- package/plugin/loader/directives/addLocalExportedNames.ts +78 -0
- package/plugin/loader/directives/analyzeDirectives.ts +298 -0
- package/plugin/loader/directives/analyzeModule.ts +57 -0
- package/plugin/loader/directives/collectExports.ts +181 -0
- package/plugin/loader/directives/collectExportsFromModule.ts +25 -0
- package/plugin/loader/directives/findDirectiveMatches.ts +58 -0
- package/plugin/loader/directives/getExportedName.ts +73 -0
- package/plugin/loader/directives/getExports.ts +27 -0
- package/plugin/loader/directives/getFunctionBody.ts +32 -0
- package/plugin/loader/directives/getFunctionName.ts +70 -0
- package/plugin/loader/directives/getQualifiedName.ts +76 -0
- package/plugin/loader/directives/index.ts +13 -0
- package/plugin/loader/directives/processFunctionNode.ts +97 -0
- package/plugin/loader/directives/typeGuards.ts +160 -0
- package/plugin/loader/directives/types.ts +174 -0
- package/plugin/loader/directives/utils.ts +35 -0
- package/plugin/loader/env-loader.ts +135 -0
- package/plugin/loader/index.ts +8 -6
- package/plugin/loader/parse.ts +42 -12
- package/plugin/loader/react-loader.ts +256 -4
- package/plugin/loader/removeDirectives.ts +14 -0
- package/plugin/loader/removeRanges.ts +21 -0
- package/plugin/loader/sourceMap.ts +174 -84
- package/plugin/loader/transformClientModule.ts +60 -0
- package/plugin/loader/transformModule.ts +59 -0
- package/plugin/loader/transformModuleIfNeeded.ts +40 -40
- package/plugin/loader/transformNonServerEnvironment.ts +95 -0
- package/plugin/loader/transformServerModule.ts +167 -0
- package/plugin/loader/transformWithAcornLoose.ts +27 -0
- package/plugin/loader/types.ts +58 -13
- package/plugin/metrics/collectStreamMetrics.ts +38 -0
- package/plugin/metrics/createRenderMetrics.ts +17 -0
- package/plugin/metrics/createStreamMetrics.ts +14 -0
- package/plugin/metrics/formatMetrics.ts +7 -3
- package/plugin/metrics/index.ts +3 -1
- package/plugin/metrics/types.ts +24 -0
- package/plugin/plugin.client.ts +43 -16
- package/plugin/plugin.server.ts +41 -21
- package/plugin/process-env.ts +27 -6
- package/plugin/react-client/cleanupWorkerServerAction.ts +33 -0
- package/plugin/react-client/configureWorkerRequestHandler.ts +206 -201
- package/plugin/react-client/createMessageHandlers.ts +17 -3
- package/plugin/react-client/createWorkerStream.ts +55 -51
- package/plugin/react-client/handleWorkerRscStream.ts +130 -61
- package/plugin/react-client/handleWorkerServerAction.ts +59 -37
- package/plugin/react-client/index.ts +4 -1
- package/plugin/react-client/plugin.ts +17 -18
- package/plugin/react-client/restartWorker.ts +74 -70
- package/plugin/react-server/configureReactServer.ts +204 -142
- package/plugin/react-server/handleServerAction.ts +156 -160
- package/plugin/react-server/plugin.ts +150 -157
- package/plugin/react-static/collectHtmlWorkerContent.ts +109 -102
- package/plugin/react-static/collectRscContent.ts +55 -51
- package/plugin/react-static/configurePreviewServer.ts +99 -100
- package/plugin/react-static/createBuildLoader.ts +157 -48
- package/plugin/react-static/plugin.ts +368 -357
- package/plugin/react-static/renderPage.ts +31 -24
- package/plugin/react-static/renderPages.ts +21 -14
- package/plugin/react-static/renderStreams.ts +13 -15
- package/plugin/react-static/rscToHtmlStream.ts +4 -6
- package/plugin/react-static/types.ts +0 -3
- package/plugin/transformer/README.md +82 -8
- package/plugin/transformer/plugin.client.ts +142 -0
- package/plugin/transformer/plugin.server.ts +87 -112
- package/plugin/types/css-tracking.ts +1 -1
- package/plugin/types/global.d.ts +2 -2
- package/plugin/types/react-server-dom-esm.d.ts +12 -13
- package/plugin/types.ts +684 -309
- package/plugin/utils/createCallServer.ts +5 -5
- package/plugin/utils/createReactFetcher.ts +4 -6
- package/plugin/utils/envUrls.node.ts +15 -10
- package/plugin/utils/index.ts +2 -1
- package/plugin/utils/routeToURL.ts +34 -0
- package/plugin/utils/urls.ts +10 -7
- package/plugin/worker/createWorker.ts +67 -34
- package/plugin/worker/html/README.md +10 -0
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +7 -4
- package/plugin/worker/html/html-worker.development.tsx +4 -3
- package/plugin/worker/html/index.ts +3 -1
- package/plugin/worker/html/messageHandler.tsx +10 -16
- package/plugin/worker/html/sendHtmlWorkerMessage.ts +8 -0
- package/plugin/worker/html/types.ts +67 -1
- package/plugin/worker/index.ts +2 -0
- package/plugin/worker/registerLoaders.ts +3 -3
- package/plugin/worker/rsc/README.md +203 -1
- package/plugin/worker/rsc/handleRender.ts +75 -45
- package/plugin/worker/rsc/handlers.ts +30 -22
- package/plugin/worker/rsc/index.ts +2 -0
- package/plugin/worker/rsc/messageHandler.tsx +23 -13
- package/plugin/worker/rsc/rsc-worker.development.ts +104 -17
- package/plugin/worker/rsc/rsc-worker.production.ts +57 -10
- package/plugin/worker/rsc/sendRscWorkerMessage.ts +7 -0
- package/plugin/worker/rsc/state.ts +1 -1
- package/plugin/worker/rsc/types.ts +185 -0
- package/plugin/worker/rsc/userOptions.ts +2 -3
- package/plugin/worker/sendMessage.ts +23 -14
- package/plugin/worker/types.ts +131 -386
- package/scripts/check-react-version.mjs +3 -3
- package/scripts/fix-unused-imports.mjs +77 -0
- package/tsconfig.json +1 -1
- package/dist/_virtual/dynamic-import-helper.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin/components/css-collector-elements.d.ts.map +0 -1
- package/dist/plugin/components/css-collector-elements.js +0 -33
- package/dist/plugin/components/css-collector-elements.js.map +0 -1
- package/dist/plugin/components/css-collector.d.ts +0 -7
- package/dist/plugin/components/css-collector.d.ts.map +0 -1
- package/dist/plugin/components/css-collector.js +0 -18
- package/dist/plugin/components/css-collector.js.map +0 -1
- package/dist/plugin/components/html.js.map +0 -1
- package/dist/plugin/components.js +0 -9
- package/dist/plugin/components.js.map +0 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +0 -1
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +0 -1
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +0 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +0 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +0 -1
- package/dist/plugin/config/defaults.js.map +0 -1
- package/dist/plugin/config/extMap.js.map +0 -1
- package/dist/plugin/config/getCondition.js.map +0 -1
- package/dist/plugin/config/getPaths.js.map +0 -1
- package/dist/plugin/config/mimeTypes.js.map +0 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +0 -5
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +0 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js +0 -25
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +0 -1
- package/dist/plugin/config/resolveEnv.js.map +0 -1
- package/dist/plugin/config/resolveOptions.js.map +0 -1
- package/dist/plugin/config/resolvePages.js.map +0 -1
- package/dist/plugin/config/resolveUrlOption.js.map +0 -1
- package/dist/plugin/config/resolveUserConfig.js.map +0 -1
- package/dist/plugin/config.js +0 -17
- package/dist/plugin/config.js.map +0 -1
- package/dist/plugin/env.js +0 -79
- package/dist/plugin/env.js.map +0 -1
- package/dist/plugin/error/toError.js.map +0 -1
- package/dist/plugin/file-preserver.js +0 -96
- package/dist/plugin/file-preserver.js.map +0 -1
- package/dist/plugin/helpers/cleanObject.js.map +0 -1
- package/dist/plugin/helpers/collectManifestCss.js.map +0 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +0 -1
- package/dist/plugin/helpers/createCssProps.js.map +0 -1
- package/dist/plugin/helpers/createEventHandler.js.map +0 -1
- package/dist/plugin/helpers/createHandler.js.map +0 -1
- package/dist/plugin/helpers/createRscStream.js.map +0 -1
- package/dist/plugin/helpers/formatMetrics.js.map +0 -1
- package/dist/plugin/helpers/getBundleManifest.js.map +0 -1
- package/dist/plugin/helpers/getRouteFiles.js.map +0 -1
- package/dist/plugin/helpers/handleServerAction.js.map +0 -1
- package/dist/plugin/helpers/inputNormalizer.js.map +0 -1
- package/dist/plugin/helpers/metrics.js.map +0 -1
- package/dist/plugin/helpers/moduleRefs.js.map +0 -1
- package/dist/plugin/helpers/requestInfo.js.map +0 -1
- package/dist/plugin/helpers/requestToRoute.js.map +0 -1
- package/dist/plugin/helpers/resolvePage.js.map +0 -1
- package/dist/plugin/helpers/resolvePageAndProps.js.map +0 -1
- package/dist/plugin/helpers/resolveProps.js.map +0 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +0 -1
- package/dist/plugin/helpers/sourceMap.d.ts +0 -8
- package/dist/plugin/helpers/sourceMap.d.ts.map +0 -1
- package/dist/plugin/helpers/sourceMap.js +0 -136
- package/dist/plugin/helpers/stashReturnValue.js.map +0 -1
- package/dist/plugin/helpers/tryManifest.js.map +0 -1
- package/dist/plugin/helpers.js +0 -27
- package/dist/plugin/helpers.js.map +0 -1
- package/dist/plugin/loader/css-loader.development.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.development.js +0 -76
- package/dist/plugin/loader/css-loader.development.js.map +0 -1
- package/dist/plugin/loader/css-loader.production.d.ts +0 -31
- package/dist/plugin/loader/css-loader.production.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.production.js +0 -45
- package/dist/plugin/loader/css-loader.production.js.map +0 -1
- package/dist/plugin/loader/env-loader.development.d.ts +0 -13
- package/dist/plugin/loader/env-loader.development.d.ts.map +0 -1
- package/dist/plugin/loader/env-loader.development.js +0 -68
- package/dist/plugin/loader/handleExports.d.ts +0 -40
- package/dist/plugin/loader/handleExports.d.ts.map +0 -1
- package/dist/plugin/loader/handleExports.js +0 -209
- package/dist/plugin/loader/handleExports.js.map +0 -1
- package/dist/plugin/loader/parse.js.map +0 -1
- package/dist/plugin/loader/react-loader.client.d.ts +0 -2
- package/dist/plugin/loader/react-loader.client.d.ts.map +0 -1
- package/dist/plugin/loader/react-loader.client.js +0 -2
- package/dist/plugin/loader/react-loader.js.map +0 -1
- package/dist/plugin/loader/react-loader.server.d.ts +0 -21
- package/dist/plugin/loader/react-loader.server.d.ts.map +0 -1
- package/dist/plugin/loader/react-loader.server.js +0 -131
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +0 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +0 -48
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +0 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +0 -428
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +0 -1
- package/dist/plugin/metrics/formatMetrics.js.map +0 -1
- package/dist/plugin/metrics.js +0 -7
- package/dist/plugin/metrics.js.map +0 -1
- package/dist/plugin/plugin.client.js.map +0 -1
- package/dist/plugin/plugin.server.js.map +0 -1
- package/dist/plugin/preserver/index.d.ts +0 -2
- package/dist/plugin/preserver/index.d.ts.map +0 -1
- package/dist/plugin/preserver/index.js +0 -1
- package/dist/plugin/preserver/plugin.d.ts +0 -3
- package/dist/plugin/preserver/plugin.d.ts.map +0 -1
- package/dist/plugin/preserver/plugin.js +0 -130
- package/dist/plugin/preserver/plugin.js.map +0 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +0 -1
- package/dist/plugin/react-client/createMessageHandlers.js.map +0 -1
- package/dist/plugin/react-client/createWorkerStream.js.map +0 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +0 -1
- package/dist/plugin/react-client/handleWorkerServerAction.js.map +0 -1
- package/dist/plugin/react-client/plugin.js.map +0 -1
- package/dist/plugin/react-client/restartWorker.js.map +0 -1
- package/dist/plugin/react-server/configureReactServer.js.map +0 -1
- package/dist/plugin/react-server/handleServerAction.js.map +0 -1
- package/dist/plugin/react-server/plugin.js.map +0 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +0 -1
- package/dist/plugin/react-static/collectRscContent.js.map +0 -1
- package/dist/plugin/react-static/configurePreviewServer.js.map +0 -1
- package/dist/plugin/react-static/createBuildLoader.js.map +0 -1
- package/dist/plugin/react-static/fileWriter.js.map +0 -1
- package/dist/plugin/react-static/plugin.js.map +0 -1
- package/dist/plugin/react-static/renderPage.js.map +0 -1
- package/dist/plugin/react-static/renderPages.js.map +0 -1
- package/dist/plugin/react-static/renderStreams.js.map +0 -1
- package/dist/plugin/react-static/rscToHtmlStream.js.map +0 -1
- package/dist/plugin/react-static/streamHandler.d.ts +0 -2
- package/dist/plugin/react-static/streamHandler.d.ts.map +0 -1
- package/dist/plugin/react-static/temporaryReferences.js.map +0 -1
- package/dist/plugin/root.js.map +0 -1
- package/dist/plugin/source-map/createMappingsSerializer.d.ts +0 -2
- package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +0 -1
- package/dist/plugin/source-map/createMappingsSerializer.js +0 -129
- package/dist/plugin/source-map/createMappingsSerializer.js.map +0 -1
- package/dist/plugin/source-map/readMappings.d.ts +0 -2
- package/dist/plugin/source-map/readMappings.d.ts.map +0 -1
- package/dist/plugin/source-map/readMappings.js +0 -200
- package/dist/plugin/transformer/plugin.js.map +0 -1
- package/dist/plugin/transformer/plugin.server.js.map +0 -1
- package/dist/plugin/utils/callServer.js.map +0 -1
- package/dist/plugin/utils/createCallServer.js.map +0 -1
- package/dist/plugin/utils/createReactFetcher.js.map +0 -1
- package/dist/plugin/utils/env.js.map +0 -1
- package/dist/plugin/utils/envUrls.node.js.map +0 -1
- package/dist/plugin/utils/urls.js.map +0 -1
- package/dist/plugin/utils.js +0 -11
- package/dist/plugin/utils.js.map +0 -1
- package/dist/plugin/vendor/vendor.client.js.map +0 -1
- package/dist/plugin/vendor/vendor.js.map +0 -1
- package/dist/plugin/vendor/vendor.server.js.map +0 -1
- package/dist/plugin/vendor.js +0 -7
- package/dist/plugin/vendor.js.map +0 -1
- package/dist/plugin/worker/createWorker.js.map +0 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +0 -1
- package/dist/plugin/worker/html/html-worker.development.js.map +0 -1
- package/dist/plugin/worker/html/html-worker.production.js.map +0 -1
- package/dist/plugin/worker/html/index.js.map +0 -1
- package/dist/plugin/worker/html/messageHandler.js.map +0 -1
- package/dist/plugin/worker/rsc/handleRender.js.map +0 -1
- package/dist/plugin/worker/rsc/handlers.js.map +0 -1
- package/dist/plugin/worker/rsc/index.js.map +0 -1
- package/dist/plugin/worker/rsc/messageHandler.js.map +0 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +0 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +0 -1
- package/dist/plugin/worker/rsc/state.js.map +0 -1
- package/dist/plugin/worker/rsc/userOptions.js.map +0 -1
- package/dist/plugin/worker/sendMessage.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/plugin/components/css-collector.tsx +0 -20
- package/plugin/config/resolveAutoDiscoverMatcher.ts +0 -23
- package/plugin/helpers/sourceMap.ts +0 -182
- package/plugin/loader/css-loader.development.ts +0 -135
- package/plugin/loader/css-loader.production.ts +0 -84
- package/plugin/loader/env-loader.development.ts +0 -107
- package/plugin/loader/handleExports.ts +0 -309
- package/plugin/loader/react-loader.client.ts +0 -1
- package/plugin/loader/react-loader.server.ts +0 -185
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +0 -593
- package/plugin/preserver/index.ts +0 -1
- package/plugin/preserver/plugin.ts +0 -178
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/source-map/createMappingsSerializer.ts +0 -181
- package/plugin/source-map/readMappings.ts +0 -194
- /package/dist/plugin/{react-static/streamHandler.js → loader/directives/types.js} +0 -0
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
The RSC worker is used by the client plugin to handle React Server Components when the main thread is running without the `react-server` condition. It provides the server-condition capabilities that the client plugin needs but can't access directly.
|
|
4
4
|
|
|
5
|
+
> **Part of**: [Vite React Server Plugin](../../../README.md)
|
|
6
|
+
> **Documentation**: [Plugin Architecture Overview](../../../docs/README.md#plugin-architecture-documentation)
|
|
7
|
+
|
|
5
8
|
## Purpose
|
|
6
9
|
|
|
7
10
|
The RSC worker serves several key functions:
|
|
8
11
|
|
|
9
12
|
1. **Server Condition Access**: Enables RSC processing in a client-focused environment
|
|
10
13
|
2. **Message-Based Communication**: Handles RSC streaming through a message passing interface
|
|
14
|
+
3. **Context Isolation**: Provides a clean environment for server-side React processing
|
|
15
|
+
4. **Streaming Support**: Handles RSC chunk processing and streaming responses
|
|
11
16
|
|
|
12
17
|
## Implementation Details
|
|
13
18
|
|
|
@@ -16,6 +21,22 @@ The worker comes in two variants:
|
|
|
16
21
|
- `rsc-worker.development.ts`: Full implementation with detailed logging and error handling
|
|
17
22
|
- `rsc-worker.production.ts`: Optimized implementation for production builds
|
|
18
23
|
|
|
24
|
+
### Message Types
|
|
25
|
+
|
|
26
|
+
The worker handles several message types:
|
|
27
|
+
|
|
28
|
+
- `RSC_RENDER`: Renders React Server Components
|
|
29
|
+
- `SERVER_ACTION`: Executes server actions
|
|
30
|
+
- `CLEANUP`: Cleans up worker resources
|
|
31
|
+
|
|
32
|
+
### State Management
|
|
33
|
+
|
|
34
|
+
The worker maintains state for:
|
|
35
|
+
- Active render requests
|
|
36
|
+
- Server action handlers
|
|
37
|
+
- Streaming connections
|
|
38
|
+
- Error boundaries
|
|
39
|
+
|
|
19
40
|
## Extending the Worker
|
|
20
41
|
|
|
21
42
|
Users can create their own RSC workers for application-level use. This allows for:
|
|
@@ -42,6 +63,130 @@ if (typeof WorkerGlobalScope !== 'undefined') {
|
|
|
42
63
|
}
|
|
43
64
|
```
|
|
44
65
|
|
|
66
|
+
## ⚠️ Advanced Configuration: Custom Loader Paths
|
|
67
|
+
|
|
68
|
+
> **Warning**: These are escape hatches for advanced users. Most users should NOT use these options as they can break React Server Components, CSS processing, or environment handling, during the rsc-worker development workflow.
|
|
69
|
+
|
|
70
|
+
The RSC worker supports custom loader paths that allow you to completely replace the core loading mechanisms:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// vite.config.ts
|
|
74
|
+
import { defineConfig } from "vite";
|
|
75
|
+
import { vitePluginReactServer } from "vite-plugin-react-server";
|
|
76
|
+
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
plugins: [
|
|
79
|
+
vitePluginReactServer({
|
|
80
|
+
// ⚠️ EXPERIMENTAL: Custom loader paths
|
|
81
|
+
reactLoaderPath: "./custom-loaders/my-react-loader.js", // Replaces React loading
|
|
82
|
+
cssLoaderPath: "./custom-loaders/my-css-loader.js", // Replaces CSS processing
|
|
83
|
+
envLoaderPath: "./custom-loaders/my-env-loader.js", // Replaces environment handling
|
|
84
|
+
|
|
85
|
+
// Legacy general loader path (discouraged)
|
|
86
|
+
loaderPath: "./custom-loaders/react-loader.js",
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Custom React Loader Example
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
// custom-loaders/my-react-loader.js
|
|
96
|
+
/**
|
|
97
|
+
* ⚠️ ADVANCED: Custom React loader
|
|
98
|
+
* This replaces the entire React loading mechanism
|
|
99
|
+
* Use at your own risk - may break RSC functionality!
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export function load(url, context, nextLoad) {
|
|
103
|
+
if (url === 'react' || url.startsWith('react/')) {
|
|
104
|
+
console.log('🚨 Intercepting React import:', url);
|
|
105
|
+
// Could redirect to different React build, but likely to break RSC
|
|
106
|
+
// return nextLoad('react@experimental', context);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return nextLoad(url, context);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Custom CSS Loader Example
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
// custom-loaders/my-css-loader.js
|
|
117
|
+
/**
|
|
118
|
+
* ⚠️ ADVANCED: Custom CSS processing
|
|
119
|
+
* This replaces the built-in CSS handling
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
export async function load(url, context, nextLoad) {
|
|
123
|
+
if (url.endsWith('.css')) {
|
|
124
|
+
console.log('🎨 Custom CSS processing:', url);
|
|
125
|
+
|
|
126
|
+
const source = await fetch(url).then(r => r.text());
|
|
127
|
+
const processed = await customCssProcessor(source);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
format: 'module',
|
|
131
|
+
source: `export default ${JSON.stringify(processed)}`,
|
|
132
|
+
shortCircuit: true
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return nextLoad(url, context);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function customCssProcessor(css) {
|
|
140
|
+
// Your custom CSS processing logic
|
|
141
|
+
return css.replace(/\/\*.*?\*\//g, ''); // Remove comments
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Why These May Not Work As Expected
|
|
146
|
+
|
|
147
|
+
These custom loader paths:
|
|
148
|
+
|
|
149
|
+
1. **Break RSC Integration**: The plugin expects specific loader behavior for React Server Components to work correctly
|
|
150
|
+
2. **Bypass Safety Checks**: Built-in loaders handle React conditions, serialization, and worker communication
|
|
151
|
+
3. **Can Cause Compatibility Issues**: Different React builds or processing might break streaming and component registration
|
|
152
|
+
4. **Are Undocumented Internal APIs**: These APIs may change without notice and could destabilize the plugin
|
|
153
|
+
|
|
154
|
+
### Safer Alternatives
|
|
155
|
+
|
|
156
|
+
Instead of completely replacing loaders, consider these safer customization options:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// vite.config.ts - Safer customization
|
|
160
|
+
export default defineConfig({
|
|
161
|
+
plugins: [
|
|
162
|
+
vitePluginReactServer({
|
|
163
|
+
// Customize loader behavior safely
|
|
164
|
+
loader: {
|
|
165
|
+
importServerPath: "my-server-imports",
|
|
166
|
+
importClientPath: "my-client-imports",
|
|
167
|
+
registerServerReferenceName: "myRegisterServer",
|
|
168
|
+
registerClientReferenceName: "myRegisterClient",
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// Custom CSS processing
|
|
172
|
+
css: {
|
|
173
|
+
inlineCss: true,
|
|
174
|
+
inlineThreshold: 1024,
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
// Event hooks for monitoring/customization
|
|
178
|
+
onEvent: (event) => {
|
|
179
|
+
if (event.type === 'css.process') {
|
|
180
|
+
console.log('CSS processed:', event.data);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
These safer alternatives provide customization without replacing core functionality.
|
|
189
|
+
|
|
45
190
|
## Future Possibilities
|
|
46
191
|
|
|
47
192
|
The RSC worker architecture is designed to be extensible. Future enhancements could include:
|
|
@@ -55,4 +200,61 @@ The RSC worker architecture is designed to be extensible. Future enhancements co
|
|
|
55
200
|
|
|
56
201
|
- The worker must be initialized with appropriate Node conditions
|
|
57
202
|
- Message handling must account for streaming data
|
|
58
|
-
- Consider memory usage when processing large RSC payloads
|
|
203
|
+
- Consider memory usage when processing large RSC payloads
|
|
204
|
+
|
|
205
|
+
### Example: Restoring Default React Server Components Loader
|
|
206
|
+
|
|
207
|
+
Here's how you can restore the default `@react-server-dom-esm-node-loader.production.js` behavior as a custom hook:
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
// custom-react-loader.js
|
|
211
|
+
import { transformSource } from 'react-server-dom-esm/node-loader';
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Custom React loader that restores default RSC behavior
|
|
215
|
+
* Just delegates to the official React Server Components loader
|
|
216
|
+
*/
|
|
217
|
+
export const load = async (url, context, defaultLoad) => {
|
|
218
|
+
// First load the file using the default loader
|
|
219
|
+
const result = await defaultLoad(url, context);
|
|
220
|
+
|
|
221
|
+
// If it's not a module or source isn't a string, return as-is
|
|
222
|
+
if (result.format !== 'module' || typeof result.source !== 'string') {
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Use the official React Server Components transformSource function
|
|
227
|
+
const transformed = await transformSource(result.source, context, (source, ctx) => ({ source }));
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
format: "module",
|
|
231
|
+
source: transformed.source,
|
|
232
|
+
shortCircuit: true
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Usage:**
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
// vite.config.ts
|
|
241
|
+
export default defineConfig({
|
|
242
|
+
plugins: [
|
|
243
|
+
react(),
|
|
244
|
+
reactServer({
|
|
245
|
+
reactLoaderPath: './custom-react-loader.js'
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
This custom loader:
|
|
252
|
+
1. **Accepts string source code** (as you mentioned)
|
|
253
|
+
2. **Parses for "use client"/"use server" directives**
|
|
254
|
+
3. **Transforms client modules** to register client references
|
|
255
|
+
4. **Transforms server modules** to register server references
|
|
256
|
+
5. **Maintains the same behavior** as the default React loader
|
|
257
|
+
|
|
258
|
+
The key requirement you mentioned is correct - the source must be a string, and this loader handles that properly while replicating the core RSC transformation logic.
|
|
259
|
+
|
|
260
|
+
// ... existing code ...
|
|
@@ -1,27 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { RscRenderMessage
|
|
1
|
+
import { resolveComponents } from "../../helpers/resolveComponents.js";
|
|
2
|
+
import type { RscRenderMessage } from "./types.js";
|
|
3
|
+
import type { StreamHandlers } from "../types.js";
|
|
3
4
|
import { activeStreams, cssFiles } from "./state.js";
|
|
4
5
|
import { createRscStream } from "../../helpers/createRscStream.js";
|
|
5
|
-
import { CssCollector } from "../../components/css-collector.js";
|
|
6
6
|
import { PassThrough } from "node:stream";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { workerData } from "node:worker_threads";
|
|
9
|
-
import { React } from "../../vendor/vendor.server.js";
|
|
10
9
|
import { hmrState } from "./state.js";
|
|
11
10
|
import { performance } from "node:perf_hooks";
|
|
12
|
-
import type {
|
|
11
|
+
import type { BuildModuleLoader, ResolvedUserOptions } from "../../types.js";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { routeToURL } from "../../utils/routeToURL.js";
|
|
14
|
+
import { createLogger, type Logger} from "vite";
|
|
13
15
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export type HandleRenderFn = <Msg extends RscRenderMessage = RscRenderMessage>(
|
|
17
|
+
msg: Msg,
|
|
18
|
+
handlers: StreamHandlers,
|
|
19
|
+
logger: Logger
|
|
20
|
+
) => Promise<void>;
|
|
21
|
+
|
|
22
|
+
export const handleRender: HandleRenderFn = async function _handleRender(
|
|
23
|
+
msg,
|
|
24
|
+
handlers,
|
|
25
|
+
logger = createLogger()
|
|
19
26
|
) {
|
|
20
|
-
|
|
21
|
-
id
|
|
22
|
-
route
|
|
23
|
-
pagePath
|
|
24
|
-
propsPath
|
|
27
|
+
const {
|
|
28
|
+
id,
|
|
29
|
+
route,
|
|
30
|
+
pagePath,
|
|
31
|
+
propsPath,
|
|
32
|
+
rootPath,
|
|
33
|
+
htmlPath,
|
|
25
34
|
pageExportName = workerData.userOptions.pageExportName,
|
|
26
35
|
propsExportName = workerData.userOptions.propsExportName,
|
|
27
36
|
projectRoot = workerData.userOptions.projectRoot,
|
|
@@ -31,41 +40,58 @@ export async function handleRender<
|
|
|
31
40
|
moduleBase = workerData.userOptions.moduleBase,
|
|
32
41
|
pipeableStreamOptions = workerData.userOptions.pipeableStreamOptions,
|
|
33
42
|
cssFiles: messageCssFiles,
|
|
34
|
-
globalCss
|
|
43
|
+
globalCss,
|
|
44
|
+
verbose = workerData.userOptions.verbose,
|
|
45
|
+
build = workerData.userOptions.build,
|
|
35
46
|
} = msg;
|
|
36
47
|
try {
|
|
37
|
-
//
|
|
38
|
-
const
|
|
48
|
+
// Create loader function for module resolution
|
|
49
|
+
const loader = async (moduleID: string) => {
|
|
50
|
+
// Handle #Page/#props suffixes
|
|
51
|
+
const [id, exportName] = moduleID.split('#');
|
|
52
|
+
if (hmrState.get(id)?.invalidated) {
|
|
53
|
+
hmrState.delete(id);
|
|
54
|
+
const res = await import(join(projectRoot, id) + `?t=${Date.now()}`)
|
|
55
|
+
if(!exportName) return res;
|
|
56
|
+
if(exportName in res) return { [exportName]: res[exportName] };
|
|
57
|
+
return res;
|
|
58
|
+
}
|
|
59
|
+
const res = await import(join(projectRoot, id))
|
|
60
|
+
if(!exportName) return res;
|
|
61
|
+
if(exportName in res) return { [exportName]: res[exportName] };
|
|
62
|
+
return res;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Load modules (page, props, and components together)
|
|
66
|
+
const componentsResult = await resolveComponents({
|
|
39
67
|
pagePath,
|
|
40
68
|
propsPath,
|
|
69
|
+
rootPath,
|
|
70
|
+
htmlPath,
|
|
41
71
|
pageExportName,
|
|
42
72
|
propsExportName,
|
|
73
|
+
rootExportName: workerData.userOptions.rootExportName,
|
|
74
|
+
htmlExportName: workerData.userOptions.htmlExportName,
|
|
43
75
|
route,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return import(join(projectRoot, id));
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return Promise.reject(error);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
76
|
+
verbose: workerData.userOptions.verbose,
|
|
77
|
+
loader: loader as BuildModuleLoader<ResolvedUserOptions>,
|
|
78
|
+
// Use components override for headless RSC streams in development
|
|
79
|
+
HtmlComponent: React.Fragment,
|
|
80
|
+
moduleBaseURL,
|
|
81
|
+
build,
|
|
82
|
+
logger,
|
|
56
83
|
});
|
|
57
|
-
if (
|
|
58
|
-
const { error,
|
|
59
|
-
|
|
84
|
+
if (componentsResult.type !== "success") {
|
|
85
|
+
const { error, reason } = componentsResult;
|
|
86
|
+
handlers.onError(id, error, { reason });
|
|
87
|
+
return; // Don't propagate the error after handling it
|
|
60
88
|
}
|
|
61
89
|
|
|
62
|
-
const { PageComponent, pageProps } =
|
|
90
|
+
const { PageComponent, pageProps, RootComponent } = componentsResult;
|
|
91
|
+
|
|
92
|
+
// Override HtmlComponent with React.Fragment for headless RSC streams in development
|
|
93
|
+
const finalHtmlComponent = React.Fragment;
|
|
63
94
|
|
|
64
|
-
const adaptedOnEvent = (event: "error" | "postpone", data: any) => {
|
|
65
|
-
if (event === "error") {
|
|
66
|
-
handlers.onError(id, data.error, data.errorInfo);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
95
|
|
|
70
96
|
if (messageCssFiles && messageCssFiles.size > 0) {
|
|
71
97
|
// if any css is added to the message, add it to the cssFiles map
|
|
@@ -73,13 +99,16 @@ export async function handleRender<
|
|
|
73
99
|
cssFiles.set(id, cssContent);
|
|
74
100
|
}
|
|
75
101
|
}
|
|
102
|
+
const url = routeToURL(route, moduleBaseURL, build.rscOutputPath);
|
|
103
|
+
|
|
76
104
|
|
|
77
105
|
// Create stream
|
|
78
106
|
const streamResult = createRscStream({
|
|
107
|
+
url: url,
|
|
79
108
|
projectRoot: projectRoot,
|
|
80
|
-
|
|
81
|
-
PageComponent,
|
|
82
|
-
|
|
109
|
+
HtmlComponent: finalHtmlComponent,
|
|
110
|
+
PageComponent: PageComponent,
|
|
111
|
+
RootComponent: RootComponent,
|
|
83
112
|
pageProps,
|
|
84
113
|
moduleBase,
|
|
85
114
|
moduleRootPath,
|
|
@@ -90,13 +119,14 @@ export async function handleRender<
|
|
|
90
119
|
// this is a stateful object, which at this point we assume contains all the css files
|
|
91
120
|
cssFiles,
|
|
92
121
|
globalCss,
|
|
93
|
-
onEvent: adaptedOnEvent,
|
|
94
122
|
pipeableStreamOptions: pipeableStreamOptions,
|
|
123
|
+
verbose,
|
|
124
|
+
logger,
|
|
95
125
|
});
|
|
96
126
|
|
|
97
127
|
if (streamResult.type !== "success") {
|
|
98
128
|
handlers.onError(id, streamResult.error);
|
|
99
|
-
return;
|
|
129
|
+
return; // Already handled the error
|
|
100
130
|
}
|
|
101
131
|
|
|
102
132
|
const { stream, metrics } = streamResult;
|
|
@@ -133,6 +163,6 @@ export async function handleRender<
|
|
|
133
163
|
});
|
|
134
164
|
} catch (error) {
|
|
135
165
|
handlers.onError(id, error as Error, { reason: `${id} render error` });
|
|
136
|
-
return
|
|
166
|
+
return; // Don't propagate the error after handling it
|
|
137
167
|
}
|
|
138
168
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sendRscWorkerMessage } from "
|
|
1
|
+
import { sendRscWorkerMessage } from "./sendRscWorkerMessage.js";
|
|
2
2
|
import type { StreamHandlers } from "../types.js";
|
|
3
3
|
import { toError } from "../../error/toError.js";
|
|
4
4
|
import { userOptions } from "./userOptions.js";
|
|
@@ -7,33 +7,39 @@ import { join } from "path";
|
|
|
7
7
|
import { ReactDOMServer } from "../../vendor/vendor.server.js";
|
|
8
8
|
import { PassThrough } from "node:stream";
|
|
9
9
|
|
|
10
|
+
// Helper function to serialize errors for worker thread communication
|
|
11
|
+
const serializeError = (error: unknown) => {
|
|
12
|
+
const err = toError(error);
|
|
13
|
+
return {
|
|
14
|
+
message: err.message,
|
|
15
|
+
name: err.name,
|
|
16
|
+
stack: err.stack,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
export const handlers: Required<StreamHandlers> = {
|
|
11
21
|
onError: (id, error, errorInfo) => {
|
|
12
22
|
sendRscWorkerMessage({
|
|
13
23
|
type: "ERROR",
|
|
14
24
|
id: id,
|
|
15
25
|
errorInfo,
|
|
16
|
-
error:
|
|
17
|
-
});
|
|
18
|
-
sendRscWorkerMessage({
|
|
19
|
-
type: "RSC_END",
|
|
20
|
-
id: id,
|
|
26
|
+
error: serializeError(error),
|
|
21
27
|
});
|
|
22
28
|
},
|
|
23
|
-
onData: (id, data
|
|
29
|
+
onData: (id, data) => {
|
|
24
30
|
sendRscWorkerMessage({
|
|
25
31
|
type: "RSC_CHUNK",
|
|
26
32
|
id: id,
|
|
27
33
|
chunk: data,
|
|
28
34
|
});
|
|
29
35
|
},
|
|
30
|
-
onEnd: (id
|
|
36
|
+
onEnd: (id) => {
|
|
31
37
|
sendRscWorkerMessage({
|
|
32
38
|
type: "RSC_END",
|
|
33
39
|
id: id,
|
|
34
40
|
});
|
|
35
41
|
},
|
|
36
|
-
onMetrics: (id
|
|
42
|
+
onMetrics: (id, metrics) => {
|
|
37
43
|
sendRscWorkerMessage({
|
|
38
44
|
type: "RSC_METRICS",
|
|
39
45
|
id: id,
|
|
@@ -65,17 +71,19 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
65
71
|
},
|
|
66
72
|
onServerActionResponse: (id, result) => {
|
|
67
73
|
const stream = ReactDOMServer.renderToPipeableStream(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
result && typeof result === "object" && "returnValue" in result
|
|
75
|
+
? result
|
|
76
|
+
: {
|
|
77
|
+
type: "server-action-response",
|
|
78
|
+
returnValue: result,
|
|
79
|
+
},
|
|
72
80
|
userOptions.moduleBasePath,
|
|
73
81
|
{
|
|
74
82
|
onError(error: Error) {
|
|
75
83
|
sendRscWorkerMessage({
|
|
76
84
|
type: "ERROR",
|
|
77
85
|
id,
|
|
78
|
-
error:
|
|
86
|
+
error: serializeError(error),
|
|
79
87
|
});
|
|
80
88
|
},
|
|
81
89
|
}
|
|
@@ -103,7 +111,7 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
103
111
|
sendRscWorkerMessage({
|
|
104
112
|
type: "ERROR",
|
|
105
113
|
id,
|
|
106
|
-
error:
|
|
114
|
+
error: serializeError(error),
|
|
107
115
|
});
|
|
108
116
|
});
|
|
109
117
|
},
|
|
@@ -137,7 +145,7 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
137
145
|
const stream = ReactDOMServer.renderToPipeableStream(
|
|
138
146
|
{
|
|
139
147
|
type: "server-action-response",
|
|
140
|
-
returnValue: result
|
|
148
|
+
returnValue: result,
|
|
141
149
|
},
|
|
142
150
|
userOptions.moduleBasePath,
|
|
143
151
|
{
|
|
@@ -145,7 +153,7 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
145
153
|
sendRscWorkerMessage({
|
|
146
154
|
type: "ERROR",
|
|
147
155
|
id,
|
|
148
|
-
error:
|
|
156
|
+
error: serializeError(error),
|
|
149
157
|
});
|
|
150
158
|
},
|
|
151
159
|
}
|
|
@@ -173,16 +181,16 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
173
181
|
sendRscWorkerMessage({
|
|
174
182
|
type: "ERROR",
|
|
175
183
|
id,
|
|
176
|
-
error:
|
|
184
|
+
error: serializeError(error),
|
|
177
185
|
});
|
|
178
186
|
});
|
|
179
187
|
} catch (error: unknown) {
|
|
180
|
-
const errorMessage =
|
|
188
|
+
const errorMessage = serializeError(error).message;
|
|
181
189
|
// Send error response using RSC stream
|
|
182
190
|
const stream = ReactDOMServer.renderToPipeableStream(
|
|
183
191
|
{
|
|
184
192
|
type: "server-action-response",
|
|
185
|
-
returnValue: { success: false, error: errorMessage }
|
|
193
|
+
returnValue: { success: false, error: errorMessage },
|
|
186
194
|
},
|
|
187
195
|
userOptions.moduleBasePath,
|
|
188
196
|
{
|
|
@@ -190,7 +198,7 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
190
198
|
sendRscWorkerMessage({
|
|
191
199
|
type: "ERROR",
|
|
192
200
|
id,
|
|
193
|
-
error:
|
|
201
|
+
error: serializeError(error),
|
|
194
202
|
});
|
|
195
203
|
},
|
|
196
204
|
}
|
|
@@ -218,7 +226,7 @@ export const handlers: Required<StreamHandlers> = {
|
|
|
218
226
|
sendRscWorkerMessage({
|
|
219
227
|
type: "ERROR",
|
|
220
228
|
id,
|
|
221
|
-
error:
|
|
229
|
+
error: serializeError(error),
|
|
222
230
|
});
|
|
223
231
|
});
|
|
224
232
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { parentPort } from "node:worker_threads";
|
|
2
|
-
import {
|
|
3
|
-
activeStreams,
|
|
4
|
-
hmrState,
|
|
5
|
-
} from "./state.js";
|
|
2
|
+
import { activeStreams, hmrState } from "./state.js";
|
|
6
3
|
import { handleRender } from "./handleRender.js";
|
|
7
|
-
import type {
|
|
8
|
-
RscWorkerInputMessage,
|
|
9
|
-
} from "../types.js";
|
|
4
|
+
import type { RscWorkerInputMessage } from "./types.js";
|
|
10
5
|
import { toError } from "../../error/toError.js";
|
|
11
6
|
import { handlers } from "./handlers.js";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { workerData } from "node:worker_threads";
|
|
9
|
+
import { sendMessage } from "../sendMessage.js";
|
|
10
|
+
import { createLogger } from "vite";
|
|
11
|
+
import { logError } from "../../error/logError.js";
|
|
12
12
|
|
|
13
13
|
// In test mode, we want errors to propagate up immediately
|
|
14
14
|
const isTestEnv = process.env["VITEST"] || process.env["NODE_ENV"] === "test";
|
|
15
15
|
const isDevEnv = process.env["NODE_ENV"] !== "production";
|
|
16
16
|
|
|
17
|
+
const logger = createLogger(workerData.resolvedConfig.logLevel ?? 'info');
|
|
17
18
|
|
|
18
19
|
export async function messageHandler(
|
|
19
20
|
msg: RscWorkerInputMessage,
|
|
@@ -25,7 +26,7 @@ export async function messageHandler(
|
|
|
25
26
|
}
|
|
26
27
|
switch (msg.type) {
|
|
27
28
|
case "RSC_RENDER":
|
|
28
|
-
return await handleRender(msg, handlers);
|
|
29
|
+
return await handleRender(msg, handlers, logger);
|
|
29
30
|
case "SERVER_ACTION":
|
|
30
31
|
return handlers.onServerAction(msg.id, msg.args);
|
|
31
32
|
case "INITIALIZED_REACT_LOADER":
|
|
@@ -54,6 +55,16 @@ export async function messageHandler(
|
|
|
54
55
|
case "SERVER_MODULE":
|
|
55
56
|
handlers.onServerModule(msg.id, msg.url, msg.source);
|
|
56
57
|
return;
|
|
58
|
+
case "MODULE_REQUEST": {
|
|
59
|
+
const { id, path } = msg;
|
|
60
|
+
try {
|
|
61
|
+
const module = await import(join(workerData.userOptions.projectRoot, path));
|
|
62
|
+
handlers.onServerModule(id, path, module);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
handlers.onError(id, toError(error));
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
57
68
|
case "SHUTDOWN": {
|
|
58
69
|
// If id is "*", clean up all render states
|
|
59
70
|
if (msg.id === "*") {
|
|
@@ -75,20 +86,19 @@ export async function messageHandler(
|
|
|
75
86
|
}
|
|
76
87
|
} catch (error) {
|
|
77
88
|
const err = toError(error);
|
|
78
|
-
if (isDevEnv) {
|
|
79
|
-
console.error(err);
|
|
80
|
-
}
|
|
81
89
|
// In dev mode, try to send error message before exiting
|
|
82
90
|
if (parentPort) {
|
|
83
|
-
|
|
91
|
+
sendMessage({
|
|
84
92
|
type: "ERROR",
|
|
85
93
|
id: "rsc-worker",
|
|
86
94
|
error: err,
|
|
87
|
-
});
|
|
95
|
+
}, port);
|
|
88
96
|
}
|
|
89
97
|
if (!isDevEnv || isTestEnv) {
|
|
90
98
|
// In test mode or production mode, just throw the error to fail fast
|
|
91
99
|
throw err;
|
|
100
|
+
} else {
|
|
101
|
+
logError(err, logger);
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
}
|