Babel plugin to transform top level block scope to IIFE
npm install babel-plugin-transform-block-scope-to-iife



!Dependency status

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:
``js`
{
const { Element } = Polymer;
}
Output:
`js`
(function () {
const {
Element
} = Polymer;
})();
``
npm i babel-plugin-transform-block-scope-to-iife
`json`
{
"plugins": [
["babel-plugin-transform-block-scope-to-iife"]
]
}
`js``
require("@babel/core").transform("code", {
plugins: ["babel-plugin-transform-block-scope-to-iife"],
});
This project is licensed under the MIT License.