@@ -14,6 +14,9 @@ const {
14
14
15
15
function ObjectGetValueSafe ( obj , key ) {
16
16
const desc = ObjectGetOwnPropertyDescriptor ( obj , key ) ;
17
+ if ( desc === undefined ) {
18
+ return undefined ;
19
+ }
17
20
return ObjectPrototypeHasOwnProperty ( desc , 'value' ) ? desc . value : undefined ;
18
21
}
19
22
@@ -141,6 +144,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
141
144
const url = data ? null : sourceMapURL ;
142
145
if ( cjsModuleInstance ) {
143
146
getCjsSourceMapCache ( ) . set ( cjsModuleInstance , {
147
+ __proto__ : null ,
144
148
filename,
145
149
lineLengths : lineLengths ( content ) ,
146
150
data,
@@ -149,6 +153,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
149
153
} ) ;
150
154
} else if ( isGeneratedSource ) {
151
155
const entry = {
156
+ __proto__ : null ,
152
157
lineLengths : lineLengths ( content ) ,
153
158
data,
154
159
url,
@@ -162,6 +167,7 @@ function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSo
162
167
// If there is no cjsModuleInstance and is not generated source assume we are in a
163
168
// "modules/esm" context.
164
169
const entry = {
170
+ __proto__ : null ,
165
171
lineLengths : lineLengths ( content ) ,
166
172
data,
167
173
url,
@@ -296,6 +302,7 @@ function sourceMapCacheToObject() {
296
302
function appendCJSCache ( obj ) {
297
303
for ( const value of getCjsSourceMapCache ( ) ) {
298
304
obj [ ObjectGetValueSafe ( value , 'filename' ) ] = {
305
+ __proto__ : null ,
299
306
lineLengths : ObjectGetValueSafe ( value , 'lineLengths' ) ,
300
307
data : ObjectGetValueSafe ( value , 'data' ) ,
301
308
url : ObjectGetValueSafe ( value , 'url' )
@@ -310,22 +317,25 @@ function findSourceMap(sourceURL) {
310
317
if ( ! SourceMap ) {
311
318
SourceMap = require ( 'internal/source_map/source_map' ) . SourceMap ;
312
319
}
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 ) {
315
322
for ( const value of getCjsSourceMapCache ( ) ) {
316
323
const filename = ObjectGetValueSafe ( value , 'filename' ) ;
317
324
const cachedSourceURL = ObjectGetValueSafe ( value , 'sourceURL' ) ;
318
325
if ( sourceURL === filename || sourceURL === cachedSourceURL ) {
319
- sourceMap = {
320
- data : ObjectGetValueSafe ( value , 'data' )
321
- } ;
326
+ entry = value ;
322
327
}
323
328
}
324
329
}
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 ;
327
337
}
328
- return undefined ;
338
+ return sourceMap ;
329
339
}
330
340
331
341
module . exports = {
0 commit comments