diff --git a/packages/vite/src/module-runner/runner.ts b/packages/vite/src/module-runner/runner.ts index 66332593f..5f103753f 100644 --- a/packages/vite/src/module-runner/runner.ts +++ b/packages/vite/src/module-runner/runner.ts @@ -33,6 +33,7 @@ import { import { hmrLogger, silentConsole } from './hmrLogger' import { createHMRHandler } from './hmrHandler' import { enableSourceMapSupport } from './sourcemap/index' +import { ESModulesEvaluator } from './esmEvaluator' interface ModuleRunnerDebugger { (formatter: unknown, ...args: unknown[]): void @@ -61,7 +62,7 @@ export class ModuleRunner { constructor( public options: ModuleRunnerOptions, - public evaluator: ModuleEvaluator, + public evaluator: ModuleEvaluator = new ESModulesEvaluator(), private debug?: ModuleRunnerDebugger, ) { const root = this.options.root diff --git a/packages/vite/src/node/ssr/runtime/serverModuleRunner.ts b/packages/vite/src/node/ssr/runtime/serverModuleRunner.ts index 47f012557..59d7bc205 100644 --- a/packages/vite/src/node/ssr/runtime/serverModuleRunner.ts +++ b/packages/vite/src/node/ssr/runtime/serverModuleRunner.ts @@ -1,5 +1,5 @@ import { existsSync, readFileSync } from 'node:fs' -import { ESModulesEvaluator, ModuleRunner } from 'vite/module-runner' +import { ModuleRunner } from 'vite/module-runner' import type { ModuleEvaluator, ModuleRunnerHmr, @@ -133,6 +133,6 @@ export function createServerModuleRunner( hmr, sourcemapInterceptor: resolveSourceMapOptions(options), }, - options.evaluator || new ESModulesEvaluator(), + options.evaluator, ) }