1016 Commits

Author SHA1 Message Date
Logan Smyth
2058e0686e Add support for an InterpreterDirective AST node. 2018-05-21 18:19:58 -07:00
Logan Smyth
c0013264b7 Add tests for interpreter directive with retainLines and sourcemaps. 2018-05-21 18:08:32 -07:00
Logan Smyth
5fb3696955 Avoid flow errors now that we've renamed Babylon to babel-parser. 2018-05-21 18:06:17 -07:00
Logan Smyth
69cca412eb
Make the filename option, as exposed to the plugins, consistently relative to the working directory (#7956)
| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | 
| Patch: Bug Fix?          | Y
| Major: Breaking Change?  | N
| Minor: New Feature?      |
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

Currently the `opts.filename` value exposed to plugins is just whatever the user passed. While it _could_ be relative to the working directory, if Babel was passed an absolute URL, it'll be absolute.

This PR explicitly ensures the filename is a relative path based on the working directory. This also exposes an officially endorsed API for reading the working directory path.
2018-05-21 17:10:57 -07:00
Mike Nason
3bee37b14d fix typo in error message (#7995) 2018-05-21 12:18:09 -07:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00
Logan Smyth
8ff675ad69 Refactor CLI to use promises/async fns. 2018-05-14 23:07:50 -07:00
Logan Smyth
a192f8beb4 Limit node version to current LTS. 2018-05-14 21:54:16 -07:00
Henry Zhu
f03adbadf4 v7.0.0-beta.47 2018-05-14 17:15:44 -07:00
Logan Smyth
dca2631ef0
Merge pull request #7911 from loganfsmyth/config-babelrcroots
Allow 'babelrc' and 'babelrcRoots' in config files (but not .babelrc/extends)
2018-05-14 10:41:22 -07:00
Stian Håklev
e06cf20d2e Update babel/core README.md (#7913) [skip ci] 2018-05-14 10:25:53 -07:00
Logan Smyth
98f0808a22 Ensure the the config file isn't re-processed when users load a partial config and then pass it back to Babel. 2018-05-11 17:49:12 -07:00
Logan Smyth
bdcfb697a6 Use 'babelrc' and 'babelrcRoots' from config file, if not specified. 2018-05-11 17:49:11 -07:00
Logan Smyth
0341d299c8 Validate different file types with different rules. 2018-05-11 16:51:43 -07:00
Logan Smyth
1a7765712e Validate the file before loading chain. 2018-05-11 15:29:28 -07:00
Brian Ng
02c4a28608
Fix typescript decorator test (#7904) 2018-05-10 17:31:38 -05:00
Carlos Villavicencio
95fc38cecf Bumped lodash version (#7895)
* Bumped lodash version

* Fixed typo

* Fixed typos

* Revert "Fixed typo"

This reverts commit 06cfe9d4edba0b99257cbffc6dc08ae2f3460d78.

* Revert "Fixed typos"

This reverts commit ec3975c7392df9a0a42682ee4f32eadd2615c69c.

* Fixed json typos
2018-05-09 15:47:52 -07:00
Logan Smyth
a3e622ad15 Fix inputSourcemapMerge when no JS content is output. 2018-05-01 20:31:29 -07:00
Hana Shiro
494a56df5f Unify main property in package.json [skip ci] (#7825) 2018-05-01 09:15:02 -07:00
Logan Smyth
acf509bab5
Upgrade Babel to self-host with beta.46 (#7784) 2018-04-27 15:04:37 -07:00
Renée Kooi
1a6855eff2 Fix default sourceFileName. (#7764)
* Fix default sourceFileName.

This deals with a problem mentioned in [babel/babelify#255][0]. I'm not
super sure about the implications, but it seems this may have been a
regression from Babel 6.

In babel@6, the default `sourceFileName` was the basename of the input
file:

```js
require('babel-core').transform('var a = 10', {
  filename: __filename,
  sourceMaps: true
}).map
// { version: 3,
//   sources: [ 'index.js' ],
//   names: [ 'a' ],
//   mappings: 'AAAA,IAAIA,IAAI,EAAR',
//   file: 'index.js',
//   sourcesContent: [ 'var a = 10' ] } }
```

Currently however, the full file path is used:

```js
require('@babel/core').transformSync('var a = 10', {
  filename: __filename,
  sourceMaps: true
}).map
// { version: 3,
//   sources: [ '/home/goto-bus-stop/Code/babel/repro-babelify-255/index.js' ],
//   names: [ 'a' ],
//   mappings: 'AAAA,IAAIA,IAAI,EAAR',
//   file: '/home/goto-bus-stop/Code/babel/repro-babelify-255/index.js',
//   sourcesContent: [ 'var a = 10' ] } }
```

This patch adds the `path.basename()` call that [Babel 6 used][1] to
@babel/core's default options, so it's the same as back then.

```js
require('../babel/packages/babel-core').transform('var a = 10', {
  filename: __filename,
  sourceMaps: true
}).map
// { version: 3,
//   sources: [ 'index.js' ],
//   names: [ 'a' ],
//   mappings: 'AAAA,IAAIA,IAAI,EAAR',
//   sourcesContent: [ 'var a = 10' ] }
```

This is the desired behaviour for browserify at least, as it expects
relative paths in the source maps and rebases them to a root directory
when generating the final source map.

[0]: https://github.com/babel/babelify/pull/255
[1]: 6689d2d23c/packages/babel-core/src/transformation/file/index.js (L163-L172)

* Use cwd-relative path for sourceFileName.

* Revert sourceMap `file` property change.

* fixup! Revert sourceMap `file` property change.

* Fix whitespace change from merge conflict

* Revert to using basename in source map outputs.
2018-04-27 13:28:23 -07:00
Logan Smyth
cfb386ff03 Reimplement input sourcemap merging. 2018-04-25 12:02:05 -07:00
Logan Smyth
9e7fe0ab49 Add type definitions for source-map library. 2018-04-25 12:02:05 -07:00
Logan Smyth
e31e907d5f Split sourcemap merging logic into its own file. 2018-04-25 12:02:05 -07:00
Logan Smyth
4da4728bf5 Add an example of an extremely bad sourcemap merge. 2018-04-25 12:02:05 -07:00
Justin Ridgewell
2afe9404fe
Use Object Spread Syntax (#7777)
* Use Object Spread Syntax

* Nits
2018-04-23 21:44:27 -04:00
Logan Smyth
3a2aa9b862 v7.0.0-beta.46 2018-04-22 21:29:42 -07:00
Logan Smyth
c8b57f777a
Ensure that the internal plugin load does not read the user's config. (#7783) 2018-04-22 20:32:52 -07:00
Henry Zhu
b414387bb1 v7.0.0-beta.45 2018-04-22 21:55:16 -04:00
Logan Smyth
d6dcbdad48
Merge pull request #7358 from loganfsmyth/babelrc-resolution-changes
Allow more flexible file-based configuration while preventing .babelrcs from breaking things
2018-04-22 13:28:05 -07:00
Logan Smyth
8606b76438 Split babelrc option into babelrcRoots. 2018-04-22 13:00:28 -07:00
Justin Ridgewell
f8ab9466d3
Move subclass inheritance to end (#7772)
We were using `Object.create` to setup the prototype chain at the start of the class definition, which lead to #7771.

I was a bit worried about a speed hit, but it seems everyone optimizes the two patterns the same way.
https://jsbench.github.io/#f9fca52407643d96458a35763b201215

Fixes #7771.
2018-04-21 17:31:44 -04:00
Logan Smyth
f7c26bf2bf Add some docs for config searching. 2018-04-20 17:00:54 -07:00
Logan Smyth
a67eb25547 Only search for .babelrc files in the 'root' package by default. 2018-04-20 17:00:53 -07:00
Logan Smyth
485e37fcb0 Support a babel.config.fs file in a 'root' directory. 2018-04-20 17:00:53 -07:00
Logan Smyth
f013dab5fb Restrict .babelrc resolution to within a given package. 2018-04-20 17:00:53 -07:00
Brian Ng
0cd868a5f2
fixup tests 2018-04-19 09:17:33 -05:00
Logan Smyth
42244123e1 Update the docs to correctly reflect default value changed in #7436. [skip ci] 2018-04-18 23:33:34 -07:00
Nicolò Ribaudo
341bdab90c Update decorators parsing (#7719)
* Update decorators parsing

This commit introduces three changes:
1) Class properties can be decorated
2) Decorators can contain arbitrary expressions, using @(...)
3) The Decorator node type has a new property, "arguments". This
    makes it possible do distinguish @dec() and @(dec()), which have
    different behaviors because @(dec()) is equivalent to @(dec())().

* Rename Decorator#expression to Decorator#callee

* Add test for @dec()()
2018-04-17 16:22:03 -05:00
Nicolò Ribaudo
a62cfe9045 Disallow arguments in class properties 2018-04-12 22:41:28 +02:00
Deven Bansod
95894397eb Migrate babel-cli and babel-generator tests to use jest-expect (#7549) 2018-04-11 13:12:56 -05:00
Markus Török
6597a472b3 Add "use strict" directive (#7411)
* #7349
- Add "use strict" directive to transformed class bodies

* Update tests (#7349)

* Add test for program with use strict directive (#7349)

* Update tests (#7349)

* Update source mapping (#7349)

* Add test for parent blockStatement with use strict directive (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Add test for constructor-only class (#7349)

* Constructor only classes are strict, too

But constructor only that use non-simple parameters must use a strict function wrapper.

* Fix test

* Wrapper not needed if class is already strict

* Revert change to lerna.json
2018-04-10 17:33:38 -04:00
Justin Ridgewell
450a1678f2
Use getProto and setProto helpers (#7675)
Depends on #7674.
2018-04-06 02:54:08 +01:00
Henry Zhu
a6df92f245 v7.0.0-beta.44 2018-04-02 18:19:30 -04:00
Henry Zhu
bdfeeb38c6 v7.0.0-beta.43 2018-04-02 12:47:55 -04:00
Daniel Tschinder
f0d681a238 Remove obsolete max-len eslint rule and reformat some stuff to fit (#7602) 2018-03-20 08:51:47 -05:00
Henry Zhu
d260bfaec4 v7.0.0-beta.42 2018-03-15 16:50:03 -04:00
Logan Smyth
017d0e7078
Ensure that the backward-compat logic for plugin-utils copies over the version API properly. (#7580) 2018-03-15 11:45:53 -07:00
Henry Zhu
270ea17fed v7.0.0-beta.41 2018-03-14 12:25:26 -04:00
Daniel Tschinder
1d69cd41ca Fix import of type ConfigItem (#7561)
It is also exported as type
2018-03-13 13:31:32 -05:00