Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unused-files-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unused-files-webpack-plugin - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

10

CHANGELOG.md

@@ -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 @@

40

lib/index.js
"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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc