* Pass `dirname` as extra metadata to preset constructor.
Sometimes a preset would like to know where it should resolve relative paths from (e.g. https://github.com/tleunen/babel-plugin-module-resolver) and this extra information makes that possible.
* Test for `dirname` passed into preset constructor
This adds a check for `dirname`’s existence and correctness to the
`resolve-addons-relative-to-file` test, and serves as a minimal example
of a path-aware preset.
Only the first for-await was correctly printed all subsequent for-await statements
where printed as for-of as the variable op was changed inside the buildForXStatement
When you write
```
for (const x of l) {
setTimeout(() => x);
}
```
we need to add a closure because the variable is meant to be block-scoped and recreated each time the block runs. We do this.
However, we also add the closure when no loop is present. This isn't necessary, because if no loop is present then each piece of code runs at most once. I changed the transform to only add a closure if a variable is referenced from within a loop.
The PathHoister ignored member references on "this", causing it
to potentially hoist an expression above its function scope.
This patch tells the hoister to watch for "this", and if seen,
mark the nearest non-arrow function scope as the upper limit
for hoistng.
This fixes#4397 and is an alternative to #4787.
The let/const plugin can add closures where you don't expect them. This is undesirable in some perf-sensitive projects (ex: React). I added an option that throws whenever the plugin adds a function (as opposed to simply renaming variables when converting to var).
* checks if babel is installed globally and displays correct cli message - fixes#5228
* recommend local installation and fix lint errors
* uses babel-cli vs babel
* switch back to babel
* use process.cwd() to determine if globally executed
* checks for /node_module/.bin/babel
* compare execPath and module execution path to determine global or local installation
* Move the babel/cli.js into a 'src' so the 'const's are compiled Node < 6.