@@ -14,6 +14,9 @@ const {
1414
1515function ObjectGetValueSafe ( obj , key ) {
1616 const desc = ObjectGetOwnPropertyDescriptor ( obj , key ) ;
17+ if ( desc === undefined ) {
18+ return undefined ;
19+ }
1720 return ObjectPrototypeHasOwnProperty ( desc , 'value' ) ? desc . value : undefined ;
1821}
1922
@@ -141,6 +144,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
141144 const url = data ? null : sourceMapURL ;
142145 if ( cjsModuleInstance ) {
143146 getCjsSourceMapCache ( ) . set ( cjsModuleInstance , {
147+ __proto__ : null ,
144148 filename,
145149 lineLengths : lineLengths ( content ) ,
146150 data,
@@ -149,6 +153,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
149153 } ) ;
150154 } else if ( isGeneratedSource ) {
151155 const entry = {
156+ __proto__ : null ,
152157 lineLengths : lineLengths ( content ) ,
153158 data,
154159 url,
@@ -162,6 +167,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
162167 // If there is no cjsModuleInstance and is not generated source assume we are in a
163168 // "modules/esm" context.
164169 const entry = {
170+ __proto__ : null ,
165171 lineLengths : lineLengths ( content ) ,
166172 data,
167173 url,
@@ -296,6 +302,7 @@ function sourceMapCacheToObject() {
296302function appendCJSCache ( obj ) {
297303 for ( const value of getCjsSourceMapCache ( ) ) {
298304 obj [ ObjectGetValueSafe ( value , 'filename' ) ] = {
305+ __proto__ : null ,
299306 lineLengths : ObjectGetValueSafe ( value , 'lineLengths' ) ,
300307 data : ObjectGetValueSafe ( value , 'data' ) ,
301308 url : ObjectGetValueSafe ( value , 'url' )
@@ -310,22 +317,25 @@ function findSourceMap(sourceURL) {
310317 if ( ! SourceMap ) {
311318 SourceMap = require ( 'internal/source_map/source_map' ) . SourceMap ;
312319 }
313- let sourceMap = esmSourceMapCache . get ( sourceURL ) ?? generatedSourceMapCache . get ( sourceURL ) ;
314- if ( sourceMap === undefined ) {
320+ let entry = esmSourceMapCache . get ( sourceURL ) ?? generatedSourceMapCache . get ( sourceURL ) ;
321+ if ( entry === undefined ) {
315322 for ( const value of getCjsSourceMapCache ( ) ) {
316323 const filename = ObjectGetValueSafe ( value , 'filename' ) ;
317324 const cachedSourceURL = ObjectGetValueSafe ( value , 'sourceURL' ) ;
318325 if ( sourceURL === filename || sourceURL === cachedSourceURL ) {
319- sourceMap = {
320- data : ObjectGetValueSafe ( value , 'data' )
321- } ;
326+ entry = value ;
322327 }
323328 }
324329 }
325- if ( sourceMap && sourceMap . data ) {
326- return new SourceMap ( sourceMap . data ) ;
330+ if ( entry === undefined ) {
331+ return undefined ;
332+ }
333+ let sourceMap = ObjectGetValueSafe ( entry , 'sourceMap' ) ;
334+ if ( sourceMap === undefined ) {
335+ sourceMap = new SourceMap ( ObjectGetValueSafe ( entry , 'data' ) ) ;
336+ entry . sourceMap = sourceMap ;
327337 }
328- return undefined ;
338+ return sourceMap ;
329339}
330340
331341module . exports = {
0 commit comments