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

babel-plugin-transform-cjs-system-wrapper

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-cjs-system-wrapper

Wraps CommonJS scripts into System.registerDynamic(...

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-5.32%
Maintainers
2
Weekly downloads
 
Created
Source

babel-plugin-transform-cjs-system-wrapper

Wraps CommonJS scripts into System.registerDynamic(...

For SystemJS 0.19 and below support, use the 0.3.0 version.

Example

In

'use strict';

var foo = require('foo/');

Babel Options

{
  moduleId: 'foobar'
  plugins: [
    ['transform-cjs-system-wrapper', {
      deps: ['bar'],
      globals: {
        f: foo
      }
    }]
  ]
}

Out

System.registerDynamic('foobar', ['bar'], function ($__require, exports, module) {
  'use strict';

  var f = $__require('foo');
  var global = this,
      GLOBAL = this;
  var foo = $__require('foo');
});

Installation

$ npm install babel-plugin-transform-cjs-system-wrapper

Usage

Via .babelrc

.babelrc

{
  "moduleId": "foobar",
  "plugins": [
    ["transform-cjs-system-wrapper", {
      "systemGlobal": "SystemJS",
      "path": "/path/to/foobar",
      "optimize": true,
      "static": true,
      "deps": ["bar"],
      "globals": {
        "f": "foo"
      }
    }]
  ]
}

Via CLI

$ babel --plugins transform-cjs-system-wrapper script.js
require("babel-core").transform("code", {
  moduleId: 'foobar', // optional (default: '')
  plugins: [
    ["transform-cjs-system-wrapper", {
      requireName: 'require' // (default: 'require')
      systemGlobal: "SystemJS", // optional (default: 'SystemJS')
      path: "/path/to/foobar", // optional (default: '')
      optimize: true, // optional (default: false)
      static: true, // optional (default: false)
      deps: ['bar'], // optional (default: []),
      map: function(dep) {
        return mappedDep
      }, // (default: identity)
      globals: {  // optional (default: {})
        f: foo
      }
    }]
  ]
});

Keywords

FAQs

Package last updated on 23 Jan 2017

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