babel-plugin-transform-block-scope-to-iife
v1.1.2
Published
Babel plugin to transform top level block scope to IIFE
Downloads
9
Readme
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.