JSPM

  • Created
  • Published
  • Downloads 20764
  • Score
    100M100P100Q142184F
  • License MIT

Babel plugin to fix buggy JScript named function expressions

Package Exports

  • babel-plugin-transform-jscript

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-transform-jscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

babel-plugin-transform-jscript

This plugin allows Babel to transform named function expressions into function declarations to get around some particularly nasty JScript bugs related to name function expressions.

Example

In

var foo = function bar() {

};

Out

"use strict";

var foo = (function () {
  function bar() {}

  return bar;
})();

Installation

npm install --save-dev babel-plugin-transform-jscript

Usage

.babelrc

{
  "plugins": ["transform-jscript"]
}

Via CLI

babel --plugins transform-jscript script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-jscript"]
});