0.0.2 • Published 4 years ago

@hqjs/babel-plugin-expose-global-to-window v0.0.2

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

https://hqjs.org

Explicitly expose global variables and functions to window in non module script.

Installation

npm install hqjs@babel-plugin-expose-global-to-window

Transformation

var x = 1, xx = 11, xxx = 111;

if (true) {
  var y = 2;
  function w() {}
}

class A {}

function f() {
  var x = 2;
  var z = 17;
  function f() {}
  
  function g() {}
}

const z = () => 0;

will turn into

var x = 1,
    xx = 11,
    xxx = 111;

if (true) {
  var y = 2;

  function w() {}
}

class A {}

function f() {
  var x = 2;
  var z = 17;

  function f() {}

  function g() {}
}

const z = () => 0;

window.x = x;
window.xx = xx;
window.xxx = xxx;
window.y = y;
window.f = f;