1.1.2 • Published 4 years ago

babel-plugin-transform-block-scope-to-iife v1.1.2

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

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.