521 Commits

Author SHA1 Message Date
Logan Smyth
9bd4b46fd6
Merge pull request #8198 from loganfsmyth/sourcemap-loading
Prefer explicit object maps, and properly load relative maps.
2018-07-04 15:39:42 -07:00
Logan Smyth
532c25c8db Ensure that file-path sourcemaps load relative to the file containing the comment. 2018-06-18 22:06:08 -07:00
Logan Smyth
3c90baaf6c Prefer object sourcemaps over file-inlined sourcemaps. 2018-06-18 21:49:23 -07:00
Logan Smyth
add5f8d0fe Allow @foo/babel-plugin as an unexpanded plugin name, and @foo as a shorthand for it. 2018-06-18 21:36:02 -07:00
Brian Ng
5895277b32 Bump prettier to v1.13.2 2018-06-03 07:54:39 -05:00
Brian Ng
f699f1bbbf
flow@0.73.0 (#8032) 2018-05-25 16:53:23 -05:00
Logan Smyth
9c707f9670 Update docs 2018-05-24 20:57:44 -07:00
Logan Smyth
53e4d74ebe
Treat all filenames as absolute paths. (#8044) 2018-05-24 20:56:19 -07:00
Logan Smyth
0bc3027554 Add a promise version of each of Babel's transform functions. 2018-05-23 21:18:17 -07:00
Logan Smyth
6f3093b557 Track the sync and async implementations in the same files. 2018-05-23 21:18:15 -07:00
Logan Smyth
6b91d6434d Add a try/catch on inline data-uri sourcemaps too, and add debug logging. 2018-05-22 23:38:16 -07:00
Michael Lavina
18796173ab feat(sourcemap): parse external source maps when normalizing (#7980) 2018-05-22 23:29:10 -07:00
Logan Smyth
eb3334a14e
Merge pull request #7955 from loganfsmyth/typescript-filename-required
Verify that files are .ts/.tsx before treating as Typescript files.
2018-05-22 22:41:39 -07:00
Logan Smyth
ca1c98b255 Allow .overrides and .env inside presets. 2018-05-21 18:23:07 -07:00
Logan Smyth
0963dbddea Rely on Babylon for interpreter directive parsing, instead of babel/core. 2018-05-21 18:19:59 -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
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
Logan Smyth
a3e622ad15 Fix inputSourcemapMerge when no JS content is output. 2018-05-01 20:31:29 -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
Justin Ridgewell
2afe9404fe
Use Object Spread Syntax (#7777)
* Use Object Spread Syntax

* Nits
2018-04-23 21:44:27 -04: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
Logan Smyth
8606b76438 Split babelrc option into babelrcRoots. 2018-04-22 13:00:28 -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
Daniel Tschinder
f0d681a238 Remove obsolete max-len eslint rule and reformat some stuff to fit (#7602) 2018-03-20 08:51:47 -05: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
Daniel Tschinder
1d69cd41ca Fix import of type ConfigItem (#7561)
It is also exported as type
2018-03-13 13:31:32 -05:00
Logan Smyth
b5e6536f26
Remove the sourceMapTarget option from core and implement it in babel-cli. (#7500) 2018-03-09 14:14:25 -08:00
Logan Smyth
74ab2798e2 Tweaks around PR comments. 2018-03-07 18:02:38 -08:00
Logan Smyth
fef5c7e523 Expose the partial Babel config for people to load and mutate. 2018-03-07 16:33:25 -08:00
Logan Smyth
15a80f0df8
Merge pull request #7490 from loganfsmyth/sourcetype-helpful-errors
Give helpful errors if the wrong sourceType is detected
2018-03-04 15:03:49 -08:00
Logan Smyth
a4795408b4
Allow plugins to assert that a specific babel version has loaded the plugin. (#7450) 2018-03-04 14:36:54 -08:00
Logan Smyth
5f6e3122a0 Give users helpful feedback if they are detected as using the wrong sourceType. 2018-03-04 14:12:37 -08:00
Logan Smyth
7cc00cce0d Require output fixture extension to match sourceType output. 2018-03-04 13:31:33 -08:00
Logan Smyth
2c3eb3096f Expand the '.env()' API call with more flexibility. 2018-02-27 18:48:24 -08:00
Logan Smyth
148e6dfc26 Centralize the plugin/configuration API object. 2018-02-27 18:48:24 -08:00
Logan Smyth
b19b7fd2cf Fix PR comments. 2018-02-27 17:46:17 -08:00
Logan Smyth
8e3e6e0a88 Require AST output to be opt-in, rather than opt-out. 2018-02-26 18:44:59 -08:00
Logan Smyth
d4a8c7672c Avoid using lodash during config loading, for require() performance. 2018-02-26 18:44:58 -08:00
Logan Smyth
600106b9cb Lazy-initialize external helper template. 2018-02-26 18:44:57 -08:00