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

Browserify plugin that enforces that certain packages are not imported

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

banify

Browserify plugin that bans certain packages from being imported.

Normally you should do this at the package manager level (e.g. using 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.

Example

Let's say you are using lodash and only cherry-picking certain functions to keep the resulting bundle small.

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:

var banify = require('banify');
var BLACKLIST = [
    'lodash',
];

gulp.src(['./index.js'])
    .pipe(bro({
        plugin: [banify(BLACKLIST)]
    }))

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:

var BLACKLIST = [
    /lodash\/fp\/.*/,
];

Keywords

FAQs

Package last updated on 06 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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