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

banify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

banify - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"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\/.*/,
];
```
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