Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kcmr/babel-plugin-transform-block-scope-to-iife
Babel plugin to transform top level block scope to IIFE
https://github.com/kcmr/babel-plugin-transform-block-scope-to-iife
babel babel-plugin babel7
Last synced: 10 days ago
JSON representation
Babel plugin to transform top level block scope to IIFE
- Host: GitHub
- URL: https://github.com/kcmr/babel-plugin-transform-block-scope-to-iife
- Owner: kcmr
- License: mit
- Created: 2020-04-17T14:57:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:38:52.000Z (almost 2 years ago)
- Last Synced: 2024-10-15T09:02:58.807Z (22 days ago)
- Topics: babel, babel-plugin, babel7
- Language: JavaScript
- Size: 1.87 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.com/kcmr/babel-plugin-transform-block-scope-to-iife.svg?branch=master)](https://travis-ci.com/kcmr/babel-plugin-transform-block-scope-to-iife)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![codecov](https://codecov.io/gh/kcmr/babel-plugin-transform-block-scope-to-iife/branch/master/graph/badge.svg)](https://codecov.io/gh/kcmr/babel-plugin-transform-block-scope-to-iife)
![Dependency status](https://img.shields.io/david/kcmr/babel-plugin-transform-block-scope-to-iife.svg)[![NPM](https://nodei.co/npm/babel-plugin-transform-block-scope-to-iife.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/babel-plugin-transform-block-scope-to-iife/)
# 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:**
```js
{
const { Element } = Polymer;
}
```**Output:**
```js
(function () {
const {
Element
} = Polymer;
})();
```## Install
```
npm i babel-plugin-transform-block-scope-to-iife
```## Usage
### With a configuration file (`.babelrc`)
```json
{
"plugins": [
["babel-plugin-transform-block-scope-to-iife"]
]
}
```### Via Node API
```js
require("@babel/core").transform("code", {
plugins: ["babel-plugin-transform-block-scope-to-iife"],
});
```## License
This project is licensed under the [MIT License](LICENSE).