🌜
🌞
babel-plugin-transform-es2015-block-scoping

babel-plugin-transform-es2015-block-scoping

v6.26.0

Compile ES2015 block scoping (const and let) to ES5

npm install babel-plugin-transform-es2015-block-scoping

README

babel-plugin-transform-es2015-block-scoping

Compile ES2015 block scoping (const and let) to ES5

Installation

npm install --save-dev babel-plugin-transform-es2015-block-scoping

Usage

.babelrc

Without options:

{
  "plugins": ["transform-es2015-block-scoping"]
}

With options:

{
  "plugins": [
    ["transform-es2015-block-scoping", {
      "throwIfClosureRequired": true
    }]
  ]
}

Via CLI

babel --plugins transform-es2015-block-scoping script.js

Via Node API

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

Options throwIfClosureRequired

In cases such as the following it's impossible to rewrite let/const without adding an additional function and closure while transforming:

for (let i = 0; i < 5; i++) {
  setTimeout(() => console.log(i), 1);
}

In extremely performance-sensitive code, this can be undesirable. If "throwIfClosureRequired": true is set, Babel throws when transforming these patterns instead of automatically adding an additional function.

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
41.4K
Community Interest
44K
Number of Forks
5,455

Maintenance

Commits
10/219/22070
Last Commit
Open Issues
628
Closed Issues
7,633
Open Pull Requests
149
Closed Pull Requests
1,045

Versions

Versions Released
10/219/2201
Latest Version Released
Aug 16, 2017
Current Tags
latest6.26.0
next7.0.0-beta.3

Contributors

sebmck
sebmck
Commits: 5,192
hzoo
hzoo
Commits: 1,264
nicolo-ribaudo
nicolo-ribaudo
Commits: 596
loganfsmyth
loganfsmyth
Commits: 594
existentialism
existentialism
Commits: 469
danez
danez
Commits: 433
JLHwung
JLHwung
Commits: 372
marijnh
marijnh
Commits: 264
RReverser
RReverser
Commits: 233
jamiebuilds
jamiebuilds
Commits: 224
amasad
amasad
Commits: 172
jridgewell
jridgewell
Commits: 159
xtuc
xtuc
Commits: 106
yavorsky
yavorsky
Commits: 89
kaicataldo
kaicataldo
Commits: 82