@@ -5,18 +5,22 @@ const {
55 ObjectFreeze,
66 SafeFinalizationRegistry,
77 SafeMap,
8- SafeWeakMap,
98 SafeWeakRef,
109 SymbolIterator,
1110} = primordials ;
11+ const {
12+ privateSymbols : {
13+ source_map_data_private_symbol,
14+ } ,
15+ } = internalBinding ( 'util' ) ;
1216
1317/**
1418 * Specialized WeakMap that caches source map entries by `filename` and `sourceURL`.
1519 * Cached entries can be iterated with `for..of`.
1620 *
1721 * The cache map maintains the cache entries by:
1822 * - `weakTargetMap`(Map): a strong sourceURL -> WeakRef(Module),
19- * - `weakMap`(WeakMap): a Module instance object -> source map data.
23+ * - WeakRef(Module[source_map_data_private_symbol]): source map data.
2024 *
2125 * Obsolete `weakTargetMap` entries are removed by the `finalizationRegistry` callback.
2226 * This pattern decouples the strong url reference to the source map data and allow the
@@ -33,7 +37,6 @@ class SourceMapCacheMap {
3337 * the cache by the `finalizationRegistry`.
3438 */
3539 #weakTargetMap = new SafeMap ( ) ;
36- #weakMap = new SafeWeakMap ( ) ;
3740
3841 #cleanup = ( { keys } ) => {
3942 // Delete the entry if the weak target has been reclaimed.
@@ -58,7 +61,7 @@ class SourceMapCacheMap {
5861 set ( keys , value , weakTarget ) {
5962 const weakRef = new SafeWeakRef ( weakTarget ) ;
6063 ArrayPrototypeForEach ( keys , ( key ) => this . #weakTargetMap. set ( key , weakRef ) ) ;
61- this . #weakMap . set ( weakTarget , value ) ;
64+ weakTarget [ source_map_data_private_symbol ] = value ;
6265 this . #finalizationRegistry. register ( weakTarget , { keys } ) ;
6366 }
6467
@@ -72,7 +75,7 @@ class SourceMapCacheMap {
7275 if ( target === undefined ) {
7376 return ;
7477 }
75- return this . #weakMap . get ( target ) ;
78+ return target [ source_map_data_private_symbol ] ;
7679 }
7780
7881 /**
@@ -92,7 +95,7 @@ class SourceMapCacheMap {
9295 const { 0 : key , 1 : weakRef } = result . value ;
9396 const target = weakRef . deref ( ) ;
9497 if ( target == null ) return next ( ) ;
95- const value = this . #weakMap . get ( target ) ;
98+ const value = target [ source_map_data_private_symbol ] ;
9699 return { done : false , value : [ key , value ] } ;
97100 } ;
98101
0 commit comments