unused-files-webpack-plugin
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,1 +1,11 @@ | ||
## 1.1.0 (2015-05-22) | ||
#### Bug Fixes | ||
* **UnusedFilesWebpackPlugin:** | ||
* use objectAssign for default values ([f8a2b6f2](https://github.com/tomchentw/unused-files-webpack-plugin/commit/f8a2b6f28825ee6e3898c9f4b60f3e6a22d55bcb)) | ||
* include emitted assets in fileDepsMap ([896e8e23](https://github.com/tomchentw/unused-files-webpack-plugin/commit/896e8e233557de43618ad700b40ed773db73f691)) | ||
## 1.0.0 (2015-05-22) | ||
@@ -2,0 +12,0 @@ |
"use strict"; | ||
var Path = require("path"); | ||
var objectAssign = require("object-assign"); | ||
var glob = require("glob"); | ||
@@ -20,17 +22,8 @@ | ||
UnusedFilesWebpackPlugin.prototype._applyAfterEmit = function(compiler, compilation, done) { | ||
var globOptions = this.globOptions; | ||
if (null == globOptions.cwd) { | ||
globOptions = Object.create(this.globOptions, { | ||
cwd: { | ||
value: compiler.context, | ||
}, | ||
}); | ||
} | ||
var globOptions = this._getGlobOptions(compiler); | ||
glob(this.options.pattern, globOptions, onGlobResult); | ||
var fileDepsBy = compilation.fileDependencies.reduce(function (acc, usedFilepath) { | ||
acc[usedFilepath] = usedFilepath; | ||
return acc; | ||
}, {}); | ||
var fileDepsMap = this._getFileDepsMap(compilation); | ||
var absolutePathResolver = Path.join.bind(Path, globOptions.cwd); | ||
@@ -43,3 +36,3 @@ | ||
var unused = files.filter(function (filepath) { | ||
return !(absolutePathResolver(filepath) in fileDepsBy); | ||
return !(absolutePathResolver(filepath) in fileDepsMap); | ||
}); | ||
@@ -56,3 +49,24 @@ if (unused.length) { | ||
UnusedFilesWebpackPlugin.prototype._getGlobOptions = function (compiler) { | ||
var globOptions = objectAssign({}, this.globOptions); | ||
if (null == globOptions.cwd) { | ||
globOptions.cwd = compiler.context; | ||
} | ||
return globOptions; | ||
}; | ||
UnusedFilesWebpackPlugin.prototype._getFileDepsMap = function (compilation) { | ||
var fileDepsBy = {}; | ||
compilation.fileDependencies.forEach(function (usedFilepath) { | ||
fileDepsBy[usedFilepath] = usedFilepath; | ||
}); | ||
Object.keys(compilation.assets).forEach(function (assetRelpath) { | ||
var existsAt = this[assetRelpath].existsAt; | ||
fileDepsBy[existsAt] = existsAt; | ||
}, compilation.assets); | ||
return fileDepsBy; | ||
}; | ||
module.exports = UnusedFilesWebpackPlugin; |
{ | ||
"__template__gist__": "https://gist.github.com/tomchentw/368a93bb748ad9d576f1#file-package-json", | ||
"name": "unused-files-webpack-plugin", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Glob all files that are not compiled by webpack under webpack's context", | ||
@@ -36,4 +36,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"glob": "^5.0.7" | ||
"glob": "^5.0.7", | ||
"object-assign": "^2.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9940
53
2
+ Addedobject-assign@^2.0.0
+ Addedobject-assign@2.1.1(transitive)