diff --git a/packages/vite/src/node/plugins/preAlias.ts b/packages/vite/src/node/plugins/preAlias.ts index 8006ca33ea467f..8edc75079a27ec 100644 --- a/packages/vite/src/node/plugins/preAlias.ts +++ b/packages/vite/src/node/plugins/preAlias.ts @@ -92,6 +92,7 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin { } } +// TODO: ? function optimizeAliasReplacementForSSR( id: string, optimizeDeps: DepOptimizationOptions, diff --git a/packages/vite/src/node/ssr/fetchModule.ts b/packages/vite/src/node/ssr/fetchModule.ts index f2b0f05637a482..3ec5f500b904b4 100644 --- a/packages/vite/src/node/ssr/fetchModule.ts +++ b/packages/vite/src/node/ssr/fetchModule.ts @@ -37,19 +37,15 @@ export async function fetchModule( } if (url[0] !== '.' && url[0] !== '/') { - const { - isProduction, - resolve: { dedupe, preserveSymlinks }, - root, - ssr, - } = environment.config - const externalConditions = ssr.resolve?.externalConditions || [] + const { isProduction, root } = environment.config + const { externalConditions, dedupe, preserveSymlinks } = + environment.options.resolve const resolveOptions: InternalResolveOptionsWithOverrideConditions = { mainFields: ['main'], conditions: [], externalConditions, - external: [], // TODO, should it be ssr.resolve.external? + external: [], // TODO, should it be environment.options.resolve.external? noExternal: [], overrideConditions: [...externalConditions, 'production', 'development'], extensions: ['.js', '.cjs', '.json'], diff --git a/packages/vite/src/node/ssr/ssrModuleLoader.ts b/packages/vite/src/node/ssr/ssrModuleLoader.ts index 4bc1f3161a61d6..d7994ef1269ea0 100644 --- a/packages/vite/src/node/ssr/ssrModuleLoader.ts +++ b/packages/vite/src/node/ssr/ssrModuleLoader.ts @@ -85,7 +85,8 @@ async function instantiateModule( urlStack: string[] = [], fixStacktrace?: boolean, ): Promise { - const moduleGraph = server.environments.ssr.moduleGraph + const environment = server.environments.ssr + const moduleGraph = environment.moduleGraph const mod = await moduleGraph.ensureEntryFromUrl(url) if (mod.ssrError) { @@ -96,7 +97,7 @@ async function instantiateModule( return mod.ssrModule } const result = - mod.transformResult || (await server.environments.ssr.transformRequest(url)) + mod.transformResult || (await environment.transformRequest(url)) if (!result) { // TODO more info? is this even necessary? throw new Error(`failed to load module for ssr: ${url}`) @@ -124,14 +125,10 @@ async function instantiateModule( urlStack = urlStack.concat(url) const isCircular = (url: string) => urlStack.includes(url) - const { - isProduction, - resolve: { dedupe, preserveSymlinks }, - root, - ssr, - } = server.config + const { isProduction, root } = server.config - const externalConditions = ssr.resolve?.externalConditions || [] + const { externalConditions, dedupe, preserveSymlinks } = + environment.options.resolve const resolveOptions: NodeImportResolveOptions = { mainFields: ['main'],