diff --git a/.nvmrc b/.nvmrc index d5a15960..9ff19494 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.10.0 +v20.12.0 diff --git a/src/source-map.ts b/src/source-map.ts index eb3c62f2..811c0211 100644 --- a/src/source-map.ts +++ b/src/source-map.ts @@ -3,23 +3,19 @@ import type { Transformed } from './utils/transform/apply-transformers.js'; const inlineSourceMapPrefix = '\n//# sourceMappingURL=data:application/json;base64,'; export const installSourceMapSupport = () => { - const hasNativeSourceMapSupport = ( - - /** - * Check if native source maps are supported by seeing if the API is available - * https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processsetsourcemapsenabledval - */ - 'setSourceMapsEnabled' in process - - /** - * Overriding Error.prepareStackTrace prevents --enable-source-maps from modifying - * the stack trace - * https://nodejs.org/dist/latest-v18.x/docs/api/cli.html#:~:text=Overriding%20Error.prepareStackTrace%20prevents%20%2D%2Denable%2Dsource%2Dmaps%20from%20modifying%20the%20stack%20trace. - * - * https://github.com/nodejs/node/blob/91193825551f9301b6ab52d96211b38889149892/lib/internal/errors.js#L141 - */ - && typeof Error.prepareStackTrace !== 'function' - ); + /** + * Check if native source maps are supported by seeing if the API is available + * https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processsetsourcemapsenabledval + * + * Previously, we also checked Error.prepareStackTrace to opt-out of source maps + * as per this recommendation: + * https://nodejs.org/dist/latest-v18.x/docs/api/cli.html#:~:text=Overriding%20Error.prepareStackTrace%20prevents%20%2D%2Denable%2Dsource%2Dmaps%20from%20modifying%20the%20stack%20trace. + * + * But it's been removed because: + * 1. It's set by default from Node v21.6.0 and v20.12.0 + * 2. It may have been possible for a custom prepareStackTrace to parse the source maps + */ + const hasNativeSourceMapSupport = 'setSourceMapsEnabled' in process; if (hasNativeSourceMapSupport) { process.setSourceMapsEnabled(true); diff --git a/tests/utils/node-versions.ts b/tests/utils/node-versions.ts index 589c1806..3b14e57e 100644 --- a/tests/utils/node-versions.ts +++ b/tests/utils/node-versions.ts @@ -13,8 +13,9 @@ export const nodeVersions = [ && process.platform !== 'win32' ) ? [ - '21.5.0', - latestMajor('20.10.0'), + latestMajor('21.7.2'), + '21.0.0', + latestMajor('20.12.0'), '20.0.0', latestMajor('18.20.0'), '18.0.0',