babel-plugin-transform-hoist-loose-functions

0.1.6 • Public • Published

babel-plugin-transform-hoist-loose-functions

This plugin hoists functions in loose-mode to their enclosing function or program scope.

This plugin was primarily developed to support using babel-minify on non-strict ES5 and below. Currently babel-minify has problems with non-strict nested functions.

Example

In

function foo() {
  if (a) {
    function bar() {}
  }
}

Out

function foo() {
  function bar() {}
 
  if (a) {}
}

Installation

npm install babel-plugin-transform-hoist-loose-functions

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-hoist-loose-functions"]
}

Via CLI

babel --plugins transform-hoist-loose-functions script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-hoist-loose-functions"]
});

Options

None

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-transform-hoist-loose-functions

Weekly Downloads

0

Version

0.1.6

License

MIT

Last publish

Collaborators

  • rossipedia