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

browserify-global-shim

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify-global-shim

Browserify transform for replacing modules with global variables

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

browserify-global-shim

A browserify transform for replacing modules with global variables.

Are you using browserify to convert a module that depends on lo-dash, jQuery, q or some other omnipresent library? And you don't want to include this dependency in your browserify-build because it's already part of your web app? Use browserify-global-shim to replace require('some module') with references to a global variable.

Getting Started

Install the module with: npm install --save-dev browserify-global-shim

Configure it via package.json:

{
    "name": "myProject",
    "version": "1.0.0",
    ...
	"browserify": {
		"transform": [
			"browserify-global-shim"
		]
	},
    "browserify-global-shim": {
    	"jQuery": "$"
    },
    ...
}

or by using the browserify API:

var browserify = require('browserify');
var b = browserify();
...
var globalShim = require('browserify-global-shim').configure({
	'jQuery': '$'
});
b.transform(globalShim);
...

In both cases all references to require('jQuery') will be replaced with window.$ when you run browserify.

Similar libraries

What are you saying? The global:... option of browserify-shim does just the same? That's true!

And browserify-shim is also configurable via an API? Also true!

But unfortunately you can't have both at the same time. The API is only supported in the old 2.x versions, the global:... option became available in 3.x. If you need both, you're in a tough spot.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Raphael Luba. Licensed under the MIT license.

FAQs

Package last updated on 12 Jan 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