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,8 +2,10 @@ import type { ResolvedConfig, ViteDevServer } from "vite";
|
|
|
2
2
|
import type {
|
|
3
3
|
AutoDiscoveredFiles,
|
|
4
4
|
ResolvedUserOptions,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
SerializableRecord,
|
|
6
|
+
ResolvedUserConfig,
|
|
7
|
+
SerializedUserOptions,
|
|
8
|
+
Serializable,
|
|
7
9
|
} from "../types.js";
|
|
8
10
|
import { cleanObject } from "./cleanObject.js";
|
|
9
11
|
|
|
@@ -84,7 +86,7 @@ const PLUGIN_NON_SERIALIZABLE_FUNCTIONS = new Set([
|
|
|
84
86
|
"Page",
|
|
85
87
|
"props",
|
|
86
88
|
"normalizer",
|
|
87
|
-
"
|
|
89
|
+
"Root",
|
|
88
90
|
"Html",
|
|
89
91
|
"onEvent",
|
|
90
92
|
"onMetrics",
|
|
@@ -100,60 +102,129 @@ function serializeRegExp(regex: RegExp) {
|
|
|
100
102
|
return {
|
|
101
103
|
source: regex.source,
|
|
102
104
|
flags: regex.flags,
|
|
103
|
-
__isRegExp: true
|
|
105
|
+
__isRegExp: true,
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
// Helper function to deserialize RegExp objects
|
|
108
|
-
export function deserializeRegExp(obj:
|
|
109
|
-
if (
|
|
110
|
-
|
|
110
|
+
export function deserializeRegExp<T>(obj: T): Extract<T, SerializableRecord> {
|
|
111
|
+
if (
|
|
112
|
+
obj &&
|
|
113
|
+
typeof obj === "object" &&
|
|
114
|
+
obj != null &&
|
|
115
|
+
"__isRegExp" in obj &&
|
|
116
|
+
typeof obj["__isRegExp"] === "boolean" &&
|
|
117
|
+
"source" in obj &&
|
|
118
|
+
typeof obj["source"] === "string" &&
|
|
119
|
+
"flags" in obj &&
|
|
120
|
+
typeof obj["flags"] === "string"
|
|
121
|
+
) {
|
|
122
|
+
return new RegExp(obj["source"], obj["flags"]) as unknown as Extract<
|
|
123
|
+
T,
|
|
124
|
+
SerializableRecord
|
|
125
|
+
>;
|
|
111
126
|
}
|
|
112
127
|
if (Array.isArray(obj)) {
|
|
113
|
-
return obj.map(deserializeRegExp)
|
|
128
|
+
return obj.map(deserializeRegExp) as unknown as Extract<
|
|
129
|
+
T,
|
|
130
|
+
SerializableRecord
|
|
131
|
+
>;
|
|
114
132
|
}
|
|
115
|
-
if (obj && typeof obj ===
|
|
116
|
-
const result:
|
|
133
|
+
if (obj && typeof obj === "object") {
|
|
134
|
+
const result: Record<string, unknown> = {};
|
|
117
135
|
for (const [key, value] of Object.entries(obj)) {
|
|
118
|
-
result[key] = deserializeRegExp(value)
|
|
136
|
+
result[key] = deserializeRegExp(value) as unknown as Extract<
|
|
137
|
+
T,
|
|
138
|
+
SerializableRecord
|
|
139
|
+
>[keyof T];
|
|
119
140
|
}
|
|
120
|
-
return result
|
|
141
|
+
return result as unknown as Extract<T, SerializableRecord>;
|
|
121
142
|
}
|
|
122
|
-
return obj
|
|
143
|
+
return obj as unknown as Extract<T, SerializableRecord>;
|
|
123
144
|
}
|
|
124
145
|
|
|
125
146
|
// Helper function to recursively process objects for serialization
|
|
126
|
-
export function processForSerialization(
|
|
147
|
+
export function processForSerialization<T>(
|
|
148
|
+
obj: T
|
|
149
|
+
): Extract<T, Serializable> {
|
|
127
150
|
if (obj instanceof RegExp) {
|
|
128
|
-
return serializeRegExp(obj)
|
|
151
|
+
return serializeRegExp(obj) as unknown as Extract<T, Serializable>;
|
|
129
152
|
}
|
|
130
153
|
if (Array.isArray(obj)) {
|
|
131
|
-
return obj.map(processForSerialization)
|
|
154
|
+
return obj.map(processForSerialization) as unknown as Extract<
|
|
155
|
+
T,
|
|
156
|
+
Serializable
|
|
157
|
+
>;
|
|
132
158
|
}
|
|
133
|
-
if (obj && typeof obj ===
|
|
134
|
-
const result:
|
|
159
|
+
if (obj && typeof obj === "object") {
|
|
160
|
+
const result: Record<string, unknown> = {};
|
|
135
161
|
for (const [key, value] of Object.entries(obj)) {
|
|
136
|
-
result[key] = processForSerialization(value)
|
|
162
|
+
result[key] = processForSerialization(value) as unknown as Extract<
|
|
163
|
+
T,
|
|
164
|
+
Serializable
|
|
165
|
+
>[keyof T];
|
|
137
166
|
}
|
|
138
|
-
return result
|
|
167
|
+
return result as unknown as Extract<T, Serializable>;
|
|
139
168
|
}
|
|
140
|
-
return obj
|
|
169
|
+
return obj as unknown as Extract<T, Serializable>;
|
|
141
170
|
}
|
|
142
171
|
|
|
143
|
-
export function serializeResolvedConfig<T extends ResolvedConfig>(
|
|
172
|
+
export function serializeResolvedConfig<T extends ResolvedConfig = ResolvedConfig>(
|
|
144
173
|
config: T,
|
|
145
174
|
knownNonSerializableFunctions: Set<string> = VITE_NON_SERIALIZABLE_FUNCTIONS
|
|
146
175
|
) {
|
|
147
176
|
const {
|
|
148
|
-
getSortedPluginHooks,
|
|
149
|
-
getSortedPlugins,
|
|
150
|
-
assetsInclude,
|
|
177
|
+
getSortedPluginHooks: _getSortedPluginHooks,
|
|
178
|
+
getSortedPlugins: _getSortedPlugins,
|
|
179
|
+
assetsInclude: _assetsInclude,
|
|
180
|
+
environments: _environments,
|
|
151
181
|
// extract known vite function properties
|
|
152
182
|
...handlerOptions
|
|
153
183
|
} = config;
|
|
154
184
|
|
|
185
|
+
// Preserve a minimal environments structure for CSS processing
|
|
186
|
+
const minimalEnvironments = _environments ? {
|
|
187
|
+
client: {
|
|
188
|
+
resolve: { conditions: ['browser', 'module', 'import'] },
|
|
189
|
+
consumer: 'client',
|
|
190
|
+
optimizeDeps: { include: [] },
|
|
191
|
+
dev: { optimizeDeps: { include: [] } },
|
|
192
|
+
build: { outDir: 'dist' },
|
|
193
|
+
},
|
|
194
|
+
ssr: {
|
|
195
|
+
resolve: { conditions: ['node', 'import'] },
|
|
196
|
+
consumer: 'server',
|
|
197
|
+
optimizeDeps: { include: [] },
|
|
198
|
+
dev: { optimizeDeps: { include: [] } },
|
|
199
|
+
build: { outDir: 'dist' },
|
|
200
|
+
},
|
|
201
|
+
} : undefined;
|
|
202
|
+
|
|
155
203
|
// Clean the object to remove non-serializable properties and process RegExp objects
|
|
156
|
-
|
|
204
|
+
const cleaned = cleanObject(handlerOptions, knownNonSerializableFunctions) as any;
|
|
205
|
+
|
|
206
|
+
// Add back the minimal environments if they existed
|
|
207
|
+
if (minimalEnvironments) {
|
|
208
|
+
cleaned.environments = minimalEnvironments;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return processForSerialization(cleaned);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function serializeResolvedUserConfig<T extends ResolvedUserConfig>(
|
|
215
|
+
config: T,
|
|
216
|
+
knownNonSerializableFunctions: Set<string> = VITE_NON_SERIALIZABLE_FUNCTIONS
|
|
217
|
+
) {
|
|
218
|
+
const {
|
|
219
|
+
assetsInclude: _assetsInclude,
|
|
220
|
+
// extract known vite function properties
|
|
221
|
+
...handlerOptions
|
|
222
|
+
} = config;
|
|
223
|
+
|
|
224
|
+
// Clean the object to remove non-serializable properties and process RegExp objects
|
|
225
|
+
return processForSerialization(
|
|
226
|
+
cleanObject(handlerOptions, knownNonSerializableFunctions)
|
|
227
|
+
);
|
|
157
228
|
}
|
|
158
229
|
|
|
159
230
|
// For Vite's config
|
|
@@ -162,66 +233,116 @@ export const serializedDevServerConfig = <T extends ViteDevServer["config"]>(
|
|
|
162
233
|
customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS
|
|
163
234
|
) => {
|
|
164
235
|
const {
|
|
165
|
-
getSortedPluginHooks,
|
|
166
|
-
getSortedPlugins,
|
|
167
|
-
assetsInclude,
|
|
168
|
-
build,
|
|
236
|
+
getSortedPluginHooks: _getSortedPluginHooks,
|
|
237
|
+
getSortedPlugins: _getSortedPlugins,
|
|
238
|
+
assetsInclude: _assetsInclude,
|
|
239
|
+
build: _build,
|
|
169
240
|
...handlerOptions
|
|
170
241
|
} = config;
|
|
171
|
-
return processForSerialization(
|
|
172
|
-
handlerOptions,
|
|
173
|
-
|
|
174
|
-
));
|
|
242
|
+
return processForSerialization(
|
|
243
|
+
cleanObject(handlerOptions, customNonSerializableFunctions)
|
|
244
|
+
);
|
|
175
245
|
};
|
|
176
246
|
|
|
177
247
|
// For your own options (if you need custom non-serializable functions)
|
|
178
|
-
export const serializedOptions =
|
|
179
|
-
userOptions: ResolvedUserOptions
|
|
248
|
+
export const serializedOptions = (
|
|
249
|
+
userOptions: ResolvedUserOptions,
|
|
180
250
|
autoDiscoveredFiles: AutoDiscoveredFiles,
|
|
181
251
|
customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS
|
|
182
|
-
) => {
|
|
252
|
+
): SerializedUserOptions => {
|
|
183
253
|
const {
|
|
184
|
-
Page,
|
|
185
|
-
props,
|
|
186
|
-
normalizer,
|
|
187
|
-
|
|
188
|
-
Html,
|
|
189
|
-
onEvent,
|
|
190
|
-
onMetrics,
|
|
191
|
-
build,
|
|
192
|
-
|
|
254
|
+
Page: _Page,
|
|
255
|
+
props: _props,
|
|
256
|
+
normalizer: _normalizer,
|
|
257
|
+
Root: _Root,
|
|
258
|
+
Html: _Html,
|
|
259
|
+
onEvent: _onEvent,
|
|
260
|
+
onMetrics: _onMetrics,
|
|
261
|
+
build: _build,
|
|
262
|
+
loader: _loader,
|
|
263
|
+
autoDiscover: autoDiscover,
|
|
264
|
+
propsExportName: propsExportName,
|
|
265
|
+
pageExportName: pageExportName,
|
|
193
266
|
...handlerOptions
|
|
194
267
|
} = userOptions;
|
|
195
|
-
const {
|
|
268
|
+
const {
|
|
269
|
+
entryFile: _entryFile,
|
|
270
|
+
chunkFile: _chunkFile,
|
|
271
|
+
assetFile: _assetFile,
|
|
272
|
+
pages: _pages,
|
|
273
|
+
...buildOptions
|
|
274
|
+
} = _build ?? {};
|
|
275
|
+
const {
|
|
276
|
+
isServerFunctionCode: _isServerFunctionCode,
|
|
277
|
+
isClientComponentCode: _isClientComponentCode,
|
|
278
|
+
getDirectiveType: _getDirectiveType,
|
|
279
|
+
allowedDirectives: allowedDirectives,
|
|
280
|
+
...loaderOptions
|
|
281
|
+
} = _loader ?? {};
|
|
282
|
+
const {
|
|
283
|
+
modulePattern: _modulePattern,
|
|
284
|
+
cssPattern: _cssPattern,
|
|
285
|
+
jsonPattern: _jsonPattern,
|
|
286
|
+
clientPattern: _clientPattern,
|
|
287
|
+
propsPattern: _propsPattern,
|
|
288
|
+
pagePattern: _pagePattern,
|
|
289
|
+
htmlPattern: _htmlPattern,
|
|
290
|
+
rscPattern: _rscPattern,
|
|
291
|
+
serverPattern: _serverPattern,
|
|
292
|
+
cssModulePattern: _cssModulePattern,
|
|
293
|
+
vendorPattern: _vendorPattern,
|
|
294
|
+
nodePattern: _nodePattern,
|
|
295
|
+
dotPattern: _dotPattern,
|
|
296
|
+
virtualPattern: _virtualPattern,
|
|
297
|
+
...serializedAutoDiscover
|
|
298
|
+
} = autoDiscover;
|
|
196
299
|
const result = {
|
|
197
300
|
...handlerOptions,
|
|
301
|
+
Page: typeof _Page === 'string' ? _Page : undefined,
|
|
302
|
+
Html: typeof _Html === 'string' ? _Html : undefined,
|
|
303
|
+
Root: typeof _Root === 'string' ? _Root : undefined,
|
|
304
|
+
normalizer: undefined,
|
|
305
|
+
onEvent: undefined,
|
|
306
|
+
onMetrics: undefined,
|
|
307
|
+
propsExportName: propsExportName,
|
|
308
|
+
pageExportName: pageExportName,
|
|
198
309
|
build: {
|
|
199
310
|
...buildOptions,
|
|
200
311
|
pages: autoDiscoveredFiles
|
|
201
312
|
? Array.from(autoDiscoveredFiles.urlMap.keys())
|
|
202
313
|
: [],
|
|
203
314
|
},
|
|
204
|
-
|
|
315
|
+
loader: {
|
|
316
|
+
directivePattern: {
|
|
317
|
+
config: {
|
|
318
|
+
validate: undefined,
|
|
319
|
+
...allowedDirectives,
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
...loaderOptions,
|
|
323
|
+
},
|
|
324
|
+
autoDiscover: {
|
|
325
|
+
modulePattern: serializeRegExp(_modulePattern),
|
|
326
|
+
serverPattern: serializeRegExp(_serverPattern),
|
|
327
|
+
clientPattern: serializeRegExp(_clientPattern),
|
|
328
|
+
pagePattern: serializeRegExp(_pagePattern),
|
|
329
|
+
propsPattern: serializeRegExp(_propsPattern),
|
|
330
|
+
cssPattern: serializeRegExp(_cssPattern),
|
|
331
|
+
jsonPattern: serializeRegExp(_jsonPattern),
|
|
332
|
+
htmlPattern: serializeRegExp(_htmlPattern),
|
|
333
|
+
cssModulePattern: serializeRegExp(_cssModulePattern),
|
|
334
|
+
vendorPattern: serializeRegExp(_vendorPattern),
|
|
335
|
+
nodePattern: serializeRegExp(_nodePattern),
|
|
336
|
+
dotPattern: serializeRegExp(_dotPattern),
|
|
337
|
+
virtualPattern: serializeRegExp(_virtualPattern),
|
|
338
|
+
rscPattern: serializeRegExp(_rscPattern),
|
|
339
|
+
...serializedAutoDiscover,
|
|
340
|
+
},
|
|
341
|
+
} as const
|
|
205
342
|
|
|
206
343
|
// Clean the object to remove non-serializable properties and process RegExp objects
|
|
207
|
-
|
|
208
|
-
result,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export function hydrateUserOptions(userOptions: any) {
|
|
214
|
-
if (!userOptions) return userOptions;
|
|
215
|
-
|
|
216
|
-
// Restore RegExp objects
|
|
217
|
-
if (userOptions.autoDiscover) {
|
|
218
|
-
const { autoDiscover } = userOptions;
|
|
219
|
-
for (const key in autoDiscover) {
|
|
220
|
-
if (typeof autoDiscover[key] === 'string' && autoDiscover[key].startsWith('__REGEXP__')) {
|
|
221
|
-
autoDiscover[key] = deserializeRegExp(autoDiscover[key]);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return userOptions;
|
|
227
|
-
}
|
|
344
|
+
const finalResult = processForSerialization(
|
|
345
|
+
cleanObject(result, customNonSerializableFunctions)
|
|
346
|
+
);
|
|
347
|
+
return finalResult as never
|
|
348
|
+
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
const stashedReturnValue = new Map<string,
|
|
2
|
-
export const
|
|
1
|
+
const stashedReturnValue = new Map<string, unknown>();
|
|
2
|
+
export const clearStashedReturnValues = () => {
|
|
3
|
+
stashedReturnValue.clear();
|
|
4
|
+
};
|
|
5
|
+
export const stashReturnValue = <FN extends (...args: unknown[]) => never>(
|
|
3
6
|
fn: FN
|
|
4
7
|
): FN => {
|
|
5
8
|
return ((...args: Parameters<FN>): ReturnType<FN> => {
|
|
6
9
|
const id = args
|
|
7
|
-
.map((arg) =>!arg ? '' : typeof arg === "string" ? arg : typeof arg === "object" && 'id' in arg ? arg.id : '')
|
|
10
|
+
.map((arg) =>!arg ? '' : typeof arg === "string" || typeof arg === "number" || typeof arg === "boolean" ? arg : typeof arg === "object" && 'id' in arg ? arg.id : '')
|
|
8
11
|
.join("_");
|
|
9
12
|
if (stashedReturnValue.has(id)) {
|
|
10
|
-
return stashedReturnValue.get(id)
|
|
13
|
+
return stashedReturnValue.get(id) as ReturnType<FN>;
|
|
11
14
|
}
|
|
12
15
|
const result = fn(...args);
|
|
13
16
|
stashedReturnValue.set(id, result);
|
|
@@ -3,7 +3,7 @@ import { join, resolve } from "node:path";
|
|
|
3
3
|
import type { Manifest } from "vite";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
|
|
6
|
-
type TryManifestOptions<SSR extends boolean = false> = {
|
|
6
|
+
export type TryManifestOptions<SSR extends boolean = false> = {
|
|
7
7
|
root: string;
|
|
8
8
|
outDir: string;
|
|
9
9
|
ssrManifest?: SSR;
|
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import * as esbuild from "esbuild";
|
|
3
1
|
import type { LoaderContext } from "../types.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { RawSourceMap } from "source-map";
|
|
3
|
+
import type { LoadFnOutput, LoadHookContext } from "node:module";
|
|
4
|
+
import type { LoadHook } from "node:module";
|
|
5
|
+
import { transformWithEsbuild } from "vite";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
+
export type LoaderResult = {
|
|
8
9
|
source: string;
|
|
9
|
-
map:
|
|
10
|
-
}
|
|
10
|
+
map: RawSourceMap | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type Loader = {
|
|
14
|
+
(
|
|
15
|
+
id: string,
|
|
16
|
+
context?: LoaderContext,
|
|
17
|
+
nextLoad?: (id: string) => Promise<LoaderResult>
|
|
18
|
+
): LoaderResult;
|
|
19
|
+
};
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
|
|
22
|
+
const defaultNextLoad: Parameters<LoadHook>[2] = async (url) => {
|
|
23
|
+
const result = await transformWithEsbuild(await readFile(url, "utf-8"), url, {
|
|
24
|
+
loader: "tsx",
|
|
25
|
+
format: "esm",
|
|
26
|
+
sourcemap: "external",
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
source: result.code,
|
|
30
|
+
format: "module",
|
|
31
|
+
map: result.map,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
15
34
|
|
|
16
35
|
/**
|
|
17
|
-
* Creates a
|
|
36
|
+
* Creates a loader function that transforms modules and handles source maps.
|
|
37
|
+
* This function can be used in two ways:
|
|
38
|
+
*
|
|
39
|
+
* 1. As a direct transformer:
|
|
40
|
+
* - Takes source code and returns transformed code with source map attached
|
|
41
|
+
* - Used by transformModuleIfNeeded
|
|
42
|
+
*
|
|
43
|
+
* 2. As a loader factory:
|
|
44
|
+
* - Returns a loader function that takes a module ID and returns a LoaderResult
|
|
45
|
+
* - Used by the plugin to create loaders for different environments
|
|
18
46
|
*/
|
|
19
|
-
export function createDefaultLoader(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
export function createDefaultLoader(
|
|
48
|
+
defaultSource: string,
|
|
49
|
+
defaultId = "index",
|
|
50
|
+
verbose = false
|
|
51
|
+
): (
|
|
52
|
+
url: string,
|
|
53
|
+
context?: Partial<LoadHookContext>,
|
|
54
|
+
nextLoad?: (
|
|
55
|
+
url: string,
|
|
56
|
+
context?: Partial<LoadHookContext>
|
|
57
|
+
) => LoadFnOutput | Promise<LoadFnOutput>
|
|
58
|
+
) => Promise<LoadFnOutput> {
|
|
30
59
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
const defaultSourceNextLoad: Parameters<LoadHook>[2] =
|
|
61
|
+
typeof defaultSource === "string"
|
|
62
|
+
? async (url = defaultId) => {
|
|
63
|
+
const result = await transformWithEsbuild(defaultSource, url, {
|
|
64
|
+
loader: "tsx",
|
|
65
|
+
format: "esm",
|
|
66
|
+
sourcemap: "external",
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
source: result.code,
|
|
70
|
+
format: "module",
|
|
71
|
+
map: result.map,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
: defaultNextLoad;
|
|
39
75
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} else {
|
|
57
|
-
// For the actual code, map to the corresponding line in the original source
|
|
58
|
-
const originalLine = Math.max(1, i - 1); // Adjust for the import line
|
|
59
|
-
mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
76
|
+
return async (
|
|
77
|
+
url = defaultId,
|
|
78
|
+
context = {
|
|
79
|
+
format: "module",
|
|
80
|
+
conditions: ["react-server"],
|
|
81
|
+
importAttributes: {},
|
|
82
|
+
},
|
|
83
|
+
nextLoad = defaultSourceNextLoad
|
|
84
|
+
) => {
|
|
85
|
+
if (verbose) {
|
|
86
|
+
console.log("[createDefaultLoader] Loading:", url);
|
|
87
|
+
console.log("[createDefaultLoader] Context:", {
|
|
88
|
+
format: context.format,
|
|
89
|
+
conditions: context.conditions,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
62
92
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
const { format } = context;
|
|
94
|
+
if (format === "module" || format === "module-typescript") {
|
|
95
|
+
if (verbose) {
|
|
96
|
+
console.log("[createDefaultLoader] Loading module:", url);
|
|
97
|
+
}
|
|
66
98
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return function load(
|
|
74
|
-
id: string,
|
|
75
|
-
context?: LoaderContext,
|
|
76
|
-
nextLoad?: any
|
|
77
|
-
): LoaderResult {
|
|
78
|
-
if (!nextLoad) {
|
|
79
|
-
nextLoad = (id: string) => {
|
|
80
|
-
const source = readFileSync(id, "utf-8");
|
|
81
|
-
// Use esbuild to transform the code
|
|
82
|
-
const result = esbuild.transformSync(source, {
|
|
83
|
-
loader: "tsx",
|
|
84
|
-
format: "esm",
|
|
85
|
-
target: "esnext",
|
|
86
|
-
sourcemap: true,
|
|
87
|
-
sourcefile: id,
|
|
99
|
+
const result = await nextLoad(url, context);
|
|
100
|
+
if (verbose) {
|
|
101
|
+
console.log("[createDefaultLoader] Next load result:", {
|
|
102
|
+
format: result.format,
|
|
103
|
+
shortCircuit: result.shortCircuit,
|
|
104
|
+
source: typeof result.source,
|
|
88
105
|
});
|
|
106
|
+
}
|
|
89
107
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
result.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
const source =
|
|
109
|
+
typeof result.source === "string"
|
|
110
|
+
? result.source
|
|
111
|
+
: result.source instanceof Uint8Array ||
|
|
112
|
+
result.source instanceof ArrayBuffer ||
|
|
113
|
+
result.source instanceof Uint8ClampedArray ||
|
|
114
|
+
result.source instanceof Uint16Array ||
|
|
115
|
+
result.source instanceof Uint32Array ||
|
|
116
|
+
result.source instanceof Int8Array ||
|
|
117
|
+
result.source instanceof Int16Array ||
|
|
118
|
+
result.source instanceof Int32Array ||
|
|
119
|
+
result.source instanceof Float32Array ||
|
|
120
|
+
result.source instanceof Float64Array ||
|
|
121
|
+
result.source instanceof BigUint64Array ||
|
|
122
|
+
result.source instanceof BigInt64Array
|
|
123
|
+
? new TextDecoder().decode(result.source)
|
|
124
|
+
: defaultSource;
|
|
98
125
|
|
|
99
|
-
// Create a new source map with proper mappings
|
|
100
|
-
const map = result.map ? {
|
|
101
|
-
version: 3,
|
|
102
|
-
sources: [id],
|
|
103
|
-
sourcesContent: [transformed],
|
|
104
|
-
mappings: (() => {
|
|
105
|
-
const serializer = createMappingsSerializer();
|
|
106
|
-
let mappings = '';
|
|
107
|
-
|
|
108
|
-
// Map each line of the transformed code to its corresponding line in the original source
|
|
109
|
-
const transformedLines = transformed.split('\n');
|
|
110
|
-
for (let i = 0; i < transformedLines.length; i++) {
|
|
111
|
-
if (i > 0) mappings += ';';
|
|
112
|
-
// For the import and registration lines, map to the first line of the original source
|
|
113
|
-
if (transformedLines[i].includes('import {') || transformedLines[i].includes('registerServerReference')) {
|
|
114
|
-
mappings += serializer(i + 1, 0, 0, 1, 0, 0);
|
|
115
|
-
} else {
|
|
116
|
-
// For the actual code, map to the corresponding line in the original source
|
|
117
|
-
const originalLine = Math.max(1, i - 1); // Adjust for the import line
|
|
118
|
-
mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
126
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
source: transformed,
|
|
128
|
-
map
|
|
129
|
-
};
|
|
127
|
+
return {
|
|
128
|
+
...result,
|
|
129
|
+
source: source,
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
|
|
133
|
+
if (verbose) {
|
|
134
|
+
console.log("[createDefaultLoader] Skipping non-module format:", format);
|
|
135
|
+
}
|
|
136
|
+
return nextLoad(url, context);
|
|
137
137
|
};
|
|
138
138
|
}
|