babel-plugin-transform-cjs-system-wrapper

WebJar for babel-plugin-transform-cjs-system-wrapper

License

License

MIT
Categories

Categories

JavaScript Languages ORM Data
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

babel-plugin-transform-cjs-system-wrapper
Last Version

Last Version

0.6.2
Release Date

Release Date

Type

Type

jar
Description

Description

babel-plugin-transform-cjs-system-wrapper
WebJar for babel-plugin-transform-cjs-system-wrapper
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/systemjs/babel-plugin-transform-cjs-system-wrapper

Download babel-plugin-transform-cjs-system-wrapper

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/babel-plugin-transform-cjs-system-wrapper/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>babel-plugin-transform-cjs-system-wrapper</artifactId>
    <version>0.6.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/babel-plugin-transform-cjs-system-wrapper/
implementation 'org.webjars.npm:babel-plugin-transform-cjs-system-wrapper:0.6.2'
// https://jarcasting.com/artifacts/org.webjars.npm/babel-plugin-transform-cjs-system-wrapper/
implementation ("org.webjars.npm:babel-plugin-transform-cjs-system-wrapper:0.6.2")
'org.webjars.npm:babel-plugin-transform-cjs-system-wrapper:jar:0.6.2'
<dependency org="org.webjars.npm" name="babel-plugin-transform-cjs-system-wrapper" rev="0.6.2">
  <artifact name="babel-plugin-transform-cjs-system-wrapper" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='babel-plugin-transform-cjs-system-wrapper', version='0.6.2')
)
libraryDependencies += "org.webjars.npm" % "babel-plugin-transform-cjs-system-wrapper" % "0.6.2"
[org.webjars.npm/babel-plugin-transform-cjs-system-wrapper "0.6.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : babel-template jar [6.9.0,7)

Project Modules

There are no modules declared in this project.

babel-plugin-transform-cjs-system-wrapper

Wraps CommonJS scripts into System.registerDynamic(...

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'], true, 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"],
      "esModule": true,
      "globals": {
        "f": "foo"
      }
    }]
  ]
}

Via CLI

$ babel --plugins transform-cjs-system-wrapper script.js

Via Node API (Recommended)

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: []),
      esModule: true, // optional (default: false)
      map: function(dep) {
        return mappedDep
      }, // (default: identity)
      globals: {  // optional (default: {})
        f: foo
      }
    }]
  ]
});

Versions

Version
0.6.2