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 {
77
77
// Do not re-hook
78
78
if (
79
79
// @ts -ignore
80
- compiler . hooks . thisCompilation . taps . find ( ( { name } ) => name === this . key )
80
+ compiler . hooks . compilation . taps . find ( ( { name } ) => name === this . key )
81
81
) {
82
82
return ;
83
83
}
84
84
85
- compiler . hooks . thisCompilation . tap ( this . key , ( compilation ) => {
85
+ compiler . hooks . compilation . tap ( this . key , ( compilation ) => {
86
86
/** @type {import('./linter').Linter } */
87
87
let lint ;
88
88
/** @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