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

Commit

Permalink
Merge pull request #63 from ooflorent/use_hooks
Browse files Browse the repository at this point in the history
Remove webpack 4 warnings
  • Loading branch information
timneutkens committed Apr 5, 2018
2 parents b285d82 + 98baeb9 commit 37c49d0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"license": "MIT",
"peerDependencies": {
"webpack": "^2.0.0 || ^3.0.0"
"webpack": "^2.0.0 || ^3.0.0 || ^4.0.0"
},
"devDependencies": {
"babel-core": "^6.23.1",
Expand Down
18 changes: 14 additions & 4 deletions src/friendly-errors-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FriendlyErrorsWebpackPlugin {

apply(compiler) {

compiler.plugin('done', stats => {
const doneFn = stats => {
this.clearConsole();

const hasErrors = stats.hasErrors();
Expand All @@ -55,12 +55,22 @@ class FriendlyErrorsWebpackPlugin {
if (hasWarnings) {
this.displayErrors(extractErrorsFromStats(stats, 'warnings'), 'warning');
}
});
};

compiler.plugin('invalid', () => {
const invalidFn = () => {
this.clearConsole();
output.title('info', 'WAIT', 'Compiling...');
});
};

if (compiler.hooks) {
const plugin = { name: 'FriendlyErrorsWebpackPlugin' };

compiler.hooks.done.tap(plugin, doneFn);
compiler.hooks.invalid.tap(plugin, invalidFn);
} else {
compiler.plugin('done', doneFn);
compiler.plugin('invalid', invalidFn);
}
}

clearConsole() {
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/moduleNotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const TYPE = 'module-not-found';

function isModuleNotFoundError (e) {
const webpackError = e.webpackError || {};
const webpackError = e.webpackError || {};
return webpackError.dependencies
&& webpackError.dependencies.length > 0
&& e.name === 'ModuleNotFoundError'
Expand Down
2 changes: 1 addition & 1 deletion test/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const webpackPromise = function (config, globalPlugins) {
const compiler = webpack(config);
compiler.outputFileSystem = new MemoryFileSystem();
if (Array.isArray(globalPlugins)) {
globalPlugins.forEach(p => compiler.apply(p));
globalPlugins.forEach(p => p.apply(compiler));
}

return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 37c49d0

Please sign in to comment.