Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit 37c49d0

Browse files
authored
Merge pull request #63 from ooflorent/use_hooks
Remove webpack 4 warnings
2 parents b285d82 + 98baeb9 commit 37c49d0

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"license": "MIT",
2828
"peerDependencies": {
29-
"webpack": "^2.0.0 || ^3.0.0"
29+
"webpack": "^2.0.0 || ^3.0.0 || ^4.0.0"
3030
},
3131
"devDependencies": {
3232
"babel-core": "^6.23.1",

src/friendly-errors-plugin.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FriendlyErrorsWebpackPlugin {
3636

3737
apply(compiler) {
3838

39-
compiler.plugin('done', stats => {
39+
const doneFn = stats => {
4040
this.clearConsole();
4141

4242
const hasErrors = stats.hasErrors();
@@ -55,12 +55,22 @@ class FriendlyErrorsWebpackPlugin {
5555
if (hasWarnings) {
5656
this.displayErrors(extractErrorsFromStats(stats, 'warnings'), 'warning');
5757
}
58-
});
58+
};
5959

60-
compiler.plugin('invalid', () => {
60+
const invalidFn = () => {
6161
this.clearConsole();
6262
output.title('info', 'WAIT', 'Compiling...');
63-
});
63+
};
64+
65+
if (compiler.hooks) {
66+
const plugin = { name: 'FriendlyErrorsWebpackPlugin' };
67+
68+
compiler.hooks.done.tap(plugin, doneFn);
69+
compiler.hooks.invalid.tap(plugin, invalidFn);
70+
} else {
71+
compiler.plugin('done', doneFn);
72+
compiler.plugin('invalid', invalidFn);
73+
}
6474
}
6575

6676
clearConsole() {

src/transformers/moduleNotFound.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const TYPE = 'module-not-found';
44

55
function isModuleNotFoundError (e) {
6-
const webpackError = e.webpackError || {};
6+
const webpackError = e.webpackError || {};
77
return webpackError.dependencies
88
&& webpackError.dependencies.length > 0
99
&& e.name === 'ModuleNotFoundError'

test/integration.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const webpackPromise = function (config, globalPlugins) {
1010
const compiler = webpack(config);
1111
compiler.outputFileSystem = new MemoryFileSystem();
1212
if (Array.isArray(globalPlugins)) {
13-
globalPlugins.forEach(p => compiler.apply(p));
13+
globalPlugins.forEach(p => p.apply(compiler));
1414
}
1515

1616
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)