From 21513479dc191656a9f6a9fe99d0591aed5821c7 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Fri, 4 Oct 2024 15:56:46 +0200 Subject: [PATCH] refactor: keep the "runner" option in runnable dev environment --- .../server/environments/runnableEnvironment.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/environments/runnableEnvironment.ts b/packages/vite/src/node/server/environments/runnableEnvironment.ts index 0568214e0b647d..8c8c6cb2179153 100644 --- a/packages/vite/src/node/server/environments/runnableEnvironment.ts +++ b/packages/vite/src/node/server/environments/runnableEnvironment.ts @@ -22,6 +22,10 @@ export function createRunnableDevEnvironment( export interface RunnableDevEnvironmentContext extends Omit { + runner?: ( + environment: RunnableDevEnvironment, + options?: ServerModuleRunnerOptions, + ) => ModuleRunner runnerOptions?: ServerModuleRunnerOptions hot?: false | HotChannel } @@ -34,6 +38,12 @@ export function isRunnableDevEnvironment( class RunnableDevEnvironment extends DevEnvironment { private _runner: ModuleRunner | undefined + private _runnerFactory: + | (( + environment: RunnableDevEnvironment, + options?: ServerModuleRunnerOptions, + ) => ModuleRunner) + | undefined private _runnerOptions: ServerModuleRunnerOptions | undefined constructor( @@ -42,6 +52,7 @@ class RunnableDevEnvironment extends DevEnvironment { context: RunnableDevEnvironmentContext, ) { super(name, config, context as DevEnvironmentContext) + this._runnerFactory = context.runner this._runnerOptions = context.runnerOptions } @@ -49,7 +60,8 @@ class RunnableDevEnvironment extends DevEnvironment { if (this._runner) { return this._runner } - this._runner = createServerModuleRunner(this, this._runnerOptions) + const factory = this._runnerFactory || createServerModuleRunner + this._runner = factory(this, this._runnerOptions) return this._runner } }