77const { RawSource } = require ( "webpack-sources" ) ;
88const ModuleFilenameHelpers = require ( "./ModuleFilenameHelpers" ) ;
99
10+ const cache = new WeakMap ( ) ;
11+
1012class EvalSourceMapDevToolModuleTemplatePlugin {
1113 constructor ( compilation , options ) {
1214 this . compilation = compilation ;
@@ -29,8 +31,11 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
2931 moduleTemplate . hooks . module . tap (
3032 "EvalSourceMapDevToolModuleTemplatePlugin" ,
3133 ( source , module ) => {
32- if ( source . __EvalSourceMapDevToolData )
33- return source . __EvalSourceMapDevToolData ;
34+ const cachedSource = cache . get ( source ) ;
35+ if ( cachedSource !== undefined ) {
36+ return cachedSource ;
37+ }
38+
3439 if ( ! matchModule ( module . resource ) ) {
3540 return source ;
3641 }
@@ -87,10 +92,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
8792 "utf8"
8893 ) . toString ( "base64" ) } `
8994 ) + `\n//# sourceURL=webpack-internal:///${ module . id } \n` ; // workaround for chrome bug
90- source . __EvalSourceMapDevToolData = new RawSource (
95+
96+ const evalSource = new RawSource (
9197 `eval(${ JSON . stringify ( content + footer ) } );`
9298 ) ;
93- return source . __EvalSourceMapDevToolData ;
99+
100+ cache . set ( source , evalSource ) ;
101+
102+ return evalSource ;
94103 }
95104 ) ;
96105 moduleTemplate . hooks . hash . tap (
0 commit comments