mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: install source map support lazily (#26445)
This way we allow importing from `@playwright/test` without affecting stack traces. Fixes #26346.
This commit is contained in:
parent
bcc30bc71e
commit
32a309ccb8
@ -43,9 +43,16 @@ const fileDependencies = new Map<string, Set<string>>();
|
|||||||
// Dependencies resolved by the external bundler.
|
// Dependencies resolved by the external bundler.
|
||||||
const externalDependencies = new Map<string, Set<string>>();
|
const externalDependencies = new Map<string, Set<string>>();
|
||||||
|
|
||||||
Error.stackTraceLimit = 200;
|
let sourceMapSupportInstalled = false;
|
||||||
|
|
||||||
sourceMapSupport.install({
|
export function installSourceMapSupportIfNeeded() {
|
||||||
|
if (sourceMapSupportInstalled)
|
||||||
|
return;
|
||||||
|
sourceMapSupportInstalled = true;
|
||||||
|
|
||||||
|
Error.stackTraceLimit = 200;
|
||||||
|
|
||||||
|
sourceMapSupport.install({
|
||||||
environment: 'node',
|
environment: 'node',
|
||||||
handleUncaughtExceptions: false,
|
handleUncaughtExceptions: false,
|
||||||
retrieveSourceMap(source) {
|
retrieveSourceMap(source) {
|
||||||
@ -59,7 +66,8 @@ sourceMapSupport.install({
|
|||||||
url: source
|
url: source
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function _innerAddToCompilationCache(filename: string, options: { codePath: string, sourceMapPath: string, moduleUrl?: string }) {
|
function _innerAddToCompilationCache(filename: string, options: { codePath: string, sourceMapPath: string, moduleUrl?: string }) {
|
||||||
sourceMaps.set(options.moduleUrl || filename, options.sourceMapPath);
|
sourceMaps.set(options.moduleUrl || filename, options.sourceMapPath);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import Module from 'module';
|
|||||||
import type { BabelPlugin, BabelTransformFunction } from './babelBundle';
|
import type { BabelPlugin, BabelTransformFunction } from './babelBundle';
|
||||||
import { createFileMatcher, fileIsModule, resolveImportSpecifierExtension } from '../util';
|
import { createFileMatcher, fileIsModule, resolveImportSpecifierExtension } from '../util';
|
||||||
import type { Matcher } from '../util';
|
import type { Matcher } from '../util';
|
||||||
import { getFromCompilationCache, currentFileDepsCollector, belongsToNodeModules } from './compilationCache';
|
import { getFromCompilationCache, currentFileDepsCollector, belongsToNodeModules, installSourceMapSupportIfNeeded } from './compilationCache';
|
||||||
|
|
||||||
const version = require('../../package.json').version;
|
const version = require('../../package.json').version;
|
||||||
|
|
||||||
@ -213,6 +213,8 @@ export async function requireOrImport(file: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function installTransform(): () => void {
|
function installTransform(): () => void {
|
||||||
|
installSourceMapSupportIfNeeded();
|
||||||
|
|
||||||
let reverted = false;
|
let reverted = false;
|
||||||
|
|
||||||
const originalResolveFilename = (Module as any)._resolveFilename;
|
const originalResolveFilename = (Module as any)._resolveFilename;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user