New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shims

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

shims

Get a lookup table of aliases from your requirejs or browserify config

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
23
21.05%
Maintainers
1
Weekly downloads
 
Created
Source

shims

Get a lookup table of aliases from your requirejs or browserify config

npm install shims

Usage

var shims = require('shims');

var requireShims = shims('path/to/my/requirejs/config.js');
var browserifyShims = shims('path/to/my/package.json');

Example

RequireJS Config:

require.config({
  paths: {
    some: "some/v1.0"
  },
  map: {
    '*': {
      foo: 'foo1.2'
    },
    'some/oldmodule': {
      foo: 'foo1.0'
    }
  },
  shim: {
    'jquery.colorize': {
      deps: ['jquery'],
      exports: 'jQuery.fn.colorize'
    },
    'jquery.scroll': {
      deps: ['jquery'],
      exports: 'jQuery.fn.scroll'
    },
    'backbone.layoutmanager': {
      deps: ['backbone'],
      exports: 'Backbone.LayoutManager'
    }
  }
});

shims returns:

{
  some: "some/v1.0",
  foo: 'foo1.2'
}

Note: shims will honor aliases in a first-come first serve fashion. Since '*' defined foo, that's the alias that will be used.

  • The primary use case for this module isn't to retain the per-module aliases, just to get the general aliases

Browserify Example: Taken from browserify-shim

{
  "main": "./js/entry.js",
  "browser": {
    "jquery": "./js/vendor/jquery.js",
    "underscore": "./js/vendor/underscore.js",
    "backbone": "./js/vendor/backbone.js"
  },
  "browserify-shim": {
    "jquery": "$",
    "three": "global:THREE"
  },
  "browserify": {
    "transform": [ "browserify-shim" ]
  },
  "dependencies": {
    "browserify-shim": "~3.2.0"
  }
}

shims returns:

{
  "jquery": "./js/vendor/jquery.js",
  "underscore": "./js/vendor/underscore.js",
  "backbone": "./js/vendor/backbone.js"
}

Keywords

shim

FAQs

Package last updated on 24 Jul 2014

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