MCPcopy
hub / github.com/vitejs/vite / constructor

Method constructor

packages/vite/src/module-runner/runner.ts:53–85  ·  packages/vite/src/module-runner/runner.ts::ModuleRunner.constructor
(
    public options: ModuleRunnerOptions,
    public evaluator: ModuleEvaluator = new ESModulesEvaluator(),
    private debug?: ModuleRunnerDebugger | undefined,
  )

Source from the content-addressed store, hash-verified

51 private closed = false
52
53 constructor(
54 public options: ModuleRunnerOptions,
55 public evaluator: ModuleEvaluator = new ESModulesEvaluator(),
56 private debug?: ModuleRunnerDebugger | undefined,
57 ) {
58 this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules()
59 this.transport = normalizeModuleRunnerTransport(options.transport)
60 if (options.hmr !== false) {
61 const optionsHmr = options.hmr ?? true
62 const resolvedHmrLogger: HMRLogger =
63 optionsHmr === true || optionsHmr.logger === undefined
64 ? hmrLogger
65 : optionsHmr.logger === false
66 ? silentConsole
67 : optionsHmr.logger
68 this.hmrClient = new HMRClient(
69 resolvedHmrLogger,
70 this.transport,
71 ({ acceptedPath }) => this.import(acceptedPath),
72 )
73 if (!this.transport.connect) {
74 throw new Error(
75 class="st">'HMR is not supported by this runner transport, but `hmr` option was set to true',
76 )
77 }
78 this.transport.connect(createHMRHandlerForRunner(this))
79 } else {
80 this.transport.connect?.()
81 }
82 if (options.sourcemapInterceptor !== false) {
83 this.resetSourceMapSupport = enableSourceMapSupport(this)
84 }
85 }
86
87 /**
88 * URL to execute. Accepts file path, server path or id relative to the root.

Callers

nothing calls this directly

Calls 5

importMethod · 0.95
enableSourceMapSupportFunction · 0.90
connectMethod · 0.65

Tested by

no test coverage detected