File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -77,12 +77,12 @@ class ESLintWebpackPlugin {
7777 // Do not re-hook
7878 if (
7979 // @ts -ignore
80- compiler . hooks . thisCompilation . taps . find ( ( { name } ) => name === this . key )
80+ compiler . hooks . compilation . taps . find ( ( { name } ) => name === this . key )
8181 ) {
8282 return ;
8383 }
8484
85- compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
85+ compiler . hooks . compilation . tap ( this . key , ( compilation ) => {
8686 /** @type {import('./linter').Linter } */
8787 let lint ;
8888 /** @type {import('./linter').Reporter } */
Original file line number Diff line number Diff line change 1+ import webpack from 'webpack' ;
2+
3+ import conf from './utils/conf' ;
4+
5+ const PLUGIN_NAME = 'ChildPlugin' ;
6+ class ChildPlugin {
7+ constructor ( options ) {
8+ this . options = webpack . config . getNormalizedWebpackOptions ( options ) ;
9+ }
10+
11+ apply ( compiler ) {
12+ compiler . hooks . make . tapAsync ( PLUGIN_NAME , ( compilation , callback ) => {
13+ const childCompiler = compilation . createChildCompiler ( PLUGIN_NAME ) ;
14+ webpack . EntryOptionPlugin . applyEntryOption (
15+ childCompiler ,
16+ compilation . compiler . context ,
17+ this . options . entry
18+ ) ;
19+ childCompiler . runAsChild ( ( ) => {
20+ callback ( ) ;
21+ } ) ;
22+ } ) ;
23+ }
24+ }
25+
26+ describe ( 'child compiler' , ( ) => {
27+ it ( 'should have linting process' , ( done ) => {
28+ const config = conf ( 'good' , { threads : false } ) ;
29+ config . plugins . push (
30+ new ChildPlugin ( {
31+ entry : {
32+ child : './child-entry' ,
33+ } ,
34+ } )
35+ ) ;
36+ webpack ( config ) . run ( ( err , stats ) => {
37+ expect ( err ) . toBeNull ( ) ;
38+ expect ( stats . hasErrors ( ) ) . toBe ( false ) ;
39+ expect ( stats . hasWarnings ( ) ) . toBe ( true ) ;
40+ done ( ) ;
41+ } ) ;
42+ } ) ;
43+ } ) ;
Original file line number Diff line number Diff line change 1+ console . log ( "Hello from child-entry.js" ) ;
You can’t perform that action at this time.
0 commit comments