58 Commits

Author SHA1 Message Date
Nicolò Ribaudo
3a85ddfb1b
Bring back deferred require() calls in core and cli (#14028) 2021-12-06 21:33:33 +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
381277ae35
Add ESLint 8 support to @babel/eslint-parser (#13782)
* Add ESLint 8 support to `@babel/eslint-parser`

* Only read eslint version dynamically during dev

* Fix tests

* Update ESLint

* Use ESLint 8 stable

* Review

* Check

* Fix babel config
2021-10-28 16:41:55 -04:00
Nicolò Ribaudo
6880898510
[babel 8] Remove make-dir polyfill for fs.mkdirSync (#13828)
* [babel 8] Remove `make-dir` polyfill for `fs.makeDitSync`

* `yarn`

* fix

* Inject polyfills in jest tests when needed
2021-10-11 07:01:30 +02:00
Huáng Jùnliàng
d2076a531f
Store token type as number (#13768)
* refactor: abstract token metadata access

* refactor: move token-specific update context logic

* refactor: centralize token definitions

* refactor: abstract token type creation

* refactor: use number as token storage

* build: replace tt.* as number

* fix flow errors

* fix: build on Node 12

* Update packages/babel-parser/src/tokenizer/types.js

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* refactor: rename token types exports to tt

* update unit test

* test: update Babel 8 test fixtures

* fix: centralize obsolete token type updateContext

* fix flow errors

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-09-17 09:36:11 -04:00
Huáng Jùnliàng
614b486780
Use named imports for babel types (#13685)
* migrate to named babel types imports

* perf: transform babel types import to destructuring

* fix merge errors

* apply plugin to itself
2021-08-18 10:28:40 -04:00
Huáng Jùnliàng
03e8476b27
Generator performance (#13593)
* bench: setup benchmarks

* add charcodes

* perf: use string as buffer backend

baseline 256 empty statements: 3_718 ops/sec ±18.65% (0.269ms)
baseline 512 empty statements: 2_070 ops/sec ±0.96% (0.483ms)
baseline 1024 empty statements: 1_012 ops/sec ±1.76% (0.988ms)
baseline 2048 empty statements: 510 ops/sec ±1.53% (1.96ms)
current 256 empty statements: 3_965 ops/sec ±21.14% (0.252ms)
current 512 empty statements: 2_219 ops/sec ±1.29% (0.451ms)
current 1024 empty statements: 1_089 ops/sec ±1.53% (0.918ms)
current 2048 empty statements: 548 ops/sec ±1.87% (1.824ms)

* perf: add endsWithCharAndNewline

baseline 256 1-length identifiers: 1_947 ops/sec ±25.11% (0.514ms)
baseline 512 1-length identifiers: 1_115 ops/sec ±0.89% (0.897ms)
baseline 1024 1-length identifiers: 537 ops/sec ±1.71% (1.862ms)
baseline 2048 1-length identifiers: 273 ops/sec ±0.57% (3.669ms)
current 256 1-length identifiers: 2_178 ops/sec ±27.17% (0.459ms)
current 512 1-length identifiers: 1_250 ops/sec ±1.19% (0.8ms)
current 1024 1-length identifiers: 622 ops/sec ±0.71% (1.608ms)
current 2048 1-length identifiers: 308 ops/sec ±1.35% (3.251ms)

* perf: avoid one byte string compare

* perf: avoid scaning word for /

* perf: hoist babel type methods

baseline 256 25-length identifiers: 1_869 ops/sec ±29.4% (0.535ms)
baseline 512 25-length identifiers: 1_092 ops/sec ±1.62% (0.916ms)
baseline 1024 25-length identifiers: 537 ops/sec ±1.29% (1.862ms)
baseline 2048 25-length identifiers: 264 ops/sec ±2% (3.793ms)
current 256 25-length identifiers: 2_462 ops/sec ±23.38% (0.406ms)
current 512 25-length identifiers: 1_401 ops/sec ±0.73% (0.714ms)
current 1024 25-length identifiers: 671 ops/sec ±1.55% (1.491ms)
current 2048 25-length identifiers: 332 ops/sec ±1.44% (3.014ms)

* perf: hoist parens methods

baseline 256 1-length identifiers: 2_678 ops/sec ±24.96% (0.373ms)
baseline 512 1-length identifiers: 1_472 ops/sec ±2.33% (0.68ms)
baseline 1024 1-length identifiers: 737 ops/sec ±1.74% (1.357ms)
baseline 2048 1-length identifiers: 371 ops/sec ±0.79% (2.695ms)
current 256 1-length identifiers: 2_633 ops/sec ±32.44% (0.38ms)
current 512 1-length identifiers: 1_676 ops/sec ±1.49% (0.597ms)
current 1024 1-length identifiers: 803 ops/sec ±1.95% (1.246ms)
current 2048 1-length identifiers: 385 ops/sec ±2.22% (2.596ms)

* cleanup unused benchcase

* Update packages/babel-generator/src/buffer.ts

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* cleanup benchmarks

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-07-22 23:01:48 -04:00
Nicolò Ribaudo
9440318309
Update Rollup plugins (#13265) 2021-05-06 08:53:30 +02:00
Nicolò Ribaudo
41c02246fb
Update @babel/* packages (#13231) 2021-04-30 11:07:16 -04:00
Nicolò Ribaudo
6d89daf064
Align regenerator-transform import with native ESM (#13086)
* Align `regenerator-transform` import with native ESM

* Add `regenerator` test to `@babel/standalone`
2021-04-07 17:25:46 +02:00
Huáng Jùnliàng
3e174e9cbd
perf: lazy load preset-env plugins (#13076) 2021-03-30 21:43:41 +02:00
Nicolò Ribaudo
4beca3999e
Fix importing polyfill plugins in the Rollup bundle (#13017) 2021-03-22 14:48:48 +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
d9ebfab07f
[internal] Use the Node.js behavior for default imports (#12795) 2021-03-04 13:55:15 +01:00
Huáng Jùnliàng
bfd30b9445
chore: do not provide polyfills on bundling @babel/standalone (#12909)
* chore: do not provide polyfills on bundling @babel/standalone

* review from Nicolò

* chore: update @babel/helper-define-polyfill-provider
2021-02-26 17:10:10 -05:00
Nicolò Ribaudo
039eb2710d
Update all the @babel/* dependencies (#12897) 2021-02-25 02:46:56 +01:00
Huáng Jùnliàng
ba4ac7d587
chore: bump semver to 7.0.0 (#12015)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-02-21 23:56:43 +01:00
Huáng Jùnliàng
4f92f8c11c
fix: use semver gte comparison on polyfill version tester (#12783) 2021-02-10 22:54:50 -05:00
Nicolò Ribaudo
e735266dee
Avoid importing .json files (#12759)
* Avoid importing `.json` files

* Use ESold in babel.config.json

* Use `import/extensions` eslint plugin
2021-02-05 23:34:36 +01:00
Nicolò Ribaudo
2811b535d6
Add yarn-plugin-conditions to update Babel 8 dependencies (#12659)
* Add `yarn-plugin-conditions` to update Babel 8 dependencies

https://github.com/nicolo-ribaudo/yarn-plugin-conditions

* Update .gitattributes
2021-01-22 10:45:03 +01:00
Huáng Jùnliàng
d28c1e52d0
Enable PnP linker on CI build job (#12011)
* chore: use pnp when building babel artifacts

* chore: refine ci config

* fix: match any n_m as unambiguous

The pnp module path starts from global cache path, which does not
match **/n_m

* fix: remove dedupe option and abort rollup on unexpected warning messages

* chore: suppress Circular_Dependency warning

* fix build error

* replace make bootstrap-only by yarn install
2020-12-18 19:00:43 -05:00
Nicolò Ribaudo
98aa72ca74
Use native Node.js functions when available (#12458) 2020-12-09 00:03:47 +01:00
Nicolò Ribaudo
b422c7f0ef
[babel 8] Disallow sequence expressions in JSX expression containers (#12447)
* jsx: fix sequence expression at JSXAttributeValue (#8787)

* jsx: fix sequence expression at JSXAttributeValue

* Change logic for detecting unparenthesized expressions

* use parseMaybeAssign instead of custom error handling

Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* I'm not good at booleans

* Format

* Throw a recoverable error

Co-authored-by: Bruno Macabeus <macabeus@users.noreply.github.com>
Co-authored-by: Daniel Tschinder <daniel@tschinder.de>
2020-12-08 10:15:03 +01:00
Nicolò Ribaudo
c139d1602b
Prepare codebase for inline Babel 8 breaking changes (#12440) 2020-12-04 21:30:40 +01:00
Nicolò Ribaudo
208acb1d6c
Use require.resolve instead of the resolve package (#12439) 2020-12-04 08:57:09 +01:00
Nicolò Ribaudo
6a0e909c13
Don't compile import() in development (#12288) 2020-11-18 16:02:02 +01:00
Nicolò Ribaudo
f80478c06d Prepare repository for gradual flow->ts migration (#12317)
Co-authored-by: Bogdan Savluk <savluk.bogdan@gmail.com>
2020-11-09 23:17:24 +01:00
Huáng Jùnliàng
ea2892fefc
add declare to class properties type annotations (#12257)
* add declare to class properties type annotations

* chore: use preset-flow
2020-10-27 10:05:01 -04:00
Huáng Jùnliàng
f2da186714
refactor: add @babel/helper-validator-option (#12006)
* refactor: add @babel/helper-validator-option

* refactor: simplify validateTopLevelOptions

* perf: the recursive version is not practically fast

* Update packages/babel-helper-validator-option/README.md

Co-authored-by: Brian Ng <bng412@gmail.com>

* Update packages/babel-helper-validator-option/src/validator.js

* fix: incorrect type annotation

* refactor: use babel/helper-option-validator in babel/compat-data

* chore: fix flow types error

* Address review comments

* address review comments

Co-authored-by: Brian Ng <bng412@gmail.com>
2020-09-24 16:23:35 -04:00
Huáng Jùnliàng
028a051c2b
Move legacy node version tests to GitHub actions (#11952)
* chore: run node 6 and 8 test on GitHub actions

* fix: apply dynamicImportUrlToPath polyfill on publish

* Apply hacks unconditionally

* try fix highlight issues

* address review comments

* chore: add test-legacy build env

* Update .travis.yml [skip ci]

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-08-14 14:20:06 -04:00
Huáng Jùnliàng
ad60153a98
Update @babel/* deps (#11899)
* chore: remove extra install step for eslint packages

* chore: update babel deps
2020-07-31 20:35:19 -04:00
Bogdan Savluk
32e7bb4027
fix build config to work the same when running on windows (#11688) 2020-07-30 14:11:58 -04:00
Huáng Jùnliàng
6373eb5d82
chore: use modules: "auto" (#11879)
* chore: use modules: “auto”

* address review comments
2020-07-28 09:41:35 -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
Huáng Jùnliàng
0aa5a47196
chore: remove included proposal plugins (#11433) 2020-04-16 21:14:46 +02:00
Huáng Jùnliàng
e39b508030
Add @babel/helper-validator-identifier (#11289)
* refactor: replace esutils.keywords.isIdentifierNameES6 by helper-validator-identifier

* refactor: replace esutils isReservedWordES6 by isKeyword || isReservedWord

* address review comments

* chore: specify both “main” and “exports”

* build helper-validator-identifier before babel-types
2020-03-20 12:23:14 +01:00
Nicolò Ribaudo
114f6726a7
Pass URLs to import() rather than paths (#11193)
* Pass URLs to import() rather than paths

* Make tests pass

* (╯°□°)╯︵ ┻━┻

* (╯°□°)╯︵ ┻━┻           (╯°□°)╯︵ ┻━┻             (╯°□°)╯︵ ┻━┻
2020-03-03 19:54:01 +01:00
Huáng Jùnliàng
0b3dea8f54
Turn on no-fallthrough rule (#11093)
* chore: turn on no-fallthrough

* chore: fix no-fallthrough errors
2020-02-07 22:05:19 +01:00
Nicolò Ribaudo
755ec192e2
Archive @babel/preset-env-standalone (#10993)
* Move @babel/preset-env-standalone to babel-archive

babel/babel-archive@a1fadd2d77

* Move tests to @babel/standalone

* Remove references in build scripts

* Update lockfile

* Delete duplicated test file.

It's already in babel-standalone/test/babel.js
2020-02-06 01:03:36 +01:00
Nicolò Ribaudo
ae06baf22f
Add support for babel.config.mjs and .babelrc.mjs (#10903)
* Add support for babel.config.mjs and .babelrc.mjs

* Use path.extname
2020-01-10 23:14:29 +01:00
Nicolò Ribaudo
282f81bd67
Prepare @babel/core for asynchronicity (#10507)
* Prepare @babel/core for asynchronicity

* Include regenerator-runtime in standalone build

* Fix rollup build
2020-01-10 22:44:13 +01:00
Nicolò Ribaudo
04354d1556
Extract targets parser and compat data from preset-env (#10899)
* Extract targets parser and compat data from preset-env

* Review by Jùnliàng

* isItemRequired -> targetsSupported

* Export isRequired
2020-01-10 03:15:20 +01:00
Huáng Jùnliàng
a0bed42aec
Bundle standalone using rollup (#10779)
* chore: bundle babel-standalone via rollup

Co-authored-by: Daniel Tschinder <daniel.tschinder@researchgate.net>

* chore: build babel-preset-env-standalone via Rollup

# Conflicts:
#	yarn.lock

* chore: add babelEnvName

* chore: farewell webpack

* chore: add terser minification

* chore: dedupe some popular dependencies

* chore: remove unused devDependencies

* chore: move plugin-babel-source to scripts/

* make prettier happy

* fix: rewrite available-plugins into esm

* chore: add extra unambiguous sources when env is rollup/standalone
2019-12-04 23:09:52 -05:00
Huáng Jùnliàng
683adcbb70 Reduce standalone build size (#10668)
* infra: build standalone against src

* infra: add absoluteRuntime

# Conflicts:
#	babel.config.js

* chore: remove `process.env` replace

* add $ to signify exact match

credits to Nicolò
2019-11-21 14:31:38 +01:00
Kai Cataldo
a6d134804a Unify build step for ESLint packages (#10723) 2019-11-16 10:15:15 +01:00
Huáng Jùnliàng
5bb4ee73da chore: use loose mode of transform (#10718) 2019-11-15 10:48:37 -06:00
Huáng Jùnliàng
ce070ce422 bump @babel/* dev dependencies (#10648)
* bump @babel/* dev dependencies

* chore: align version to @babel/runtime

* chore: bump to 7.7.1

* chore: bump to 7.7.2
2019-11-13 00:05:38 +01:00
Huáng Jùnliàng
5f1970433d
chore: only apply lazy cjs module transform on cli and core (#10443) 2019-09-27 16:53:27 -04:00
Nicolò Ribaudo
eaa1474541
Enable optional chaining and nullish coalescing plugins (#10494)
* Add optional chaining plugin

* Nullish coalescing
2019-09-24 23:11:56 +02:00
Brian Ng
58cf1a7d48
Bump deps (#10007) 2019-05-21 15:10:29 -05:00