@@ -253,7 +253,7 @@ class ContextModule extends Module {
253253 }
254254
255255 getFakeMap ( dependencies ) {
256- if ( ! this . options . namespaceObject ) return 1 ;
256+ if ( ! this . options . namespaceObject ) return 9 ;
257257 // if we filter first we get a new array
258258 // therefor we dont need to create a clone of dependencies explicitly
259259 // therefore the order of this is !important!
@@ -268,20 +268,24 @@ class ContextModule extends Module {
268268 . reduce ( ( map , dep ) => {
269269 const exportsType =
270270 dep . module . buildMeta && dep . module . buildMeta . exportsType ;
271- if ( ! exportsType ) hasNonHarmony = true ;
272- if ( exportsType === "namespace" ) hasNamespace = true ;
273- if ( exportsType === "named" ) hasNamed = true ;
274- map [ dep . module . id ] =
275- {
276- namespace : 1 ,
277- named : 2
278- } [ exportsType ] || 0 ;
271+ const id = dep . module . id ;
272+ if ( ! exportsType ) {
273+ map [ id ] = this . options . namespaceObject === "strict" ? 1 : 7 ;
274+ hasNonHarmony = true ;
275+ } else if ( exportsType === "namespace" ) {
276+ map [ id ] = 9 ;
277+ hasNamespace = true ;
278+ } else if ( exportsType === "named" ) {
279+ map [ id ] = 3 ;
280+ hasNamed = true ;
281+ }
279282 return map ;
280283 } , Object . create ( null ) ) ;
281- if ( ! hasNamespace && hasNonHarmony && ! hasNamed ) return 0 ;
282- if ( hasNamespace && ! hasNonHarmony && ! hasNamed ) return 1 ;
283- if ( ! hasNamespace && ! hasNonHarmony && hasNamed ) return 2 ;
284- if ( ! hasNamespace && ! hasNonHarmony && ! hasNamed ) return 1 ;
284+ if ( ! hasNamespace && hasNonHarmony && ! hasNamed )
285+ return this . options . namespaceObject === "strict" ? 1 : 7 ;
286+ if ( hasNamespace && ! hasNonHarmony && ! hasNamed ) return 9 ;
287+ if ( ! hasNamespace && ! hasNonHarmony && hasNamed ) return 3 ;
288+ if ( ! hasNamespace && ! hasNonHarmony && ! hasNamed ) return 9 ;
285289 return fakeMap ;
286290 }
287291
@@ -292,26 +296,14 @@ class ContextModule extends Module {
292296 }
293297
294298 getReturn ( type ) {
295- if ( type === 1 ) return "module" ;
296- if ( type === 2 )
297- return 'Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module })' ;
298- if ( type === 0 ) {
299- if ( this . options . namespaceObject === "strict" ) {
300- return '/* fake namespace object */ { "default": module }' ;
301- } else {
302- return '(typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }))' ;
303- }
304- }
299+ if ( type === 9 ) return "__webpack_require__(id)" ;
300+ return `__webpack_require__.t(id, ${ type } )` ;
305301 }
306302
307303 getReturnModuleObjectSource ( fakeMap , fakeMapDataExpression = "fakeMap[id]" ) {
308304 if ( typeof fakeMap === "number" )
309305 return `return ${ this . getReturn ( fakeMap ) } ;` ;
310- return `return ${ fakeMapDataExpression } === 1 ? ${ this . getReturn (
311- 1
312- ) } : ${ fakeMapDataExpression } ? ${ this . getReturn ( 2 ) } : ${ this . getReturn (
313- 0
314- ) } ;`;
306+ return `return __webpack_require__.t(id, ${ fakeMapDataExpression } )` ;
315307 }
316308
317309 getSyncSource ( dependencies , id ) {
@@ -324,7 +316,6 @@ ${this.getFakeMapInitStatement(fakeMap)}
324316
325317function webpackContext(req) {
326318 var id = webpackContextResolve(req);
327- var module = __webpack_require__(id);
328319 ${ returnModuleObject }
329320}
330321function webpackContextResolve(req) {
@@ -359,7 +350,6 @@ function webpackContext(req) {
359350 e.code = 'MODULE_NOT_FOUND';
360351 throw e;
361352 }
362- var module = __webpack_require__(id);
363353 ${ returnModuleObject }
364354}
365355function webpackContextResolve(req) {
@@ -394,7 +384,6 @@ function webpackAsyncContext(req) {
394384 e.code = 'MODULE_NOT_FOUND';
395385 throw e;
396386 }
397- var module = __webpack_require__(id);
398387 ${ returnModuleObject }
399388 });
400389}
@@ -423,11 +412,10 @@ module.exports = webpackAsyncContext;`;
423412 const map = this . getUserRequestMap ( dependencies ) ;
424413 const fakeMap = this . getFakeMap ( dependencies ) ;
425414 const thenFunction =
426- fakeMap !== 1
415+ fakeMap !== 9
427416 ? `function(id) {
428- var module = __webpack_require__(id);
429- ${ this . getReturnModuleObjectSource ( fakeMap ) }
430- }`
417+ ${ this . getReturnModuleObjectSource ( fakeMap ) }
418+ }`
431419 : "__webpack_require__" ;
432420 return `var map = ${ JSON . stringify ( map , null , "\t" ) } ;
433421${ this . getFakeMapInitStatement ( fakeMap ) }
@@ -464,9 +452,8 @@ module.exports = webpackAsyncContext;`;
464452 const map = this . getUserRequestMap ( dependencies ) ;
465453 const fakeMap = this . getFakeMap ( dependencies ) ;
466454 const thenFunction =
467- fakeMap !== 1
455+ fakeMap !== 9
468456 ? `function(id) {
469- var module = __webpack_require__(id);
470457 ${ this . getReturnModuleObjectSource ( fakeMap ) } ;
471458 }`
472459 : "__webpack_require__" ;
@@ -546,7 +533,7 @@ function webpackAsyncContext(req) {
546533 });
547534 }
548535 return ${ requestPrefix } .then(function() {
549- var module = __webpack_require__( ids[0]) ;
536+ var id = ids[0];
550537 ${ returnModuleObject }
551538 });
552539}
0 commit comments