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

Function enableSourceMapSupport

packages/vite/src/module-runner/sourcemap/index.ts:4–28  ·  packages/vite/src/module-runner/sourcemap/index.ts::enableSourceMapSupport
(runner: ModuleRunner)

Source from the content-addressed store, hash-verified

2import { interceptStackTrace } from class="st">'./interceptor'
3
4export function enableSourceMapSupport(runner: ModuleRunner): () => void {
5 if (runner.options.sourcemapInterceptor === class="st">'node') {
6 if (typeof process === class="st">'undefined') {
7 throw new TypeError(
8 `Cannot use class="st">"sourcemapInterceptor: 'node'" because global class="st">"process" variable is not available.`,
9 )
10 }
11 /* eslint-disable n/no-unsupported-features/node-builtins -- process.setSourceMapsEnabled and process.sourceMapsEnabled */
12 if (typeof process.setSourceMapsEnabled !== class="st">'function') {
13 throw new TypeError(
14 `Cannot use class="st">"sourcemapInterceptor: 'node'" because class="st">"process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.`,
15 )
16 }
17 const isEnabledAlready = process.sourceMapsEnabled ?? false
18 process.setSourceMapsEnabled(true)
19 return () => !isEnabledAlready && process.setSourceMapsEnabled(false)
20 /* eslint-enable n/no-unsupported-features/node-builtins */
21 }
22 return interceptStackTrace(
23 runner,
24 typeof runner.options.sourcemapInterceptor === class="st">'object'
25 ? runner.options.sourcemapInterceptor
26 : undefined,
27 )
28}

Callers 1

constructorMethod · 0.90

Calls 1

interceptStackTraceFunction · 0.90

Tested by

no test coverage detected