Commit graph

211 commits

Author SHA1 Message Date
Boshen
020bb80b65 refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map (#6310) 2024-10-06 05:05:47 +00:00
Boshen
8729755baa feat(oxc,napi/transform): napi/transform use oxc compiler pipeline (#6298)
part of #6156
2024-10-05 16:35:09 +00:00
overlookmotel
e19deaa102 ci(transformer): move post-transform checker to tasks crate (#6288)
Move post-transform checker into a `tasks` crate. It doesn't feel like it belongs in `oxc_semantic`. It also feels like too heavy a lump of code to put in `tasks/common`.
2024-10-05 14:48:37 +00:00
leaysgur
5a73a663dc refactor(regular_expression)!: Simplify public APIs (#6262)
This PR makes 2 changes to improve the existing API that are not very useful.

- Remove `(Literal)Parser` and `FlagsParser` and their ASTs
- Add `with_flags(flags_text)` helper to `ParserOptions`

Here are the details.

> Remove `(Literal)Parser` and `FlagsParser` and their ASTs

Previously, the `oxc_regular_expression` crate exposed 3 parsers.

- `(Literal)Parser`: assumes `/pattern/flags` format
- `PatternParser`: assumes `pattern` part only
- `FlagsParser`: assumes `flags` part only

However, it turns out that in actual usecases, only the `PatternParser` is actually sufficient, as the pattern and flags are validated and sliced in advance on the `oxc_parser` side.

The current usecase for `(Literal)Parser` is mostly for internal testing.

There were also some misuses of `(Literal)Parser` that restore `format!("/{pattern}/{flags}")` back and use `(Literal)Parser`.

Therefore, only `PatternParser` is now published, and unnecessary ASTs have been removed.
(This also obsoletes #5592 .)

> Added `with_flags(flags_text)` helper to `ParserOptions`

Strictly speaking, there was a subtle difference between the "flag" strings that users were aware of and the "mode" recognised by the parser.

Therefore, it was a common mistake to forget to enable `unicode_mode` when using the `v` flag.

With this helper, crate users no longer need to distinguish between flags and modes.
2024-10-03 02:47:08 +00:00
Boshen
51a78d5946
feat(napi/transform): rename all mention of React to Jsx; remove mention of Binding (#6198)
This does not alter field names nor file names.

part of #6156
2024-10-01 11:52:50 +08:00
Cam McHenry
65d8f9e8fe
perf(linter, ast-tools, coverage): Use FxHashSet instead of std::collections::HashSet (#6001) 2024-09-24 19:29:08 +08:00
camchenry
02d5637dbc perf(ast-tools): use FxHashMap over std::collections::HashMap (#5997) 2024-09-23 18:28:54 +00:00
overlookmotel
eadffb900e test(conformance): move conformance snapshots into separate directory (#5924) 2024-09-20 12:30:39 +00:00
Boshen
84a5816d03
feat(isolated_declarations): add stripInternal (#5878)
closes #3906
closes #5687
closes #3958

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-09-19 23:14:47 +08:00
Boshen
5901d2a0f1 fix(codegen): various spacing issues (#5820) 2024-09-17 09:03:28 +00:00
Boshen
512be65fa7 refactor(coverage): remove sourcemap snapshot (#5782) 2024-09-15 08:56:54 +00:00
dalaoshu
d18c896a2c
perf(rust): use cow_utils instead (#5664)
Related to #5586 and #5662

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-11 18:39:30 +08:00
Boshen
2016bae98c feat(coverage): add regular expression idempotency test (#5676)
closes #5634
2024-09-11 02:07:42 +00:00
Boshen
f49e6ebd41 fix(span): treat .js as module file (reverts the previous breaking change) (#5612)
As it turns out it's not ideal to treat `.js` as `script` in today's world anymore.

This makes https://github.com/oxc-project/oxlint-ecosystem-ci pass again.
2024-09-08 15:14:04 +00:00
Boshen
d00a1f6511
chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
Boshen
1bc08e296e fix(coverage): parse babel unambiguously (#5579) 2024-09-07 10:49:00 +00:00
Boshen
43933912ce fix(coverage): parse typescript unambiguously (#5575) 2024-09-07 10:48:59 +00:00
Boshen
28b934ca74 fix(coverage): apply always_strict to test262 and typescript per the specifcation (#5555)
This also removes the confusing `SourceType::always_strict` field.

I hacked it with `SourceType::always_strict`, but what we actually want is add `'use strict'`.

This is technically a breaking change but I don't expect anyone using this outside of oxc.

The snapshot has a large diff due to every single line shifting by 1 row :-/
2024-09-06 17:14:01 +00:00
overlookmotel
dc924892cc test: add trailing line breaks to conformance fixtures (#5541)
Continuation of #5537. Ensure all conformance fixture files have a trailing line break.
2024-09-06 12:55:17 +00:00
overlookmotel
694f032a3d style: add trailing line breaks to package.json files (#5542)
For consistency with our `.editorconfig`.
2024-09-06 12:43:44 +00:00
Boshen
1bed5ce2a5 chore: run cargo +nightly fmt to sort imports (#5503)
They are never going to be stable are they ... cedf7a4daa/.rustfmt.toml (L8-L16)
2024-09-06 04:04:26 +00:00
Boshen
c3cfbfb480 chore: clippy::allow_attributes (#5521)
https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#expectlint

https://rust-lang.github.io/rust-clippy/master/index.html#/allow_attributes
2024-09-06 03:07:02 +00:00
overlookmotel
be4642fc02 feat(semantic): transform checker check child scope IDs (#5410)
Transform checker check child scope IDs. If we have to track child scope IDs, we should make sure they're correct!
2024-09-03 00:57:13 +00:00
Boshen
e75e0f1465 chore: update test262 / babel / typescript submodules (#5369)
closes #5215
2024-08-31 12:28:25 +00:00
overlookmotel
af5713e411 refactor(semantic): transform checker continue checks if missing IDs (#5259)
Transform checker don't bail out if some IDs missing from AST. Continue to check for other problems.

Also simplify iterating over pairs of IDs.
2024-08-27 11:58:20 +00:00
Boshen
c96609151e
fix(coverage): fix cases where source_type is incorrectly set to script 2024-08-24 14:40:05 +08:00
Boshen
e4ca3d3901
chore(coverage): ignore annex-b/disabled tests 2024-08-24 14:20:06 +08:00
Boshen
12c21b2bfd
fix(coverage): do not run generated test cases when filter is applied 2024-08-24 14:03:54 +08:00
Boshen
afe728a73a feat(parser): parse regular expression with regex parser (#4998)
Many false positives and incorrect errors. @leaysgur Enjoy 😁

Run `just conformance` to update the snapshot.
2024-08-22 03:09:55 +00:00
overlookmotel
ee7ac8b0b7 refactor(semantic): store all data in PostTransformChecker in transform checker (#5050)
Pure refactor of transform checker. Store all scope data in `PostTransformChecker` so it doesn't need to be passed around. `SemanticData` contains a full set of all semantic data for semantic pass, so we have 2 instances of it for 1. after transform and 2. rebuilt semantic.
2024-08-21 17:04:48 +00:00
overlookmotel
4e1f4abf89 refactor(semantic): add SemanticIds to transformer checker (#5048)
Transformer checker use `SemanticIds` to store collected IDs. `SemanticIds` only contains the IDs, without the `Vec` of errors which is only used temporarily.
2024-08-21 15:49:07 +00:00
Boshen
1bd9365bd0 fix(coverage): correctly check semantic data after transform (#5035)
closes #4999
2024-08-21 09:35:04 +00:00
Boshen
b4407c4e9a
refactor(oxc,mangler): oxc crate add mangler; mangler use options API 2024-08-20 22:58:59 +08:00
Boshen
cd9cf5efd8
refactor(oxc): remove remove_whitespace 2024-08-20 18:27:59 +08:00
Boshen
1f6b107339 chore(coverage): ignore test262 stage3 json-modules (#5002)
stage 3 https://github.com/tc39/proposal-json-modules

Ignoring due to https://github.com/tc39/proposal-json-modules/issues/27
2024-08-20 08:50:27 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Boshen
3f6014a042 chore(semantic): add PostTransformChecker (#4967) 2024-08-19 05:38:27 +00:00
Boshen
6800e694e3
feat(oxc): add Compiler and CompilerInterface (#4954)
This PR adds a full compiler pipeline to the `oxc` crate, to stop us
from implementing the same pipeline over and over again.

relates #4455
2024-08-19 10:20:05 +08:00
Boshen
c7a86865f3
fix(coverage): handle transformer errors 2024-08-18 22:19:58 +08:00
Boshen
873d502993
refactor(coverage): use the oxc crate 2024-08-17 22:40:08 +08:00
Boshen
bea76f0f24
fix(coverage): fix babel cases 2024-08-17 11:22:00 +08:00
Boshen
81439403fd chore(coverage): print path relative to snapshot file (#4938)
Ctrl + click in terminal can open the file with this change.

I don't know about vscode, but maybe a plugin can help?

<img width="1399" alt="image" src="https://github.com/user-attachments/assets/9bb4609b-14e9-4df8-b5ee-cb96b72b2f7d">

<img width="1131" alt="image" src="https://github.com/user-attachments/assets/e0293693-f755-4b91-8712-bbd2a0e615cc">
2024-08-17 03:09:25 +00:00
Boshen
7ecf0efd40
chore(coverage): remove arrow functions plugin from semantic check 2024-08-16 19:12:17 +08:00
Boshen
61cdfef5c7
chore(coverage): remove quotes around path from snapshot files
to make it easier to triple click and copy the path
2024-08-16 16:03:50 +08:00
Boshen
c220730779 feat(coverage): check symbols and scopes after transformation (#4917)
closes https://github.com/oxc-project/oxc/issues/4790

@overlookmotel enjoy ... take a look at the snapshots and probably nothing else.

The snapshots are minimal right now, but it's already showing symbols from import specifiers are not being removed. We can iterate on the snapshot representation to aid debugging later.

I'll extend this to `transformer_conformance` and `oxc-monitor` in an up coming PR.
2024-08-16 07:05:11 +00:00
Boshen
34aa93bda3 feat(coverage): add checker for correctness of semantic data (#4908)
Part of https://github.com/oxc-project/oxc/issues/4790
2024-08-15 04:46:07 +00:00
Boshen
117ae36775 refactor(coverage): add driver struct for adding common checks later (#4893) 2024-08-14 11:11:13 +00:00
Boshen
2afccd75fb
refactor(coverage): move tools into src/tools/ 2024-08-14 15:44:03 +08:00
Boshen
e78cba6464 refactor(minifier): ast passes infrastructure (#4625)
After studying google closure compiler, I'm leaning towards a multi-ast-pass infrastructure for the minifier.

This is one of the few places where we are going to trade maintainability over performance, given the goal of the minifier is compression size not performance.

All of the terminologies and separation of concerns are aligned with google closure compiler.

Infrastructure of `terser` and `esbuild` are not suitable for us to study nor pursuit. Their code are so tightly coupled - I failed to comprehend any of them every time I try to walk through a piece of optmization. Google closure compiler despite being written in Java, it's actually the most readable minifier out there.

To improve performance between ast passes, I envision a change detection system over a portion of the code.

The benchmark will demonstrate the performance regression of running 5 ast passes instead of 2.

To complete this PR, I need to figure out "fix-point" and order of these ast passes.
2024-08-04 11:58:39 +00:00
Boshen
107e57019c feat(coverage): run multi-file typescript tests (#4256)
The code is really ugly because I didn't anticipate multi-test files from typescript when I started writing the runner :-(
2024-07-16 06:15:04 +00:00