310 Commits

Author SHA1 Message Date
Logan Smyth
86fc4fbc4f Avoid using OptionManager statics 2017-04-10 10:01:01 -07:00
Andres Suarez
f0dc710a46 Remove unnecessary returns in asyncToGenerator helper (#5548)
* Remove unnecessary returns in asyncToGenerator helper

* Reuse "then" callbacks in asyncToGenerator helpher
2017-04-06 11:40:55 -04:00
Logan Smyth
d39400c9d5 Separate config/plugin loading from config processing. (#5563) 2017-04-04 14:48:48 -07:00
Logan Smyth
878a7c5fdb Add tests to test the plugin ordering. (#5571) 2017-03-31 18:52:58 -07:00
Henry Zhu
3d74dc044f fix ci 2017-03-27 17:26:39 -04:00
Henry Zhu
67253c5d27 babelrc false to relevant files 2017-03-27 17:19:02 -04:00
Kai Cataldo
1f2f63ccdf Fix: config lookup logic in babel-core (#5550)
This fixes a bug that was causing the config lookup to stop
when a package.json file was found even if it did not contain a
"babel" key.
2017-03-27 11:54:57 -07:00
Logan Smyth
3c63431c7e Move config loading helpers into config folder. 2017-03-17 00:03:59 -07:00
Logan Smyth
12a2124d16 Move the deeply nested option logic to a toplevel folder. 2017-03-17 00:03:58 -07:00
Logan Smyth
6c4810cea5 Move Plugin class to be part of config loading, independent of File. 2017-03-17 00:03:58 -07:00
Logan Smyth
bf13ed4da0 Limit where certain arguments are allowed in Babel config. 2017-03-17 00:03:58 -07:00
Logan Smyth
39c862c195 Make only/ignore relative to cwd/config file and move only/ignore checking all to core. (#5487)
* Make only/ignore relative to cwd/config file and move only/ignore checking all to core.
2017-03-16 23:22:43 -07:00
Logan Smyth
b6194a8533 Merge pull request #5467 from loganfsmyth/clean-options
Misc reorganizing and prep for ignore/only refactoring
2017-03-16 20:25:20 -07:00
Logan Smyth
dd1bc3b183 Resolve programmatic/CLI arguments from cwd, not file being compiled. (#5466) 2017-03-14 16:56:00 -07:00
Logan Smyth
bf4664b430 Invert the resolution order of config-chain to process higher-priority items first. 2017-03-14 13:39:57 -07:00
Logan Smyth
4f72232ca9 Move option parsing to babel-cli. 2017-03-13 11:06:46 -07:00
Logan Smyth
305165eda4 Remove Logger usage from options processing. 2017-03-09 16:13:38 -08:00
Kai Cataldo
d054cd0ea8 Add support for .babelrc.js files 2017-03-07 16:44:24 -05:00
Brian Ng
8a82cc060a Run new lint rules (#5413) 2017-03-04 10:46:01 -05:00
Daniel Tschinder
6d6cdf6baf [7.0] Allow presets to be objects (#5385)
* Allow presets to be objects

* Improve logic to detect preset format
2017-02-28 16:39:08 -05:00
Henry Zhu
d33d023594 Merge remote-tracking branch 'origin/master' into merge-master 2017-02-23 18:54:15 -05:00
Daniel Tschinder
87ca6150ae [7.0] Remove bc code from preset handling and preset-es2015 (#5128)
* Remove bc code from preset handling and preset-es2015

* Add more tests

* Only allow functions for presets

* Fix lint
2017-02-22 14:58:01 +01:00
Izaak Schroeder
8d9195f862 Pass dirname as extra metadata to preset constructor. (#4834)
* 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.
2017-02-21 22:13:03 -05:00
Daniel Tschinder
6c03cb0783
Merge branch 'master' into merge-master
# Conflicts:
#	lerna.json
#	packages/babel-cli/package.json
#	packages/babel-core/package.json
#	packages/babel-generator/package.json
#	packages/babel-helper-builder-react-jsx/package.json
#	packages/babel-helper-function-name/package.json
#	packages/babel-helper-optimise-call-expression/package.json
#	packages/babel-helper-replace-supers/package.json
#	packages/babel-helper-transform-fixture-test-runner/package.json
#	packages/babel-helpers/package.json
#	packages/babel-plugin-transform-class-properties/package.json
#	packages/babel-plugin-transform-es2015-block-scoping/package.json
#	packages/babel-plugin-transform-es2015-classes/package.json
#	packages/babel-plugin-transform-es2015-modules-commonjs/package.json
#	packages/babel-plugin-transform-es2015-modules-systemjs/package.json
#	packages/babel-plugin-transform-es2015-modules-umd/package.json
#	packages/babel-plugin-transform-es2015-parameters/package.json
#	packages/babel-plugin-transform-react-jsx/package.json
#	packages/babel-register/package.json
#	packages/babel-template/package.json
#	packages/babel-traverse/package.json
#	packages/babel/package.json
2017-02-14 12:46:23 +01:00
Logan Smyth
e1fee21529 Add charset so tests work with convert-source-map@>1.4 (#5302) 2017-02-13 14:37:41 -08:00
Ben Alpert
14d3c2e256 Avoid adding unnecessary closure for block scoping (#5246)
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.
2017-02-13 13:46:00 -08:00
Henry Zhu
9083bd6283 Merge branch 'master' into 7.0 2017-02-09 18:36:02 -05:00
Logan Smyth
b845f2b69d Re-enable the max-len ESLint rule. (#5265) 2017-02-04 11:07:15 -05:00
Sergey Rubanov
d0b42d4313 Update babel-core browserify fixture (#5164) 2017-01-20 10:29:44 +01:00
Jordan Jones
1742035a98 [7.0] Fixes #5108, browser.js and browser.js test removed (#5124)
* Fixes #5108, browser.js and browser.js test removed

* Moved api/node.js to index.js and adjusted associated file references
2017-01-19 22:43:11 -05:00
Sergey Rubanov
3a5ce620c8 [7.0] Deprecate babel-core/register.js (#5132)
* Deprecate babel-core/register.js

* add error when using `babel-core/register`
2017-01-19 22:22:45 -05:00
Brian Ng
8c35b320d3 Bump eslint-config-babel and fix lint (#5129) 2017-01-17 10:51:16 +01:00
Sergey Rubanov
292c3ca206 Refactor test packages to use ES modules instead of CJS (#5138) 2017-01-16 11:25:04 -05:00
Henry Zhu
672adba9a1 enable prefer const (#5113) 2017-01-14 09:48:52 -05:00
Logan Smyth
ce0c620a9f Merge pull request #4729 from rmacklin/add-resolvePlugin-and-resolvePreset
Add resolvePlugin and resolvePreset methods to babel-core API
2016-12-20 08:42:27 -08:00
Henry Zhu
cd041541b8 Fix bug + Generate test fixtures if no expected.js (#4858) 2016-11-17 17:53:46 -05:00
Moti Zilberman
6bc10b5573 Support ObjectExpression in static path evaluation (#4746) 2016-10-17 18:55:02 -04:00
Richard Macklin
4ea1007645 Remove unneeded tests
Previously these were testing the logic that is now encapsulated in
getPossiblePresetNames and tested in a unit test
2016-10-16 11:07:16 -07:00
Richard Macklin
e24f07dfda Extract resolvePreset method to babel-core public API
This encapsulates the logic for turning an acceptable preset name into
the absolute path for that preset. It can be used to preprocess a
presets list to map each preset to its absolute path, which is necessary
if `babel.transform` is going to be executed on a file outside the
directory subtree where the presets are installed.

This adds a getPossiblePresetNames helper encapsulating the logic for
what preset names we should try to resolve, and the resolvePreset method
just calls this helper and actually resolves them.
2016-10-16 11:06:47 -07:00
Richard Macklin
f4389a1886 Extract resolvePlugin method to babel-core public API
This encapsulates the logic for turning an acceptable plugin name into
the absolute path for that plugin. It can be used to preprocess a
plugins list to map each plugin to its absolute path, which is necessary
if `babel.transform` is going to be executed on a file outside the
directory subtree where the plugins are installed.

This adds a getPossiblePluginNames helper encapsulating the logic for
what plugin names we should try to resolve, and the resolvePlugin method
just calls this helper and actually resolves them.
2016-10-16 10:52:13 -07:00
Andrew Levine
9f8ab29213 Change usage of "suite"/"test" in unit-tests to "describe"/"it" (#4734)
Fixes #4733
2016-10-15 18:45:35 -04:00
Andrew Levine
c0038221d7 Run ESLint on test files, and fix lint errors in test files (#4732) 2016-10-15 18:27:48 -04:00
Moti Zilberman
76de1cc8a4 Update tests for changed error messages in Babylon (#4727)
Depends on babel/babylon#172.
2016-10-14 16:25:56 -04:00
Moti Zilberman
2827d660fc Make special case for class property initializers in shadow-functions (#4502) 2016-10-14 15:21:11 -04:00
Daniel Tschinder
1dca51f8ab Enable babel for tests (#4564)
* Enable babel for tests

This enables babel for tests by using a mocha compiler
It uses the babel config from package.json
Transformed OptionsManager test to es2015 to see if it works
Removed the 5s timeout from cli tests, as the default timeout is already 10s, this should probably fix the timouts on travis that we had in babylon
Also run the cli tests on travis, they were disabled if istanbul active, but istanbul is always active on travis so we were never running this tests.

* ignore scripts directory

* only register for tests

* Set only flag correctly
2016-10-12 10:56:50 +02:00
Kai Cataldo
27ee74ea14 Better error messaging when preset options are given without a corresponding preset (#4685) 2016-10-11 16:56:53 +02:00
Daniel Tschinder
5a8070a397 Forward bound shadowed function when hoisting identifiers (#4635)
This change ensures that when hoisting an identifier we do not hoist it up to
the first no shadowed function, but rather up to the bound shadowed function
2016-10-01 13:24:12 -04:00
Daniel Tschinder
46339463bd Resolve presets with named exports correctly (#4620) 2016-09-30 18:27:40 -04:00
Henry Zhu
b2eb5eca6f babel-core: add options for different parser/generator (#3561)
* babel-core: add options for different parser/generator

* test for experiemental plugins, other babylon options

* fix passing options into parser

* Fix when no code is provided

* fixup tests

* fix tests again

* use filename and fallback to cwd
2016-09-27 09:09:31 -04:00
Justin Ridgewell
c2ed9de7fb Flip default parameter template (#4515)
* Flip default parameter template

YMMV, I saved ~10b on a 2kb library. Not noticeable at the small scale, by why not do it anyway?

I've (unscientifically) found that flipping the default parameter conditional yields better gzip results. I think this is due to the slightly longer string it can now repeatedly match:

```js
// old
var param = arguments.length <= 0 || void 0 === arguments[0] ? null : arguments[0]
--------------------------------------------------------------^

// new
var param = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null
------------------------------------------------------------------------^
```

Though it's entirely likely gzip will also choose up to the index of the arguments if you many default parameters at different indexes.

* Update tests
2016-09-25 14:05:53 -07:00