0.1.6 • Published 7 years ago

babel-plugin-transform-hoist-loose-functions v0.1.6

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

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