fix(module-runner): make evaluator optional (#18672)
Some checks are pending
CI / Get changed files (push) Waiting to run
CI / Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (18, ubuntu-latest) (push) Blocked by required conditions
CI / Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (20, ubuntu-latest) (push) Blocked by required conditions
CI / Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (22, macos-latest) (push) Blocked by required conditions
CI / Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (22, ubuntu-latest) (push) Blocked by required conditions
CI / Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }} (22, windows-latest) (push) Blocked by required conditions
CI / Build & Test Passed or Skipped (push) Blocked by required conditions
CI / Build & Test Failed (push) Blocked by required conditions
CI / Lint: node-20, ubuntu-latest (push) Waiting to run
Preview release / preview (push) Waiting to run

This commit is contained in:
Vladimir 2024-11-19 11:48:02 +01:00 committed by GitHub
parent 5ec9eedc80
commit fd1283fe27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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,
)
}