Skip to content

Commit

Permalink
fix: fix watch.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wood1986 committed Nov 7, 2021
1 parent f0721d3 commit 8e638eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ESLintWebpackPlugin {
// Do not re-hook
if (
// @ts-ignore
compiler.hooks.thisCompilation.taps.find(({ name }) => name === this.key)
compiler.hooks.compilation.taps.find(({ name }) => name === this.key)
) {
return;
}
Expand Down
28 changes: 17 additions & 11 deletions test/child-compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import webpack from 'webpack';

import conf from './utils/conf';

const PLUGIN_NAME = "ChildPlugin";
const PLUGIN_NAME = 'ChildPlugin';
class ChildPlugin {
constructor(options) {
this.options = webpack.config.getNormalizedWebpackOptions(options);
Expand All @@ -11,27 +11,33 @@ class ChildPlugin {
apply(compiler) {
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
const childCompiler = compilation.createChildCompiler(PLUGIN_NAME);
webpack.EntryOptionPlugin.applyEntryOption(childCompiler, compilation.compiler.context, this.options.entry);
webpack.EntryOptionPlugin.applyEntryOption(
childCompiler,
compilation.compiler.context,
this.options.entry
);
childCompiler.runAsChild(() => {
callback();
})
})
});
});
}
}

describe('child compiler', () => {
it("should have linting process", (done) => {
it('should have linting process', (done) => {
const config = conf('good', { threads: false });
config.plugins.push(new ChildPlugin({
entry: {
child: './child-entry'
}
}));
config.plugins.push(
new ChildPlugin({
entry: {
child: './child-entry',
},
})
);
webpack(config).run((err, stats) => {
expect(err).toBeNull();
expect(stats.hasErrors()).toBe(false);
expect(stats.hasWarnings()).toBe(true);
done();
})
});
});
});

0 comments on commit 8e638eb

Please sign in to comment.