89 Commits

Author SHA1 Message Date
Nicolò Ribaudo
2d989a983d
Run tests in a native Node.js ESM environment (#13966) 2021-12-03 15:32:58 +01:00
Nicolò Ribaudo
29de280006
Use Node.js interop when importing lib in test (#13995) 2021-11-29 21:48:34 +01:00
Nicolò Ribaudo
75996cb62b
Use full import specifier path in tests (#13938) 2021-11-24 11:43:18 +01:00
Huáng Jùnliàng
4eda1c8605
chore: bump eslint and its plugins (#13412) 2021-06-03 23:42:32 -04:00
Huáng Jùnliàng
6ee87eea49
[babel 8] fallback targets to "defaults, not ie 11" (#12989) 2021-03-23 20:17:16 +01:00
Nicolò Ribaudo
d04842a700
Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00
Nicolò Ribaudo
31ca15ef58 Support .mjs plugins/presets and async factories (#12266) 2021-02-21 17:08:30 +01:00
Brian Ng
fec4a132ad
Bump prettier@2.2.1 (#12633) 2021-01-14 14:10:47 -05:00
Nicolò Ribaudo
208acb1d6c
Use require.resolve instead of the resolve package (#12439) 2020-12-04 08:57:09 +01:00
Nicolò Ribaudo
1b90d90fcc Instantiate presets before plugins (#11689) 2020-10-14 19:59:02 +02:00
Vahagn Aharonian
b651a6f6ab Enable logical assignment by default in @babel/parser (#11860) (#11869) 2020-07-29 18:32:12 -04:00
coderaiser
cf425a0bde
feature: babel-core: add cloneInputAst (#10241)
Co-authored-by: coderaiser <coderaiser@cloudcmd.io>
2020-07-29 16:40:02 -04:00
Wojciech Maj
1dd94e813e
Replace non-inclusive "whitelist" and "blacklist" terms with "allowlist" etc. (#11758) 2020-06-29 15:39:38 -04:00
Bogdan Savluk
4108524856
Update prettier to v2 (#11579)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-07 22:21:33 +02:00
Abdul Ali
5b907e9bb7 [parser] enable dynamic import by default (#10843)
* [parser] enable dynamic import by default

* chore: add back babel-core api test
2020-01-10 02:28:52 +01:00
Tan Li Hau
f5ca0587d1 always throw when add missing helpers (#10208) 2019-07-12 12:53:55 -05:00
Kai Cataldo
806e133473 Export @babel/parser#tokTypes in @babel/core (#8986)
* Export @babel/parser in @babel/core

* Expose tokTypes instead of parser
2018-11-30 18:41:58 -08:00
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