@@ -18,12 +18,14 @@ const basename = name => {
18
18
return name . substr ( name . lastIndexOf ( "/" ) + 1 ) ;
19
19
} ;
20
20
21
+ const assetsCache = new WeakMap ( ) ;
22
+
21
23
const getTaskForFile = ( file , chunk , options , compilation ) => {
22
24
const asset = compilation . assets [ file ] ;
23
- if ( asset . __SourceMapDevToolFile === file && asset . __SourceMapDevToolData ) {
24
- const data = asset . __SourceMapDevToolData ;
25
- for ( const cachedFile in data ) {
26
- compilation . assets [ cachedFile ] = data [ cachedFile ] ;
25
+ const cache = assetsCache . get ( asset ) ;
26
+ if ( cache && cache . file === file ) {
27
+ for ( const cachedFile in cache . assets ) {
28
+ compilation . assets [ cachedFile ] = cache . assets [ cachedFile ] ;
27
29
if ( cachedFile !== file ) chunk . files . push ( cachedFile ) ;
28
30
}
29
31
return ;
@@ -207,6 +209,7 @@ class SourceMapDevToolPlugin {
207
209
task . file ,
208
210
"attach SourceMap"
209
211
) ;
212
+ const assets = Object . create ( null ) ;
210
213
const chunk = task . chunk ;
211
214
const file = task . file ;
212
215
const asset = task . asset ;
@@ -222,8 +225,7 @@ class SourceMapDevToolPlugin {
222
225
}
223
226
sourceMap . sourceRoot = options . sourceRoot || "" ;
224
227
sourceMap . file = file ;
225
- asset . __SourceMapDevToolFile = file ;
226
- asset . __SourceMapDevToolData = { } ;
228
+ assetsCache . set ( asset , { file, assets } ) ;
227
229
let currentSourceMappingURLComment = sourceMappingURLComment ;
228
230
if (
229
231
currentSourceMappingURLComment !== false &&
@@ -260,24 +262,20 @@ class SourceMapDevToolPlugin {
260
262
. relative ( path . dirname ( file ) , sourceMapFile )
261
263
. replace ( / \\ / g, "/" ) ;
262
264
if ( currentSourceMappingURLComment !== false ) {
263
- asset . __SourceMapDevToolData [ file ] = compilation . assets [
264
- file
265
- ] = new ConcatSource (
265
+ assets [ file ] = compilation . assets [ file ] = new ConcatSource (
266
266
new RawSource ( source ) ,
267
267
currentSourceMappingURLComment . replace (
268
268
/ \[ u r l \] / g,
269
269
sourceMapUrl
270
270
)
271
271
) ;
272
272
}
273
- asset . __SourceMapDevToolData [ sourceMapFile ] = compilation . assets [
273
+ assets [ sourceMapFile ] = compilation . assets [
274
274
sourceMapFile
275
275
] = new RawSource ( sourceMapString ) ;
276
276
chunk . files . push ( sourceMapFile ) ;
277
277
} else {
278
- asset . __SourceMapDevToolData [ file ] = compilation . assets [
279
- file
280
- ] = new ConcatSource (
278
+ assets [ file ] = compilation . assets [ file ] = new ConcatSource (
281
279
new RawSource ( source ) ,
282
280
currentSourceMappingURLComment
283
281
. replace ( / \[ m a p \] / g, ( ) => sourceMapString )
0 commit comments