72 Commits

Author SHA1 Message Date
Nicolò Ribaudo
24c4901ff5
Remove Babylon plugins for features already merged to the ECMAScript spec (#8448)
These are now enabled by default:
- objectRestSpread (2018)
- asyncGenerators (2018)
- optionalCatchBInding (2019)
- jsonStrings (2019)

TODO (after this commit):
- [ ] Deprecate the `@babel/plugin-syntax-*` packages.
- [ ] Deprecate the `@babel/plugin-proposal-*` packages.
- [ ] Create the `@babel/plugin-transform-*` packages.
2018-11-05 23:48:06 +01:00
Thiago Arrais
6f3a800677 Do not mutate ast (#8342)
This clones the given ast prior to working on it to avoid mutating the AST given to `transformFromAST`.
2018-07-23 22:20:55 -04:00
Logan Smyth
6d177ba4c5 Remove micromatch and use a simple pattern matching utility. 2018-07-16 09:57:14 -07:00
Henry Zhu
10910a10f5
Remove yearly presets from repo, inline in standalone (#8274)
These were already deprecated in v6, just didn't remove the folders?
2018-07-09 14:23:25 -04: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
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
a67eb25547 Only search for .babelrc files in the 'root' package by default. 2018-04-20 17:00:53 -07:00
Daniel Tschinder
3a7881379a jest: ToEqual -> toBe 2018-03-10 11:48:09 +01:00
Deven Bansod
f3f0197890 Migrate babel-core tests to use jest-expect (#7513)
* Used codemods at: https://gist.github.com/devenbansod/03c5cff857661e076cbec72fcb2e7eb3 along with some manual intervention and review
2018-03-10 11:40:28 +01:00
Daniel Tschinder
3e95830646
Migrate to jest (#7455) 2018-03-03 10:58:19 +01:00
Logan Smyth
ddd40bf5c7
Rely entirely on sourceType for module vs script differentiation. (#7417) 2018-02-27 18:11:13 -08:00
Logan Smyth
8e3e6e0a88 Require AST output to be opt-in, rather than opt-out. 2018-02-26 18:44:59 -08:00
Maaz Syed Adeeb
17b37b5013 Handling babylon parsing errors in a better way (#6961)
* Handling babylon parsing errors in a better way

* Better error messages + Helpful URLs

* Replaced message from babylon completely

* Add importMeta plugin to the map
2017-12-18 15:49:34 -05:00
Logan Smyth
189c56628a Replace repeated plugins/preset in top-level config instead of running both. 2017-11-25 18:47:13 -08:00
Nicolas Marien
cf62908bbd Keep user options intact in transformFile (#6890)
* Preserve user options in transformFile

* Improve tests for transformFile user opts handling
2017-11-25 10:13:56 -08:00
Logan Smyth
db28c18458 Disallow nested '.env' blocks since they are useless. 2017-11-24 17:45:27 -08:00
Logan Smyth
64abf75d1f Perform option validation up front to avoid repeating assertions. 2017-10-25 15:55:58 -07:00
Logan Smyth
3673fbbd52 Refactor config item processing. 2017-10-25 15:55:58 -07:00
Henry Zhu
691f90a774 Scoped: change test imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Logan Smyth
35312dc3d2 Track options on the plugin instance to avoid array pair usage. 2017-10-02 14:15:40 -07:00
Logan Smyth
f20f8b164f Remove unused module metadata collection. 2017-09-29 15:17:11 -07:00
Logan Smyth
3bac67b4b9 Remove the resolveModuleSource options. 2017-09-29 15:17:11 -07:00
Logan Smyth
8339e036bf Remove babel.analyse and surrounding helpers. 2017-09-29 15:17:11 -07:00
Logan Smyth
2b88e079ef Only transform this/use strict if a module. 2017-09-20 10:19:35 -07:00
Mateusz Burzyński
4519f95a29 Fixed buildExternalHelpers tool for var and module output types (#6260) 2017-09-19 14:44:40 -04:00
Daniel Tschinder
b3372a572d Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
Logan Smyth
2b86d353d6 Restrict Babel's plugins/presets to a single target. (#5547) 2017-04-17 11:45:49 -07:00
Logan Smyth
d7e10a3adc Misc refactoring of OptionManager. 2017-04-10 10:01:01 -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
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
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
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
Brian Ng
8a82cc060a Run new lint rules (#5413) 2017-03-04 10:46:01 -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
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
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
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
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