@@ -3,23 +3,19 @@ import type { Transformed } from './utils/transform/apply-transformers.js';
3
3
const inlineSourceMapPrefix = '\n//# sourceMappingURL=data:application/json;base64,' ;
4
4
5
5
export const installSourceMapSupport = ( ) => {
6
- const hasNativeSourceMapSupport = (
7
-
8
- /**
9
- * Check if native source maps are supported by seeing if the API is available
10
- * https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processsetsourcemapsenabledval
11
- */
12
- 'setSourceMapsEnabled' in process
13
-
14
- /**
15
- * Overriding Error.prepareStackTrace prevents --enable-source-maps from modifying
16
- * the stack trace
17
- * 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.
18
- *
19
- * https://github.com/nodejs/node/blob/91193825551f9301b6ab52d96211b38889149892/lib/internal/errors.js#L141
20
- */
21
- && typeof Error . prepareStackTrace !== 'function'
22
- ) ;
6
+ /**
7
+ * Check if native source maps are supported by seeing if the API is available
8
+ * https://nodejs.org/dist/latest-v18.x/docs/api/process.html#processsetsourcemapsenabledval
9
+ *
10
+ * Previously, we also checked Error.prepareStackTrace to opt-out of source maps
11
+ * as per this recommendation:
12
+ * 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.
13
+ *
14
+ * But it's been removed because:
15
+ * 1. It's set by default from Node v21.6.0 and v20.12.0
16
+ * 2. It may have been possible for a custom prepareStackTrace to parse the source maps
17
+ */
18
+ const hasNativeSourceMapSupport = 'setSourceMapsEnabled' in process ;
23
19
24
20
if ( hasNativeSourceMapSupport ) {
25
21
process . setSourceMapsEnabled ( true ) ;
0 commit comments