A few seconds.

babel-plugin-transform-global-system-wrapper

Converts global scripts into named System.registerDynamic('name', [], ...

babel-plugin-transform-global-system-wrapper

Converts global scripts into named System.registerDynamic('name', [], ...

Example

In

foo = "bar";

Out

System.registerDynamic("foo", [], false, function ($__require, $__exports, $__module) {
  var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal($__module.id, "foo", null);

  (function ($__global) {
    foo = "bar";
  })(this);

  return _retrieveGlobal();
});

Installation

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

Usage

Via .babelrc

.babelrc

{
  "plugins": [
    ["transform-global-system-wrapper", {
      "deps": ["baz.js"],
      "exportName": "foo",
      "globals": {
        "jquery": "jquery.js"
      },
      "moduleName": "foo",
      "systemGlobal": "SystemJS"
    }]
  ]
}

Via CLI

$ babel --plugins transform-global-system-wrapper script.js
require("babel-core").transform("code", {
  plugins: [
    ["transform-global-system-wrapper", {
      deps: ["baz.js"],
      exportName: "foo",
      globals: {
        "jquery": "jquery.js"
      },
      moduleName: "foo",
      systemGlobal: "SystemJS",
    }]
  ]
});
Pincer is a project which aims to provide best library discovery tools for developers. We're growing day by day. We have only npm platform for now but we will add the others as much as we can.