UNPKG

818 BMarkdownView Raw
1# babel-plugin-transform-jscript
2
3> This plugin allows Babel to transform named function expressions into function declarations to get around some [particularly nasty JScript bugs](https://kangax.github.io/nfe/#jscript-bugs) related to name function expressions.
4
5## Example
6
7**In**
8
9```javascript
10var foo = function bar() {
11
12};
13```
14
15**Out**
16
17```javascript
18"use strict";
19
20var foo = (function () {
21 function bar() {}
22
23 return bar;
24})();
25```
26
27## Installation
28
29```sh
30npm install --save-dev babel-plugin-transform-jscript
31```
32
33## Usage
34
35### Via `.babelrc` (Recommended)
36
37**.babelrc**
38
39```json
40{
41 "plugins": ["transform-jscript"]
42}
43```
44
45### Via CLI
46
47```sh
48babel --plugins transform-jscript script.js
49```
50
51### Via Node API
52
53```javascript
54require("babel-core").transform("code", {
55 plugins: ["transform-jscript"]
56});
57```