@@ -2,6 +2,7 @@ import type { ModuleRunner } from 'vite/module-runner'
2
2
import type { ResolvedConfig } from '../../config'
3
3
import type { DevEnvironmentContext } from '../environment'
4
4
import { DevEnvironment } from '../environment'
5
+ import type { ServerModuleRunnerOptions } from '../../ssr/runtime/serverModuleRunner'
5
6
import { createServerModuleRunner } from '../../ssr/runtime/serverModuleRunner'
6
7
import type { HotChannel } from '../hmr'
7
8
import { createServerHotChannel } from '../hmr'
@@ -21,7 +22,11 @@ export function createRunnableDevEnvironment(
21
22
22
23
export interface RunnableDevEnvironmentContext
23
24
extends Omit < DevEnvironmentContext , 'hot' > {
24
- runner ?: ( environment : RunnableDevEnvironment ) => ModuleRunner
25
+ runner ?: (
26
+ environment : RunnableDevEnvironment ,
27
+ options ?: ServerModuleRunnerOptions ,
28
+ ) => ModuleRunner
29
+ runnerOptions ?: ServerModuleRunnerOptions
25
30
hot ?: false | HotChannel
26
31
}
27
32
@@ -34,8 +39,12 @@ export function isRunnableDevEnvironment(
34
39
class RunnableDevEnvironment extends DevEnvironment {
35
40
private _runner : ModuleRunner | undefined
36
41
private _runnerFactory :
37
- | ( ( environment : RunnableDevEnvironment ) => ModuleRunner )
42
+ | ( (
43
+ environment : RunnableDevEnvironment ,
44
+ options ?: ServerModuleRunnerOptions ,
45
+ ) => ModuleRunner )
38
46
| undefined
47
+ private _runnerOptions : ServerModuleRunnerOptions | undefined
39
48
40
49
constructor (
41
50
name : string ,
@@ -44,17 +53,15 @@ class RunnableDevEnvironment extends DevEnvironment {
44
53
) {
45
54
super ( name , config , context as DevEnvironmentContext )
46
55
this . _runnerFactory = context . runner
56
+ this . _runnerOptions = context . runnerOptions
47
57
}
48
58
49
59
get runner ( ) : ModuleRunner {
50
60
if ( this . _runner ) {
51
61
return this . _runner
52
62
}
53
- if ( this . _runnerFactory ) {
54
- this . _runner = this . _runnerFactory ( this )
55
- return this . _runner
56
- }
57
- this . _runner = createServerModuleRunner ( this )
63
+ const factory = this . _runnerFactory || createServerModuleRunner
64
+ this . _runner = factory ( this , this . _runnerOptions )
58
65
return this . _runner
59
66
}
60
67
}
0 commit comments