Files
node/test/fixtures/source-map/output/source_map_prepare_stack_trace.js
Chengzhong Wu 2fb007fdce lib: allow skipping source maps in node_modules
Files in `node_modules` are not authored by the user directly and the
original sources are less relevant to the user.

Skipping source maps in `node_modules` improves the general
performance. Add `module.setSourceMapsSupport(enabled, options)` to
skip source maps in `node_modules` if it is needed. This moves
all source maps related API to `node:module` and this a step to
promote the source maps API to stable.

PR-URL: https://github.com/nodejs/node/pull/56639
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-01-30 10:44:33 +01:00

39 lines
935 B
JavaScript

// Flags: --enable-source-maps
'use strict';
require('../../../common');
const assert = require('node:assert');
const Module = require('node:module');
Error.stackTraceLimit = 5;
assert.strictEqual(typeof Error.prepareStackTrace, 'function');
const defaultPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (error, trace) => {
trace = trace.filter(it => {
return it.getFunctionName() !== 'functionC';
});
return defaultPrepareStackTrace(error, trace);
};
try {
require('../enclosing-call-site-min.js');
} catch (e) {
console.log(e);
}
// Source maps support is disabled programmatically even without deleting the
// CJS module cache.
Module.setSourceMapsSupport(false);
assert.deepStrictEqual(Module.getSourceMapsSupport(), {
__proto__: null,
enabled: false,
nodeModules: false,
generatedCode: false,
});
try {
require('../enclosing-call-site-min.js');
} catch (e) {
console.log(e);
}