vite-plugin-react-server 1.1.20 → 1.2.0-alpha.0
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 +102 -395
- package/dist/_virtual/dynamic-import-helper.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -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 +199 -121
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +155 -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.map +1 -1
- package/dist/plugin/config/resolveEnv.js +14 -4
- 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 +228 -206
- 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 +86 -40
- 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 +111 -93
- 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 +47 -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 -4
- 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 +48 -14
- 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 +70 -7
- 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 +5 -2
- 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 +28 -1
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +43 -30
- 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 +137 -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 +97 -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 +11 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeModule.js +34 -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 +11 -0
- package/dist/plugin/loader/env-loader.d.ts.map +1 -0
- package/dist/plugin/loader/env-loader.js +65 -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 +11 -2
- package/dist/plugin/loader/parse.d.ts.map +1 -1
- package/dist/plugin/loader/parse.js +29 -6
- 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 +10 -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 +33 -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/transformServerModule.d.ts +11 -0
- package/dist/plugin/loader/transformServerModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformServerModule.js +84 -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 +18 -0
- package/dist/plugin/loader/types.d.ts +59 -12
- 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 +30 -17
- 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 +7 -4
- 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 +33 -29
- 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 +25 -14
- 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 +59 -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 +12 -10
- 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 +98 -43
- 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 +14 -17
- 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 +38 -31
- 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 +33 -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.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 +43 -44
- 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 +452 -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.js +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 +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 +4 -3
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +54 -32
- 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 +16 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js +77 -11
- package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
- 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 +58 -25
- 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 +184 -95
- 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 +5 -10
- package/plugin/config/resolveOptions.ts +415 -299
- 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 +417 -351
- package/plugin/env/plugin.ts +71 -7
- 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 +45 -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 +41 -20
- package/plugin/helpers/createEventHandler.ts +1 -1
- package/plugin/helpers/createHandler.ts +40 -12
- package/plugin/helpers/createRscStream.tsx +97 -35
- package/plugin/helpers/formatMetrics.ts +2 -37
- package/plugin/helpers/getBundleManifest.ts +10 -1
- package/plugin/helpers/getRouteFiles.ts +112 -8
- package/plugin/helpers/handleServerAction.ts +10 -6
- 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 +72 -52
- package/plugin/helpers/requestToRoute.ts +38 -12
- package/plugin/helpers/resolveComponent.ts +173 -0
- package/plugin/helpers/resolveComponents.ts +185 -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 +118 -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 +39 -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.development.ts → env-loader.ts} +8 -22
- package/plugin/loader/index.ts +8 -6
- package/plugin/loader/parse.ts +42 -12
- package/plugin/loader/react-loader.ts +255 -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 +64 -0
- package/plugin/loader/transformModule.ts +54 -0
- package/plugin/loader/transformModuleIfNeeded.ts +40 -40
- package/plugin/loader/transformServerModule.ts +136 -0
- package/plugin/loader/transformWithAcornLoose.ts +27 -0
- package/plugin/loader/types.ts +65 -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 +39 -15
- package/plugin/plugin.server.ts +39 -18
- package/plugin/preserver/plugin.ts +42 -42
- package/plugin/react-client/cleanupWorkerServerAction.ts +33 -0
- package/plugin/react-client/configureWorkerRequestHandler.ts +212 -201
- package/plugin/react-client/createMessageHandlers.ts +17 -3
- package/plugin/react-client/createWorkerStream.ts +55 -51
- package/plugin/react-client/handleWorkerRscStream.ts +141 -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 +75 -70
- package/plugin/react-server/configureReactServer.ts +200 -142
- package/plugin/react-server/handleServerAction.ts +156 -160
- package/plugin/react-server/plugin.ts +18 -25
- package/plugin/react-static/collectHtmlWorkerContent.ts +109 -102
- package/plugin/react-static/collectRscContent.ts +55 -51
- package/plugin/react-static/configurePreviewServer.ts +110 -100
- package/plugin/react-static/createBuildLoader.ts +157 -48
- package/plugin/react-static/plugin.ts +368 -357
- package/plugin/react-static/renderPage.ts +43 -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.server.ts +55 -82
- 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 +685 -309
- package/plugin/utils/createCallServer.ts +5 -5
- package/plugin/utils/createReactFetcher.ts +4 -6
- package/plugin/utils/index.ts +2 -1
- package/plugin/utils/routeToURL.ts +34 -0
- package/plugin/utils/urls.ts +9 -6
- 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 +76 -39
- package/plugin/worker/rsc/handlers.ts +30 -22
- package/plugin/worker/rsc/index.ts +2 -0
- package/plugin/worker/rsc/messageHandler.tsx +17 -10
- package/plugin/worker/rsc/rsc-worker.development.ts +104 -17
- 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/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/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.client.d.ts +0 -2
- package/dist/plugin/transformer/plugin.client.d.ts.map +0 -1
- 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/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/source-map/createMappingsSerializer.ts +0 -181
- package/plugin/source-map/readMappings.ts +0 -194
- package/plugin/transformer/plugin.client.ts +0 -0
- /package/dist/plugin/{transformer/plugin.client.js → loader/directives/types.js} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # RSC Boundary Handling
|
|
3
|
+
*
|
|
4
|
+
* This file provides the core transformation logic for React Server Components (RSC) boundaries.
|
|
5
|
+
*
|
|
6
|
+
* ## Error Behavior
|
|
7
|
+
*
|
|
8
|
+
* - If a client component is imported on the server, the export is a function that throws a clear error.
|
|
9
|
+
* - If a server action is imported on the client, the export is a function that throws a clear error.
|
|
10
|
+
*
|
|
11
|
+
* This ensures that implementation details are never leaked across boundaries and errors are easy to debug.
|
|
12
|
+
*/
|
|
13
|
+
import type { ParseResult } from "./directives/types.js";
|
|
14
|
+
import { transformServerModule } from "./transformServerModule.js";
|
|
15
|
+
import { transformClientModule } from "./transformClientModule.js";
|
|
16
|
+
import type { TransformFunction, TransformOptions, TransformResult } from "./types.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Transforms a module for RSC boundaries, handling imports and registrations.
|
|
20
|
+
*/
|
|
21
|
+
export const transformModule: TransformFunction = async (
|
|
22
|
+
source: string,
|
|
23
|
+
moduleId: string,
|
|
24
|
+
parseResult: ParseResult,
|
|
25
|
+
options: TransformOptions
|
|
26
|
+
): Promise<TransformResult> => {
|
|
27
|
+
if (parseResult.type !== 'success') {
|
|
28
|
+
if(options.verbose) {
|
|
29
|
+
console.log(`[transformModule] Parse error:`, parseResult.error);
|
|
30
|
+
}
|
|
31
|
+
return { code: '', map: null };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (options.verbose) {
|
|
35
|
+
console.log(`[transformModule] Module: ${moduleId}`);
|
|
36
|
+
console.log(`[transformModule] Directives:`, parseResult.directiveInfo);
|
|
37
|
+
console.log(
|
|
38
|
+
`[transformModule] isServerFunction:`,
|
|
39
|
+
options.forceServerFunction,
|
|
40
|
+
`isClientComponent:`,
|
|
41
|
+
options.forceClientComponent
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Only apply transformation for server functions or client components
|
|
46
|
+
if (!(options.forceServerFunction || options.forceClientComponent)) {
|
|
47
|
+
return { code: source, map: null };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Transform based on module type and return the result directly
|
|
51
|
+
return options.forceServerFunction
|
|
52
|
+
? transformServerModule(source, moduleId, parseResult, options.loader, options.verbose)
|
|
53
|
+
: transformClientModule(source, moduleId, parseResult, options.loader, options.verbose);
|
|
54
|
+
};
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { transformWithAcornLoose } from "./transformWithAcornLoose.js";
|
|
2
|
+
import type { RawSourceMap } from "source-map";
|
|
3
|
+
import type { TransformOptions } from "./types.js";
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
// --- React RSC Directive Handling ---
|
|
7
7
|
//
|
|
8
|
-
// 1. 'use client' at file top:
|
|
8
|
+
// 1. 'use client' at file top of NON-SERVER environment:
|
|
9
9
|
// - Pass through code as-is (after removing directive).
|
|
10
10
|
// - Do not transform or register anything.
|
|
11
|
-
// -
|
|
11
|
+
// - Remove the directive.
|
|
12
12
|
// - See: https://react.dev/reference/rsc/use-client
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// -
|
|
13
|
+
// 2. 'use client' at file top of SERVER environment:
|
|
14
|
+
// - Remove implementation of client components.
|
|
15
|
+
// - Import registerClientReference.
|
|
16
|
+
// - Register client components as error-throwing functions.
|
|
17
|
+
// - Always a export const ${registrationName} = registerClientReference(...)
|
|
18
|
+
// - See: https://react.dev/reference/rsc/use-client
|
|
19
|
+
// 3. 'use server' at file top:
|
|
20
|
+
// - import registerServerReference.
|
|
21
|
+
// - Append registrations to bottom of file.
|
|
22
|
+
// - Register all exported functions as server actions.
|
|
23
|
+
// - Do not re-export, just append to bottom of file registerServerReference(...).
|
|
16
24
|
// - See: https://react.dev/reference/rsc/use-server
|
|
17
25
|
//
|
|
18
26
|
// 3. 'use server' at function top:
|
|
19
|
-
// -
|
|
27
|
+
// - add import registerServerReference.
|
|
28
|
+
// - Register only that/those functions as a server action.
|
|
20
29
|
// - See: https://react.dev/reference/rsc/use-server
|
|
21
30
|
//
|
|
22
|
-
// 4. No directive
|
|
23
|
-
// - Treat as
|
|
31
|
+
// 4. No directive or no exported boundary functions
|
|
32
|
+
// - Treat as server-only module.
|
|
33
|
+
// - Do not allow on client, only use client is allowed on client.
|
|
24
34
|
// - No special registration or transformation.
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Transforms a module and returns the transformed code with source map attached.
|
|
38
|
+
* This is used by the loader to transform modules and attach source maps.
|
|
39
|
+
*
|
|
40
|
+
* @returns The transformed code with source map attached as a URL comment
|
|
41
|
+
*/
|
|
42
|
+
export async function transformModuleIfNeeded(
|
|
27
43
|
source: string,
|
|
28
44
|
moduleId: string,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isServerEnvironment = getCondition() === "react-server"
|
|
32
|
-
) {
|
|
33
|
-
// Handle environment-specific cases
|
|
34
|
-
if (isServerEnvironment) {
|
|
35
|
-
// In server environment:
|
|
36
|
-
// - Server functions need transformation
|
|
37
|
-
// - Client components need transformation
|
|
38
|
-
// - Other modules can pass through
|
|
39
|
-
if (!isServerFunction && !isClientComponent) {
|
|
40
|
-
return source;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
// In client environment:
|
|
44
|
-
// - Only client components should pass through
|
|
45
|
-
// - Server functions should be transformed
|
|
46
|
-
if (isClientComponent) {
|
|
47
|
-
return source;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
45
|
+
options: TransformOptions
|
|
46
|
+
): Promise<{ code: string; map: RawSourceMap | null }> {
|
|
51
47
|
try {
|
|
52
|
-
|
|
48
|
+
// Get transformed code and source map from acorn-loose transformer
|
|
49
|
+
const result = await transformWithAcornLoose(
|
|
53
50
|
source,
|
|
54
51
|
moduleId,
|
|
55
|
-
|
|
56
|
-
isServerFunction,
|
|
57
|
-
isClientComponent
|
|
52
|
+
options
|
|
58
53
|
);
|
|
54
|
+
|
|
55
|
+
if(options.verbose) {
|
|
56
|
+
console.log("[transformModuleIfNeeded] Transformed module:", { code: result.code, map: result.map });
|
|
57
|
+
}
|
|
58
|
+
// Return the transformed code with source map attached as a URL comment
|
|
59
59
|
return result;
|
|
60
60
|
} catch (error) {
|
|
61
61
|
// Log the error and rethrow
|
|
62
|
-
console.error(`Error transforming module ${moduleId}:`, error);
|
|
62
|
+
console.error(`[transformModuleIfNeeded] Error transforming module ${moduleId}:`, error);
|
|
63
63
|
throw error;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ParseResult, Program } from "./directives/types.js";
|
|
2
|
+
import type { ResolvedUserOptions } from "../types.js";
|
|
3
|
+
import { createSourceMap } from "./sourceMap.js";
|
|
4
|
+
import type { TransformResult } from "./types.js";
|
|
5
|
+
import { removeDirectives } from "./removeDirectives.js";
|
|
6
|
+
import * as acorn from "acorn";
|
|
7
|
+
import { getNodeEnv } from "../getNodeEnv.js";
|
|
8
|
+
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
9
|
+
import type { ArrowFunctionExpression, FunctionDeclaration, FunctionExpression } from "acorn";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Transforms a server module by:
|
|
13
|
+
* 1. Parsing it to get exports and directives
|
|
14
|
+
* 2. Collecting function-level server directives
|
|
15
|
+
* 3. Registering server functions
|
|
16
|
+
*/
|
|
17
|
+
export async function transformServerModule(
|
|
18
|
+
source: string,
|
|
19
|
+
moduleId: string,
|
|
20
|
+
parseResult: ParseResult,
|
|
21
|
+
loader: Pick<
|
|
22
|
+
ResolvedUserOptions["loader"],
|
|
23
|
+
"registerServerReferenceName" | "importServerPath"
|
|
24
|
+
> = DEFAULT_CONFIG.RSC_LOADER[getNodeEnv()],
|
|
25
|
+
verbose = false
|
|
26
|
+
): Promise<TransformResult> {
|
|
27
|
+
if (!loader) {
|
|
28
|
+
loader = DEFAULT_CONFIG.RSC_LOADER[getNodeEnv()];
|
|
29
|
+
}
|
|
30
|
+
if (parseResult.type !== "success") {
|
|
31
|
+
return { code: "", map: null };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Parse the source with Acorn to get accurate directive locations
|
|
35
|
+
const ast = acorn.parse(source, {
|
|
36
|
+
ecmaVersion: "latest",
|
|
37
|
+
sourceType: "module",
|
|
38
|
+
locations: true,
|
|
39
|
+
ranges: true,
|
|
40
|
+
allowAwaitOutsideFunction: true,
|
|
41
|
+
allowReturnOutsideFunction: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Collect all directive ranges (file-level and function-level)
|
|
45
|
+
const rangesToRemove: { start: number; end: number }[] = [];
|
|
46
|
+
|
|
47
|
+
// File-level: top-level ExpressionStatement with directive
|
|
48
|
+
for (const node of ast.body) {
|
|
49
|
+
if (
|
|
50
|
+
node.type === "ExpressionStatement" &&
|
|
51
|
+
node.directive === "use server"
|
|
52
|
+
) {
|
|
53
|
+
rangesToRemove.push({ start: node.start, end: node.end });
|
|
54
|
+
}
|
|
55
|
+
// Stop at first non-directive
|
|
56
|
+
if (node.type !== "ExpressionStatement" || !node.directive) break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Function-level: walk all functions and check first statement in body
|
|
60
|
+
function walkFunctionDirectives(node: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression | Program) {
|
|
61
|
+
if (
|
|
62
|
+
(node.type === "FunctionDeclaration" ||
|
|
63
|
+
node.type === "FunctionExpression" ||
|
|
64
|
+
node.type === "ArrowFunctionExpression") &&
|
|
65
|
+
node.body &&
|
|
66
|
+
node.body.type === "BlockStatement" &&
|
|
67
|
+
node.body.body.length > 0
|
|
68
|
+
) {
|
|
69
|
+
const first = node.body.body[0];
|
|
70
|
+
if (
|
|
71
|
+
first.type === "ExpressionStatement" &&
|
|
72
|
+
first.expression.type === "Literal" &&
|
|
73
|
+
first.expression.value === "use server"
|
|
74
|
+
) {
|
|
75
|
+
rangesToRemove.push({ start: first.start, end: first.end });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Recurse into child nodes
|
|
79
|
+
for (const key in node) {
|
|
80
|
+
const value = node[key as keyof typeof node];
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
value.forEach((item) => {
|
|
83
|
+
if (item && typeof item === 'object' && 'type' in item) {
|
|
84
|
+
walkFunctionDirectives(item as any);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else if (value && typeof value === 'object' && 'type' in value) {
|
|
88
|
+
walkFunctionDirectives(value as any);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
walkFunctionDirectives(ast);
|
|
93
|
+
|
|
94
|
+
if (verbose) {
|
|
95
|
+
console.log(`[transformServerModule] Ranges to remove:`, rangesToRemove);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Remove directives from the source code using the shared utility
|
|
99
|
+
const transformedCode = removeDirectives(source, rangesToRemove);
|
|
100
|
+
|
|
101
|
+
// Register all exports as server references
|
|
102
|
+
const registrations = [];
|
|
103
|
+
for (const exp of parseResult.exports.exports.values()) {
|
|
104
|
+
// Check if any exports have server directives
|
|
105
|
+
const hasServerDirective = parseResult.directiveInfo.functionLevel.some(
|
|
106
|
+
(d) => d.type === "server" && d.name === exp.localName
|
|
107
|
+
);
|
|
108
|
+
// Register if it has its own server directive or if there's a file-level directive
|
|
109
|
+
if (
|
|
110
|
+
hasServerDirective ||
|
|
111
|
+
parseResult.directiveInfo.fileLevel?.type === "server"
|
|
112
|
+
) {
|
|
113
|
+
// Use original module ID for re-exports, current module ID for local exports
|
|
114
|
+
const targetModuleId = exp.originalModuleId || moduleId;
|
|
115
|
+
registrations.push(
|
|
116
|
+
`${loader?.registerServerReferenceName}(${exp.localName}, "${targetModuleId}", "${exp.exportName}");`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Only add the import and registrations if there are any registrations to make
|
|
122
|
+
const finalCode =
|
|
123
|
+
registrations.length > 0
|
|
124
|
+
? `\n import { ${loader?.registerServerReferenceName} } from "${
|
|
125
|
+
loader?.importServerPath
|
|
126
|
+
}";\n ${transformedCode}\n ${registrations.join("\n")}\n `
|
|
127
|
+
: transformedCode;
|
|
128
|
+
|
|
129
|
+
// Create source map based on the final transformed code
|
|
130
|
+
const map = createSourceMap(finalCode, source, moduleId, []);
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
code: finalCode,
|
|
134
|
+
map,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createTransformer } from "./createTransformer.js";
|
|
2
|
+
import type { RawSourceMap } from "source-map";
|
|
3
|
+
import { parse } from "./parse.js";
|
|
4
|
+
import type { TransformOptions } from "./types.js";
|
|
5
|
+
|
|
6
|
+
export type TransformWithAcornLooseFn = (
|
|
7
|
+
source: string,
|
|
8
|
+
moduleId: string,
|
|
9
|
+
options: TransformOptions
|
|
10
|
+
) => Promise<{ code: string; map: RawSourceMap | null }>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Transforms a module using acorn-loose for parsing.
|
|
14
|
+
* @returns Object containing the transformed code and its source map
|
|
15
|
+
*/
|
|
16
|
+
export const transformWithAcornLoose: TransformWithAcornLooseFn =
|
|
17
|
+
async function _transformWithAcornLoose(
|
|
18
|
+
source: string,
|
|
19
|
+
moduleId: string,
|
|
20
|
+
options: TransformOptions
|
|
21
|
+
): Promise<{ code: string; map: RawSourceMap | null }> {
|
|
22
|
+
const transformer = createTransformer({
|
|
23
|
+
parseFn: parse,
|
|
24
|
+
options,
|
|
25
|
+
});
|
|
26
|
+
return transformer(source, moduleId);
|
|
27
|
+
};
|
package/plugin/loader/types.ts
CHANGED
|
@@ -1,18 +1,70 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawSourceMap } from "source-map";
|
|
2
|
+
import type { DirectiveWarning, ParseResult, Program, AllowedDirectives } from "./directives/types.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type LoaderConfig = {
|
|
7
|
+
serverDirective: RegExp;
|
|
8
|
+
clientDirective: RegExp;
|
|
9
|
+
allowedDirectives: AllowedDirectives;
|
|
10
|
+
getDirectiveType: (
|
|
11
|
+
directive: string,
|
|
12
|
+
moduleId?: string
|
|
13
|
+
) => "client" | "server" | undefined;
|
|
14
|
+
mode: "development" | "production" | "test";
|
|
15
|
+
importServerPath: string;
|
|
16
|
+
importClientPath: string;
|
|
17
|
+
registerClientReferenceName: string;
|
|
18
|
+
registerServerReferenceName: string;
|
|
19
|
+
isServerFunctionCode: (code: string, moduleId?: string) => boolean;
|
|
20
|
+
isClientComponentCode: (code: string, moduleId?: string) => boolean;
|
|
21
|
+
parse: (source: string) => Promise<{
|
|
22
|
+
ast: Program;
|
|
23
|
+
code: string;
|
|
24
|
+
map?: { url: string; start: number; end: number; lines: number } | null;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type RscLoader = Pick<LoaderConfig, 'importServerPath' | 'importClientPath' | 'registerClientReferenceName' | 'registerServerReferenceName'>;
|
|
29
|
+
|
|
30
|
+
export type TransformOptions = {
|
|
31
|
+
forceServerFunction?: boolean;
|
|
32
|
+
forceClientComponent?: boolean;
|
|
33
|
+
isServerEnvironment?: boolean;
|
|
34
|
+
loader?: LoaderConfig;
|
|
35
|
+
directiveWarnings?: DirectiveWarning[];
|
|
36
|
+
// based on warning, remove warning directive index to avoid warning in development
|
|
37
|
+
removeDirectives?: number[];
|
|
38
|
+
// based on warning, add warning directive index to avoid warning in development
|
|
39
|
+
addDirectives?: number[];
|
|
40
|
+
verbose?: boolean;
|
|
41
|
+
panicThreshold?: 'none' | 'critical_errors' | 'all_errors';
|
|
42
|
+
mode?: "development" | "production" | "test";
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type TransformResult = {
|
|
46
|
+
code: string;
|
|
47
|
+
map: RawSourceMap | null;
|
|
6
48
|
};
|
|
7
49
|
|
|
8
|
-
export type
|
|
50
|
+
export type TransformFunction = (
|
|
51
|
+
source: string,
|
|
52
|
+
moduleId: string,
|
|
53
|
+
parseResult: ParseResult,
|
|
54
|
+
options: TransformOptions
|
|
55
|
+
) => Promise<TransformResult>;
|
|
9
56
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
57
|
+
export type TransformerFactory = (options: {
|
|
58
|
+
parseFn?: (source: string) => Promise<{ ast: Program; code: string; map?: {
|
|
59
|
+
url: string;
|
|
60
|
+
start: number;
|
|
61
|
+
end: number;
|
|
62
|
+
lines: number;
|
|
63
|
+
} | null }>;
|
|
64
|
+
options: Pick<TransformOptions, 'verbose' | 'loader' | 'panicThreshold'>;
|
|
65
|
+
forceServerFunction?: boolean | undefined;
|
|
66
|
+
forceClientComponent?: boolean | undefined;
|
|
67
|
+
isServerEnvironment?: boolean;
|
|
68
|
+
}) => (source: string, moduleId: string) => Promise<TransformResult>;
|
|
17
69
|
|
|
18
|
-
export type Program
|
|
70
|
+
export type { Program };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import type { PipeableStream } from "react-dom/server";
|
|
3
|
+
import { createStreamMetrics } from "./createStreamMetrics.js";
|
|
4
|
+
import type { StreamMetrics } from "./types.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a transform stream that collects metrics from the input stream
|
|
8
|
+
* @param stream The stream to collect metrics from
|
|
9
|
+
* @returns A promise that resolves with the metrics when the stream ends
|
|
10
|
+
*/
|
|
11
|
+
export function collectStreamMetrics(stream: PipeableStream | NodeJS.ReadableStream): Promise<StreamMetrics> {
|
|
12
|
+
const metrics = createStreamMetrics();
|
|
13
|
+
const startTime = performance.now()
|
|
14
|
+
|
|
15
|
+
return new Promise<StreamMetrics>((resolve, reject) => {
|
|
16
|
+
const transform = new Transform({
|
|
17
|
+
transform(chunk, _encoding, callback) {
|
|
18
|
+
metrics.chunks++;
|
|
19
|
+
metrics.bytes += chunk.length;
|
|
20
|
+
callback(null, chunk);
|
|
21
|
+
},
|
|
22
|
+
flush(callback) {
|
|
23
|
+
metrics.duration = Date.now() - startTime;
|
|
24
|
+
callback();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
stream.pipe(transform);
|
|
29
|
+
|
|
30
|
+
transform.on("error", (error) => {
|
|
31
|
+
reject(error);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
transform.on("end", () => {
|
|
35
|
+
resolve(metrics);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createStreamMetrics } from "./createStreamMetrics.js";
|
|
2
|
+
import type { RenderMetrics } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export function createRenderMetrics(route: string): RenderMetrics {
|
|
5
|
+
return {
|
|
6
|
+
route,
|
|
7
|
+
htmlSize: 0,
|
|
8
|
+
rscSize: 0,
|
|
9
|
+
processingTime: 0,
|
|
10
|
+
chunks: 0,
|
|
11
|
+
chunkRate: 0,
|
|
12
|
+
memoryUsage: process.memoryUsage(),
|
|
13
|
+
streamMetrics: createStreamMetrics(),
|
|
14
|
+
htmlSizes: new Map(),
|
|
15
|
+
rscSizes: new Map(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StreamMetrics } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export function createStreamMetrics(): StreamMetrics {
|
|
4
|
+
return {
|
|
5
|
+
chunks: 0,
|
|
6
|
+
bytes: 0,
|
|
7
|
+
backpressureCount: 0,
|
|
8
|
+
drainCount: 0,
|
|
9
|
+
errorCount: 0,
|
|
10
|
+
duration: 0,
|
|
11
|
+
startTime: performance.now()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RenderMetrics } from "
|
|
1
|
+
import type { RenderMetrics } from "./types.js";
|
|
2
2
|
|
|
3
3
|
export function formatMetrics(metrics: RenderMetrics): string {
|
|
4
4
|
const {
|
|
@@ -41,8 +41,8 @@ export function metricWatcher({
|
|
|
41
41
|
}: {
|
|
42
42
|
maxTime?: number;
|
|
43
43
|
warnOnly?: boolean;
|
|
44
|
-
warn?: (...args:
|
|
45
|
-
info?: (...args:
|
|
44
|
+
warn?: (...args: unknown[]) => void;
|
|
45
|
+
info?: (...args: unknown[]) => void;
|
|
46
46
|
}) {
|
|
47
47
|
return (metrics: RenderMetrics) => {
|
|
48
48
|
if (metrics.processingTime > maxTime) {
|
|
@@ -60,3 +60,7 @@ export function metricWatcher({
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
export function logMetrics(metrics: RenderMetrics, logger: {info: (message: string) => void} = console) {
|
|
65
|
+
logger.info(formatMetrics(metrics));
|
|
66
|
+
}
|
package/plugin/metrics/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
export type StreamMetrics = {
|
|
3
|
+
chunks: number;
|
|
4
|
+
bytes: number;
|
|
5
|
+
backpressureCount: number;
|
|
6
|
+
drainCount: number;
|
|
7
|
+
errorCount: number;
|
|
8
|
+
duration: number;
|
|
9
|
+
startTime: number;
|
|
10
|
+
route?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type RenderMetrics = {
|
|
14
|
+
route: string;
|
|
15
|
+
htmlSize: number;
|
|
16
|
+
rscSize: number;
|
|
17
|
+
processingTime: number;
|
|
18
|
+
chunks: number;
|
|
19
|
+
chunkRate: number;
|
|
20
|
+
memoryUsage: NodeJS.MemoryUsage;
|
|
21
|
+
streamMetrics: StreamMetrics;
|
|
22
|
+
htmlSizes: Map<string, number>;
|
|
23
|
+
rscSizes: Map<string, number>;
|
|
24
|
+
};
|
package/plugin/plugin.client.ts
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import { reactPreservePlugin } from "./preserver/plugin.js";
|
|
2
|
-
import type {
|
|
3
|
-
StreamPluginOptions,
|
|
4
|
-
InlineCssOpt,
|
|
5
|
-
PagePropOpt,
|
|
6
|
-
} from "../types.js";
|
|
2
|
+
import type { StreamPluginOptions } from "../types.js";
|
|
7
3
|
import { reactClientPlugin } from "./react-client/plugin.js";
|
|
8
4
|
import { envPlugin } from "./env/plugin.js";
|
|
5
|
+
import type { Plugin } from "vite";
|
|
9
6
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
export type VitePluginReactClientFn = <
|
|
8
|
+
Opt extends StreamPluginOptions = StreamPluginOptions
|
|
9
|
+
>(
|
|
10
|
+
options: Opt
|
|
11
|
+
) => Plugin[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Vite plugin for the React client, use same name to support dynamic import.
|
|
15
|
+
* Includes:
|
|
16
|
+
* - envPlugin
|
|
17
|
+
* - reactClientPlugin
|
|
18
|
+
* - reactPreservePlugin
|
|
19
|
+
* @param options
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export const vitePluginReactServer: VitePluginReactClientFn =
|
|
23
|
+
function _vitePluginReactClient(options) {
|
|
24
|
+
if (options == null) {
|
|
25
|
+
throw new Error("options is required");
|
|
26
|
+
}
|
|
27
|
+
return [
|
|
28
|
+
envPlugin(),
|
|
29
|
+
reactClientPlugin(options),
|
|
30
|
+
reactPreservePlugin(options),
|
|
31
|
+
];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Vite plugin for the React client, use specific name to support static import (that doesn't conflict with vitePluginReactServer)
|
|
36
|
+
* Includes:
|
|
37
|
+
* - envPlugin
|
|
38
|
+
* - reactClientPlugin
|
|
39
|
+
* - reactPreservePlugin
|
|
40
|
+
* @param options
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export const vitePluginReactClient = vitePluginReactServer;
|
package/plugin/plugin.server.ts
CHANGED
|
@@ -1,31 +1,52 @@
|
|
|
1
1
|
import { reactPreservePlugin } from "./preserver/plugin.js";
|
|
2
2
|
import { reactStaticPlugin } from "./react-static/plugin.js";
|
|
3
3
|
import { reactTransformPlugin } from "./transformer/plugin.server.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
StreamPluginOptions,
|
|
6
|
+
} from "./types.js";
|
|
5
7
|
import { reactServerPlugin } from "./react-server/plugin.js";
|
|
6
8
|
import { envPlugin } from "./env/plugin.js";
|
|
9
|
+
import type { Plugin } from "vite";
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
T extends PagePropOpt = PagePropOpt,
|
|
11
|
-
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
11
|
+
export type VitePluginReactServerFn = <
|
|
12
|
+
Opt extends StreamPluginOptions = StreamPluginOptions
|
|
12
13
|
>(
|
|
13
|
-
options
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
options: Opt
|
|
15
|
+
) => Plugin[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Vite plugin for the React server, use same name to support dynamic import.
|
|
19
|
+
* Includes:
|
|
20
|
+
* - envPlugin
|
|
21
|
+
* - reactTransformPlugin
|
|
22
|
+
* - reactServerPlugin
|
|
23
|
+
* - reactStaticPlugin (if build.pages is not empty)
|
|
24
|
+
* - reactPreservePlugin
|
|
25
|
+
*/
|
|
26
|
+
export const vitePluginReactServer: VitePluginReactServerFn =
|
|
27
|
+
function _vitePluginReactServer(
|
|
28
|
+
options
|
|
29
|
+
) {
|
|
30
|
+
if(options == null) {
|
|
31
|
+
throw new Error("options is required");
|
|
32
|
+
}
|
|
33
|
+
if (
|
|
34
|
+
!options.build?.pages ||
|
|
35
|
+
(Array.isArray(options.build.pages) && options.build.pages.length === 0)
|
|
36
|
+
) {
|
|
37
|
+
// in this case we do not need the static plugin at all
|
|
38
|
+
return [
|
|
39
|
+
envPlugin(),
|
|
40
|
+
reactTransformPlugin(options),
|
|
41
|
+
reactServerPlugin(options),
|
|
42
|
+
reactPreservePlugin(options),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
17
45
|
return [
|
|
18
46
|
envPlugin(),
|
|
19
47
|
reactTransformPlugin(options),
|
|
20
48
|
reactServerPlugin(options),
|
|
49
|
+
reactStaticPlugin(options),
|
|
21
50
|
reactPreservePlugin(options),
|
|
22
51
|
];
|
|
23
|
-
}
|
|
24
|
-
return [
|
|
25
|
-
envPlugin(),
|
|
26
|
-
reactTransformPlugin(options),
|
|
27
|
-
reactServerPlugin(options),
|
|
28
|
-
reactStaticPlugin(options),
|
|
29
|
-
reactPreservePlugin(options),
|
|
30
|
-
];
|
|
31
|
-
}
|
|
52
|
+
};
|