33const {
44 ArrayPrototypeMap,
55 JSONParse,
6+ ObjectAssign,
67 ObjectKeys,
78 ObjectGetOwnPropertyDescriptor,
89 ObjectPrototypeHasOwnProperty,
@@ -14,6 +15,9 @@ const {
1415
1516function ObjectGetValueSafe ( obj , key ) {
1617 const desc = ObjectGetOwnPropertyDescriptor ( obj , key ) ;
18+ if ( desc === undefined ) {
19+ return undefined ;
20+ }
1721 return ObjectPrototypeHasOwnProperty ( desc , 'value' ) ? desc . value : undefined ;
1822}
1923
@@ -310,22 +314,25 @@ function findSourceMap(sourceURL) {
310314 if ( ! SourceMap ) {
311315 SourceMap = require ( 'internal/source_map/source_map' ) . SourceMap ;
312316 }
313- let sourceMap = esmSourceMapCache . get ( sourceURL ) ?? generatedSourceMapCache . get ( sourceURL ) ;
314- if ( sourceMap === undefined ) {
317+ let entry = esmSourceMapCache . get ( sourceURL ) ?? generatedSourceMapCache . get ( sourceURL ) ;
318+ if ( entry === undefined ) {
315319 for ( const value of getCjsSourceMapCache ( ) ) {
316320 const filename = ObjectGetValueSafe ( value , 'filename' ) ;
317321 const cachedSourceURL = ObjectGetValueSafe ( value , 'sourceURL' ) ;
318322 if ( sourceURL === filename || sourceURL === cachedSourceURL ) {
319- sourceMap = {
320- data : ObjectGetValueSafe ( value , 'data' )
321- } ;
323+ entry = value ;
322324 }
323325 }
324326 }
325- if ( sourceMap && sourceMap . data ) {
326- return new SourceMap ( sourceMap . data ) ;
327+ if ( entry === undefined ) {
328+ return undefined ;
329+ }
330+ let sourceMap = ObjectGetValueSafe ( entry , 'sourceMap' ) ;
331+ if ( sourceMap === undefined ) {
332+ sourceMap = new SourceMap ( ObjectGetValueSafe ( entry , 'data' ) ) ;
333+ ObjectAssign ( entry , { __proto__ : null , sourceMap } ) ;
327334 }
328- return undefined ;
335+ return sourceMap ;
329336}
330337
331338module . exports = {
0 commit comments