336 Commits

Author SHA1 Message Date
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
Kay J
4dcc981d6a Removed unnecessary 'return' statements. (#3653)
* Removed unnecessary 'return' statements.

Returning a 'Promise' value in 'promise.then()' makes promise chains.
Used memory and promises are not garbage collected
until finishing 'helpers.asyncToGenerator'.

* Update test
2016-09-25 13:57:59 -07:00
Henry Zhu
c07919bc9b Add support for preset organization shortcuts (#4542)
* add support for @org shortcats, fixes #4362

* add shortcut test

* fixes
2016-09-21 16:44:13 -04:00
Moti Zilberman
e64d86c1eb If loading a preset fails, show its name/path (#4506) (#4517) 2016-09-17 23:01:08 -04:00
Daniel Tschinder
10cd6519d8 Fix class inheritance in IE <=10 (T3041) (#3527)
* Fix class inheritance in IE9 & IE10 (T3041)

Internet Explorer 9&10 do not support __proto__ at all, don't have
Object.setPrototypeOf(), but have Object.getPrototypeOf().

Because of this setting the prototype is not possible, which makes the
babelHelpers.inherits() function to set __proto__ although not supported.

Afterwards Object.getPrototypeOf() is used, but this one is not
respecting the "custom" property __proto__ that we set.

The solution is to check for __proto__ first and afterwards fallback to
Object.getPrototypeOf().

* Do the same logic in babel-helper-replace-supers

* Fix tests

* Extract creation of prototype nodes to small helper
2016-08-23 15:08:44 -04:00
Sebastian McKenzie
07b3dc18a0 Add wrapPluginVisitorMethod option to allow introspection and metrics tracking of plugins (#3659) 2016-08-20 10:36:52 -04:00
Sebastian McKenzie
4a19661346 Generate names field for identifiers to get correct names mappings (#3658) 2016-08-16 13:43:55 -04:00
Jordan Scales
ca27cf135d Revert "Merge pull request #3641 from babel/guy-fieri" (#3646)
This reverts commit 033681af8941d9678961f985c13e500c3c70f337, reversing
changes made to a2d66c0fc8ee58e82be3efd59173803e66dee3e0.

I brought you into this world, and I can take you out.
2016-08-15 11:35:39 -04:00
James Kyle
10f4546fef Remove unnecessary import 2016-08-08 17:34:01 -07:00
James Kyle
f36d07d303 Fixes from PR comments 2016-08-08 17:32:58 -07:00
James Talmage
0a9cbe6e83 git commit add test for package.json config 2016-07-07 16:58:22 -04:00
James Talmage
8e84196eb8 add tests for env options 2016-07-07 16:36:34 -04:00
James Talmage
62ad67e5d9 add tests for build-config-chain 2016-07-03 23:58:44 -04:00
Logan Smyth
231f27f170 Fix non-unique 'ref' binding name - fixes T7468 2016-06-28 19:16:44 -07:00
Jesse McCarthy
ff044bbb0f Use more ideal mocha hooks (#3446)
* setup() instead of manual before().
* suiteTeardown() instead of afterEach().
2016-05-19 08:26:59 -04:00
Jordan Klassen
dc1f40540d Upgrade to lodash 4 (#3315)
* Upgrade to lodash 4

* Fix incorrect require in babel-runtime/scripts

* Replace cloneDeep with cloneDeepWith where applicable
2016-05-13 17:15:14 -04:00
Logan Smyth
81e6d4147d Map the end of block statement nodes to the end of their original location - fixes T7258 2016-04-11 01:54:41 -07:00
Logan Smyth
76bb1dffaa Track sourcemap location on a stack - fixes T7255 2016-04-11 01:54:40 -07:00
Logan Smyth
c3ccddaaaf Revert "Merge pull request #3433 from loganfsmyth/bail-out-rename"
This reverts commit 2d0a007d14e519fe60a849dd17068a0f3df79a28, reversing
changes made to e4d6d420415a0c290a321fb6c18ba5f19675b5c1.
2016-04-08 09:09:48 -07:00
Logan Smyth
3af8ec16e9 Handle input source mappings with no source location - fixes T7151 2016-04-07 09:34:45 -07:00
Logan Smyth
078f6c0ed3 Only attempt to rename export declarations, not expressions - fixes T7215 2016-03-16 23:26:52 -07:00
Amjad Masad
f6ff14624f localize side-effectful test 2016-03-16 18:13:40 -07:00
Amjad Masad
fd7b1c3386 don't rely on scope to get the type alias 2016-03-10 12:13:05 -08:00
Logan Smyth
af4575c43e Expand the regression tests for T2765. 2016-03-08 08:15:42 -08:00
Amjad Masad
2f654650bb Merge pull request #3407 from babel/async-tests
Async context tests
2016-03-08 02:00:40 -08:00