Socket
Socket
Sign inDemoInstall

babel-plugin-transform-es2015-block-scoping

Package Overview
Dependencies
25
Maintainers
5
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-transform-es2015-block-scoping

Compile ES2015 block scoping (const and let) to ES5


Version published
Weekly downloads
1.4M
increased by0.39%
Maintainers
5
Install size
4.38 MB
Created
Weekly downloads
 

Readme

Source

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.

Keywords

FAQs

Last updated on 16 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc