This repository was archived by the owner on Sep 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export function pitch(request) {
3737 const cb = this . async ( ) ;
3838
3939 const filename = loaderUtils . interpolateName ( this , options . name || '[hash].worker.js' , {
40- context : options . context || this . options . context ,
40+ context : options . context || this . rootContext || this . options . context ,
4141 regExp : options . regExp ,
4242 } ) ;
4343
@@ -62,13 +62,23 @@ export function pitch(request) {
6262
6363 const subCache = `subcache ${ __dirname } ${ request } ` ;
6464
65- worker . compiler . plugin ( ' compilation' , ( compilation ) => {
65+ worker . compilation = ( compilation ) => {
6666 if ( compilation . cache ) {
67- if ( ! compilation . cache [ subCache ] ) compilation . cache [ subCache ] = { } ;
67+ if ( ! compilation . cache [ subCache ] ) {
68+ compilation . cache [ subCache ] = { } ;
69+ }
6870
6971 compilation . cache = compilation . cache [ subCache ] ;
7072 }
71- } ) ;
73+ } ;
74+
75+ if ( worker . compiler . hooks ) {
76+ const plugin = { name : 'WorkerLoader' } ;
77+
78+ worker . compiler . hooks . compilation . tap ( plugin , worker . compilation ) ;
79+ } else {
80+ worker . compiler . plugin ( 'compilation' , worker . compilation ) ;
81+ }
7282
7383 worker . compiler . runAsChild ( ( err , entries , compilation ) => {
7484 if ( err ) return cb ( err ) ;
You can’t perform that action at this time.
0 commit comments