@@ -206,13 +206,22 @@ if (process.env.NODE_ENV === 'development') {
206
206
207
207
const sourceMap = nodeModule . findSourceMap ( requestedFilePath ) ;
208
208
let map ;
209
- // There are two ways to return a source map depending on what we observe in error.stack.
210
- // A real app will have a similar choice to make for which strategy to pick.
211
- if ( ! sourceMap || ! isCompiledOutput ) {
209
+ if ( requestedFilePath . startsWith ( 'node:' ) ) {
210
+ // This is a node internal. We don't include any source code for this but we still
211
+ // generate a source map for it so that we can add it to an ignoreList automatically.
212
+ map = {
213
+ version : 3 ,
214
+ sources : [ requestedFilePath ] ,
215
+ sourcesContent : [ '// Node Internals' ] ,
216
+ mappings : 'AAAA' ,
217
+ ignoreList : [ 0 ] ,
218
+ sourceRoot : '' ,
219
+ } ;
220
+ } else if ( ! sourceMap || ! isCompiledOutput ) {
212
221
// If a file doesn't have a source map, such as this file, then we generate a blank
213
222
// source map that just contains the original content and segments pointing to the
214
- // original lines.
215
- // Similarly
223
+ // original lines. If a line number points to uncompiled output, like if source mapping
224
+ // was already applied we also use this path.
216
225
const sourceContent = await readFile ( requestedFilePath , 'utf8' ) ;
217
226
const lines = sourceContent . split ( '\n' ) . length ;
218
227
map = {
@@ -224,6 +233,10 @@ if (process.env.NODE_ENV === 'development') {
224
233
// generated for each parsed segment or add a segment for each column.
225
234
mappings : 'AAAA' + ';AACA' . repeat ( lines - 1 ) ,
226
235
sourceRoot : '' ,
236
+ // Add any node_modules to the ignore list automatically.
237
+ ignoreList : requestedFilePath . includes ( 'node_modules' )
238
+ ? [ 0 ]
239
+ : undefined ,
227
240
} ;
228
241
} else {
229
242
// We always set prepareStackTrace before reading the stack so that we get the stack
0 commit comments