@@ -16,7 +16,10 @@ module.exports.pitch = function(request, preReq, data) {
16
16
this . cacheable && this . cacheable ( ) ;
17
17
var query = loaderUtils . parseQuery ( this . query ) ;
18
18
this . addDependency ( this . resourcePath ) ;
19
- if ( this [ __dirname ] ( null , query ) ) {
19
+ // We already in child compiler, return empty bundle
20
+ if ( this [ __dirname ] === false ) {
21
+ return "" ;
22
+ } else if ( this [ __dirname ] ( null , query ) ) {
20
23
if ( query . omit ) {
21
24
this . loaderIndex += + query . omit + 1 ;
22
25
request = request . split ( "!" ) . slice ( + query . omit ) . join ( "!" ) ;
@@ -47,6 +50,13 @@ module.exports.pitch = function(request, preReq, data) {
47
50
compilation . cache = compilation . cache [ subCache ] ;
48
51
}
49
52
} ) ;
53
+ // We set loaderContext[__dirname] = false to indicate we already in
54
+ // a child compiler so we don't spawn another child compilers from there.
55
+ childCompiler . plugin ( "this-compilation" , function ( compilation ) {
56
+ compilation . plugin ( "normal-module-loader" , function ( loaderContext , module ) {
57
+ loaderContext [ __dirname ] = false ;
58
+ } ) ;
59
+ } ) ;
50
60
var source ;
51
61
childCompiler . plugin ( "after-compile" , function ( compilation , callback ) {
52
62
source = compilation . assets [ childFilename ] && compilation . assets [ childFilename ] . source ( ) ;
@@ -98,4 +108,4 @@ module.exports.pitch = function(request, preReq, data) {
98
108
return resultSource ;
99
109
}
100
110
}
101
- } ;
111
+ } ;
0 commit comments