Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "banify", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Browserify plugin that enforces that certain packages are not imported", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# banify | ||
Browserify plugin that enforces that certain packages are not imported. Inspired by [Apache Maven Enforcer Plugin](http://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html). | ||
Browserify plugin that bans certain packages from being imported. | ||
## Usage | ||
Normally you should do this at the package manager level (e.g. using [dependency-ban](https://www.npmjs.com/package/dependency-ban)). | ||
However, this plugin is useful in scenarios when you want to use a dependency but want to ensure that only parts of it are ever included in the browserify build. | ||
This plugin is inspired by [Apache Maven Enforcer Plugin](http://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html). | ||
## Example | ||
Let's say you are using [lodash](https://lodash.com/) and only cherry-picking certain functions to keep the resulting bundle small. | ||
```js | ||
var find = require('lodash/collection/find'); | ||
``` | ||
You want to enforce that no one accidentally requires all of lodash (e.g. by `require('lodash')`) because that would invalidate the effort. You can use banify to do that: | ||
```js | ||
var banify = require('banify'); | ||
var BLACKLIST = [ | ||
'foo', | ||
/^bar$/ | ||
'lodash', | ||
]; | ||
@@ -16,6 +27,14 @@ | ||
.pipe(bro({ | ||
plugin: [banify([BLACKLIST])] | ||
plugin: [banify(BLACKLIST)] | ||
})) | ||
``` | ||
The plugin fails the build if `require('foo')` or `require('bar')` is used anywhere in the codebase. | ||
The plugin fails the build if `require('lodash')` or is found anywhere in the codebase. Other imports (e.g. `require('lodash/collection/find')`) will succeed. | ||
Besides exact matches a blacklist can also contain regular expressions: | ||
```js | ||
var BLACKLIST = [ | ||
/lodash\/fp\/.*/, | ||
]; | ||
``` |
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
2572
40