babel-plugin-transform-block-scope-to-iife

1.1.2 • Public • Published

Build Status Commitizen friendly semantic-release codecov Dependency status

NPM

babel-plugin-transform-block-scope-to-iife

Replaces brackets used as scope in a file by an IIFE.
This prevents exposing variables in window when const or let are transformed to var after transpiling to ES5.

Input:

{
  const { Element } = Polymer;
}

Output:

(function () {
  const {
    Element 
  } = Polymer;
})();

Install

npm i babel-plugin-transform-block-scope-to-iife

Usage

With a configuration file (.babelrc)

{
  "plugins": [
    ["babel-plugin-transform-block-scope-to-iife"]
  ]
}

Via Node API

require("@babel/core").transform("code", {
  plugins: ["babel-plugin-transform-block-scope-to-iife"],
});

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i babel-plugin-transform-block-scope-to-iife

Weekly Downloads

4

Version

1.1.2

License

MIT

Unpacked Size

6.37 kB

Total Files

5

Last publish

Collaborators

  • kuscamara