From fd1283fe27cc1a19b5c7d9d72664832e4daa1bbf Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 19 Nov 2024 11:48:02 +0100 Subject: [PATCH] fix(module-runner): make evaluator optional (#18672) --- packages/vite/src/module-runner/runner.ts | 3 ++- packages/vite/src/node/ssr/runtime/serverModuleRunner.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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, ) }