@@ -254,6 +254,10 @@ class ContextModule extends Module {
254254 return fakeMap ;
255255 }
256256
257+ getFakeMapInitStatement ( fakeMap ) {
258+ return typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" ;
259+ }
260+
257261 getReturnModuleObjectSource ( fakeMap , fakeMapDataExpression = "fakeMap[id]" ) {
258262 const strict = this . options . namespaceObject === "strict" ;
259263 const getReturn = type => {
@@ -277,7 +281,7 @@ class ContextModule extends Module {
277281 const returnModuleObject = `${ this . getReturnModuleObjectSource ( fakeMap ) } ;` ;
278282
279283 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
280- ${ typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" }
284+ ${ this . getFakeMapInitStatement ( fakeMap ) }
281285
282286function webpackContext(req) {
283287 var id = webpackContextResolve(req);
@@ -307,7 +311,7 @@ webpackContext.id = ${JSON.stringify(id)};`;
307311 const returnModuleObject = `${ this . getReturnModuleObjectSource ( fakeMap ) } ;` ;
308312
309313 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
310- ${ typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" }
314+ ${ this . getFakeMapInitStatement ( fakeMap ) }
311315
312316function webpackContext(req) {
313317 var id = webpackContextResolve(req);
@@ -342,7 +346,7 @@ module.exports = webpackContext;`;
342346 const returnModuleObject = `${ this . getReturnModuleObjectSource ( fakeMap ) } ;` ;
343347
344348 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
345- ${ typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" }
349+ ${ this . getFakeMapInitStatement ( fakeMap ) }
346350
347351function webpackAsyncContext(req) {
348352 return webpackAsyncContextResolve(req).then(function(id) {
@@ -386,7 +390,7 @@ module.exports = webpackAsyncContext;`;
386390}` :
387391 "__webpack_require__" ;
388392 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
389- ${ typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" }
393+ ${ this . getFakeMapInitStatement ( fakeMap ) }
390394
391395function webpackAsyncContext(req) {
392396 return webpackAsyncContextResolve(req).then(${ thenFunction } );
@@ -427,7 +431,7 @@ module.exports = webpackAsyncContext;`;
427431 "__webpack_require__" ;
428432
429433 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
430- ${ typeof fakeMap === "object" ? `var fakeMap = ${ JSON . stringify ( fakeMap , null , "\t" ) } ;` : "" }
434+ ${ this . getFakeMapInitStatement ( fakeMap ) }
431435
432436function webpackAsyncContext(req) {
433437 return webpackAsyncContextResolve(req).then(${ thenFunction } );
0 commit comments