babel-plugin-transform-es2015-block-scoping

Compile ES2015 block scoping (const and let) to ES5

MIT 51 个版本
安装
npm install babel-plugin-transform-es2015-block-scoping
yarn add babel-plugin-transform-es2015-block-scoping
pnpm add babel-plugin-transform-es2015-block-scoping
bun add 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.

版本列表
7.0.0-beta.3 2017-10-15
7.0.0-beta.2 2017-09-26
7.0.0-beta.1 2017-09-19
7.0.0-beta.0 2017-09-12
7.0.0-alpha.20 2017-08-30
7.0.0-alpha.19 2017-08-07
7.0.0-alpha.18 2017-08-03
7.0.0-alpha.17 2017-07-26
7.0.0-alpha.16 2017-07-25
7.0.0-alpha.15 2017-07-12
7.0.0-alpha.14 2017-07-12
7.0.0-alpha.12 2017-05-31
7.0.0-alpha.11 2017-05-31
7.0.0-alpha.10 2017-05-25
7.0.0-alpha.9 2017-04-18
7.0.0-alpha.8 2017-04-17
7.0.0-alpha.7 2017-04-05
7.0.0-alpha.3 2017-03-23
7.0.0-alpha.1 2017-03-02
6.26.0 2017-08-16
6.24.1 2017-04-07
6.23.0 2017-02-14
6.22.0 2017-01-20
6.21.0 2016-12-16
6.20.0 2016-12-08
6.18.0 2016-10-24
6.15.0 2016-09-01
6.14.0 2016-08-24
6.10.1 2016-06-11
6.10.0 2016-06-11
6.9.0 2016-05-17
6.8.0 2016-05-02
6.7.1 2016-03-09
6.7.0 2016-03-09
6.6.5 2016-03-04
6.6.4 2016-03-02
6.6.0 2016-02-29
6.5.0-1 2016-02-07
6.5.0 2016-02-07
6.4.0 2016-01-06
6.3.13 2015-12-04
6.2.4 2015-11-25
6.1.18 2015-11-12
6.1.17 2015-11-12
6.1.10 2015-11-12
6.1.5 2015-11-12
6.1.4 2015-11-11
6.0.18 2015-11-03
6.0.14 2015-10-30
6.0.9 2015-10-29
6.0.2 2015-10-29