Skip to content

Commit c1d4da0

Browse files
Merge pull request #9 from jnsdls/master
update to new webpack hooks interface
2 parents dcbe874 + bf58454 commit c1d4da0

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

example/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
exclude: ['*.test.js'],
2020
// Root directory (optional)
2121
root: __dirname,
22-
failOnUnused: true
22+
failOnUnused: true,
2323
}),
2424
],
2525
};

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function UnusedPlugin(options) {
1010
}
1111

1212
UnusedPlugin.prototype.apply = function(compiler) {
13-
compiler.plugin(
14-
'emit',
13+
compiler.hooks.emit.tapAsync(
14+
'UnusedPlugin',
1515
function(compilation, callback) {
1616
// Files used by Webpack during compilation
1717
const usedModules = Array.from(compilation.fileDependencies)
@@ -44,9 +44,9 @@ module.exports = UnusedPlugin;
4444
function continueOrFail(failOnUnused, compilation, allFiles) {
4545
if (allFiles && allFiles.length > 0) {
4646
if (failOnUnused) {
47-
compilation.errors.push(new Error("Unused files found"));
47+
compilation.errors.push(new Error('Unused files found'));
4848
} else {
49-
compilation.warnings.push(new Error("Unused files found"));
49+
compilation.warnings.push(new Error('Unused files found'));
5050
}
5151
}
5252
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"name": "unused-webpack-plugin",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "A webpack plugin to find unused modules/source files",
55
"main": "index.js",
66
"repository": "https://github.com/MatthieuLemoine/unused-webpack-plugin",
77
"author": "MatthieuLemoine",
88
"license": "MIT",
99
"scripts": {
10-
"pretty":
11-
"prettier-eslint --single-quote --trailing-comma es5 --write \"**/*.js\" \"**/*.json\"",
10+
"pretty": "prettier-eslint --single-quote --trailing-comma es5 --write \"**/*.js\" \"**/*.json\"",
1211
"lint": "eslint index.js"
1312
},
1413
"devDependencies": {

0 commit comments

Comments
 (0)