@@ -18,12 +18,14 @@ const basename = name => {
1818 return name . substr ( name . lastIndexOf ( "/" ) + 1 ) ;
1919} ;
2020
21+ const assetsCache = new WeakMap ( ) ;
22+
2123const getTaskForFile = ( file , chunk , options , compilation ) => {
2224 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 ] ;
2729 if ( cachedFile !== file ) chunk . files . push ( cachedFile ) ;
2830 }
2931 return ;
@@ -207,6 +209,7 @@ class SourceMapDevToolPlugin {
207209 task . file ,
208210 "attach SourceMap"
209211 ) ;
212+ const assets = Object . create ( null ) ;
210213 const chunk = task . chunk ;
211214 const file = task . file ;
212215 const asset = task . asset ;
@@ -222,8 +225,7 @@ class SourceMapDevToolPlugin {
222225 }
223226 sourceMap . sourceRoot = options . sourceRoot || "" ;
224227 sourceMap . file = file ;
225- asset . __SourceMapDevToolFile = file ;
226- asset . __SourceMapDevToolData = { } ;
228+ assetsCache . set ( asset , { file, assets } ) ;
227229 let currentSourceMappingURLComment = sourceMappingURLComment ;
228230 if (
229231 currentSourceMappingURLComment !== false &&
@@ -260,24 +262,20 @@ class SourceMapDevToolPlugin {
260262 . relative ( path . dirname ( file ) , sourceMapFile )
261263 . replace ( / \\ / g, "/" ) ;
262264 if ( currentSourceMappingURLComment !== false ) {
263- asset . __SourceMapDevToolData [ file ] = compilation . assets [
264- file
265- ] = new ConcatSource (
265+ assets [ file ] = compilation . assets [ file ] = new ConcatSource (
266266 new RawSource ( source ) ,
267267 currentSourceMappingURLComment . replace (
268268 / \[ u r l \] / g,
269269 sourceMapUrl
270270 )
271271 ) ;
272272 }
273- asset . __SourceMapDevToolData [ sourceMapFile ] = compilation . assets [
273+ assets [ sourceMapFile ] = compilation . assets [
274274 sourceMapFile
275275 ] = new RawSource ( sourceMapString ) ;
276276 chunk . files . push ( sourceMapFile ) ;
277277 } else {
278- asset . __SourceMapDevToolData [ file ] = compilation . assets [
279- file
280- ] = new ConcatSource (
278+ assets [ file ] = compilation . assets [ file ] = new ConcatSource (
281279 new RawSource ( source ) ,
282280 currentSourceMappingURLComment
283281 . replace ( / \[ m a p \] / g, ( ) => sourceMapString )
0 commit comments