1.1.2 • Published 6 years ago
babel-plugin-transform-block-scope-to-iife v1.1.2
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-iifeUsage
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.
