Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/droidxrx/babel-plugin-transform-global-window
Transforms previously module scoped variables into globally scoped window properties
https://github.com/droidxrx/babel-plugin-transform-global-window
babel babel-plugin babel-plugin-transform-global
Last synced: 19 days ago
JSON representation
Transforms previously module scoped variables into globally scoped window properties
- Host: GitHub
- URL: https://github.com/droidxrx/babel-plugin-transform-global-window
- Owner: droidxrx
- License: mit
- Created: 2021-07-31T08:51:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-03T10:46:43.000Z (over 3 years ago)
- Last Synced: 2024-04-25T21:20:29.987Z (10 months ago)
- Topics: babel, babel-plugin, babel-plugin-transform-global
- Language: JavaScript
- Homepage: https://github.com/droidxrx
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Babel plugin transform global window
Transforms previously module scoped variables into globally scoped window properties
## Installation
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).```bash
npm install --save-dev babel-plugin-transform-global-window
``````bash
yarn add --dev babel-plugin-transform-global-window
```## Usage
Add to .babelrc
```json
{
"plugins": ["babel-plugin-transform-global-window"]
}
```**Input**
```Javascript
const myvar1 = "MyVar1";
let myvar2 = "MyVar2";
const arrfun = () => 1 + 1;
function myFun() {
return 1 + 1;
}
class myClass {}
```**Output**
```javascript
const myvar1 = "MyVar1";
let myvar2 = "MyVar2";const arrfun = () => 1 + 1;
function myFun() {
return 1 + 1;
}class myClass {}
window.myvar1 = myvar1;
window.myvar2 = myvar2;
window.arrfun = arrfun;
window.myFun = myFun;
window.myClass = myClass;
```## License
[MIT](LICENSE)