Commit graph

133 commits

Author SHA1 Message Date
Boshen
1959930ee7
fix(coverage): fix clippy 2024-06-11 17:01:52 +08:00
Boshen
f9c08d1e28 feat(coverage): add --debug option for finding crash scene (#3622)
The `--debug` options turns off rayon and prints the paths so we can
find the crashing file by looking at the last printed out file.

closes #3497
2024-06-11 07:10:02 +00:00
Dunqing
5793ff1986
refactor(transformer): replace &’a Trivias with Rc<Trivias> (#3580)
`Transformer` needs to borrow `Trivias`.
8be1cc8052 (r1630711060)
2024-06-11 13:23:41 +08:00
Dunqing
5c8e16c976 feat(coverage): second transformer build does not print typescript (#3561)
Currently, we lack a test to check if the TS AST has been completely deleted. I have thought of a way to test it. Let's have our idempotency test print the TypeScript code the first time and the second time print the JavaScript code only. If the two results do not match, it means that there are still undeleted TS ASTs or other bugs. Since ideally the TS ASTs are completely deleted, the two results should be the same.
2024-06-07 05:04:25 +00:00
Dunqing
0007ee47be
chore(coverage, transformer_conformance): print all AST whether or not they are Typecript AST (#3556)
We have a conclusion that codegen will print whatever is in the AST,
instead of having an option to enable printing TypeScript syntax. I plan
to remove codegen's `enable_typescript` option after we strip out all
typescript AST in the transformer typescript plugin.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-06 15:45:20 +08:00
Dunqing
646b9937ee feat(coverage/transformer): handle @jsx option (#3553)
if has`@jsx: react`, configure transformer options to match `@jsx: react` behavior
2024-06-06 05:34:22 +00:00
Dunqing
3ba2a932d6 refactor(coverage): use code without meta options in TypeScriptSuite (#3552)
The `@jsx: react` is a typescript option. The `Babel` typescript plugin handles @jsx as well, but this is different. `@jsx` in babel is a [pragma](https://babeljs.io/docs/babel-plugin-transform-react-jsx#pragma) option. So we should use code without these meta options to avoid Babel parsing `@jsx` incorrectly
2024-06-06 05:34:18 +00:00
Dunqing
d4588d7cac chore(codegen): print typescript code for typescript files (#3515)
We should not print typescript code as javascript code. Forcing to print as JavaScript code may result in syntax errors. If we truly want javascript code, we can use the `oxc_transformer`.
2024-06-03 10:05:08 +00:00
Dunqing
574629e5de feat(tasks/coverage): turn on idempotency testing for transformer (#3470) 2024-05-30 22:15:32 +08:00
IWANABETHATGUY
0cdb45a1ff
feat(oxc_codegen): preserve annotate comment (#3465)
1. Copy tests from
efa3dd2d8e/internal/bundler_tests/bundler_dce_test.go (L3833-L3971)
2. Add option to preserve annotate comment like `/* #__NO_SIDE_EFFECTS__
*/` and `/* #__PURE__ */`
2024-05-30 15:25:23 +08:00
Boshen
d2e1dbc82a perf(coverage): run test cases in parallel (#3348) 2024-05-19 03:24:08 +00:00
Boshen
899a52bf28
fix: fix some nightly warnings 2024-05-19 00:54:52 +08:00
Dunqing
9ee962add8 feat(transformer): support from_babel_options in TransformOptions (#3301)
Move `BabelOptions` to Transformer. The `output.json` is a standard babel configuration. We can reuse BabelOptions to read [babel.config.json](https://babeljs.io/docs/configuration#babelconfigjson) or our configuration(maybe oxc.config.json)

The current `from_babel_options` implementation is copied from the `transform_options` in `test_case.rs`, which I'll completely reimplement next
2024-05-16 10:10:39 +00:00
Boshen
530455849b chore(tasks): add commit sha to snapshots to make sure submodules are not outdated (#3267)
If submodules are outdated, it'll panic with the following message

```
Repository is outdated, please run `just submodules` to update it.
```

For us maintainers, we'll need the env `UPDATE_SNAPSHOT` to force an update.
2024-05-14 10:18:00 +00:00
Boshen
893af230c0
refactor: clean up more diagnostics usages 2024-05-12 21:46:03 +08:00
Boshen
dbde5b3a04
refactor(diagnostics): remove export of miette 2024-05-12 11:46:48 +08:00
Boshen
2064ae9e0a refactor(parser,diagnostic): one diagnostic struct to eliminate monomorphization of generic types (#3214)
part of #3213

We should only have one diagnostic struct instead 353 copies of them, so we don't end up choking LLVM with 50k lines of the same code due to monomorphization.

If the proposed approach is good, then I'll start writing a codemod to turn all the existing structs to plain functions.

---

Background:

Using `--timings`, we see `oxc_linter` is slow on codegen (the purple part).

![image](https://github.com/zkat/miette/assets/1430279/c1df4f7d-90ef-4c0f-9956-2ec3194db7ca)

The crate currently contains 353 miette errors. [cargo-llvm-lines](https://github.com/dtolnay/cargo-llvm-lines) displays

```
cargo llvm-lines -p oxc_linter --lib --release

  Lines                 Copies               Function name
  -----                 ------               -------------
  830350                33438                (TOTAL)
   29252 (3.5%,  3.5%)    808 (2.4%,  2.4%)  <alloc::boxed::Box<T,A> as core::ops::drop::Drop>::drop
   23298 (2.8%,  6.3%)    353 (1.1%,  3.5%)  miette::eyreish::error::object_downcast
   19062 (2.3%,  8.6%)    706 (2.1%,  5.6%)  core::error::Error::type_id
   12610 (1.5%, 10.1%)     65 (0.2%,  5.8%)  alloc::raw_vec::RawVec<T,A>::grow_amortized
   12002 (1.4%, 11.6%)    706 (2.1%,  7.9%)  miette::eyreish::ptr::Own<T>::boxed
    9215 (1.1%, 12.7%)    115 (0.3%,  8.2%)  core::iter::traits::iterator::Iterator::try_fold
    9150 (1.1%, 13.8%)      1 (0.0%,  8.2%)  oxc_linter::rules::RuleEnum::read_json
    8825 (1.1%, 14.9%)    353 (1.1%,  9.3%)  <miette::eyreish::error::ErrorImpl<E> as core::error::Error>::source
    8822 (1.1%, 15.9%)    353 (1.1%, 10.3%)  miette::eyreish::error::<impl miette::eyreish::Report>::construct
    8119 (1.0%, 16.9%)    353 (1.1%, 11.4%)  miette::eyreish::error::object_ref
    8119 (1.0%, 17.9%)    353 (1.1%, 12.5%)  miette::eyreish::error::object_ref_stderr
    7413 (0.9%, 18.8%)    353 (1.1%, 13.5%)  <miette::eyreish::error::ErrorImpl<E> as core::fmt::Display>::fmt
    7413 (0.9%, 19.7%)    353 (1.1%, 14.6%)  miette::eyreish::ptr::Own<T>::new
    6669 (0.8%, 20.5%)     39 (0.1%, 14.7%)  alloc::raw_vec::RawVec<T,A>::try_allocate_in
    6173 (0.7%, 21.2%)    353 (1.1%, 15.7%)  miette::eyreish::error::<impl miette::eyreish::Report>::from_std
    6027 (0.7%, 21.9%)     70 (0.2%, 16.0%)  <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    6001 (0.7%, 22.7%)    353 (1.1%, 17.0%)  miette::eyreish::error::object_drop
    6001 (0.7%, 23.4%)    353 (1.1%, 18.1%)  miette::eyreish::error::object_drop_front
    5648 (0.7%, 24.1%)    353 (1.1%, 19.1%)  <miette::eyreish::error::ErrorImpl<E> as core::fmt::Debug>::fmt
```

It's totalling more than 50k llvm lines, and is putting pressure on rustc codegen (the purple part on `oxc_linter` in the image above.

---

It's pretty obvious by looking at https://github.com/zkat/miette/blob/main/src/eyreish/error.rs, the generics can expand out to lots of code.
2024-05-11 04:56:22 +00:00
Boshen
f5dccc96fd
refactor(coverage): avoid an String::from_utf8 over head during serialization (#3145) 2024-04-30 23:11:22 +08:00
Boshen
67225a8091
refactor(coverage): replace yaml parsing with saphyr (#3144)
closes #3128

Profiling `cargo run -p oxc_coverage -- parser` no longer shows a
bottleneck in yaml parsing
2024-04-30 22:49:39 +08:00
Boshen
a63a45d5b2
refactor(transformer): remove the requirement of Semantic (#3140)
It seems like we need to rebuild the scopes and symbols while
traversing. We can't utilize the scopes and symbols built by semantic
because they are immutable.
2024-04-30 12:48:21 +08:00
Ali Rezvani
0d770f57ff
refactor: remove redundant imports to fix some of clippy warnings. (#3028)
These are raising warnings in nightly, And are in fact redundant.
2024-04-19 21:02:23 +08:00
Boshen
d57526103c
feat(coverage): add transformer to prevent crashes (#2970) 2024-04-14 18:52:51 +08:00
underfin
b199cb89a2
feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00
underfin
d9b77d853b
refactor(sourcemap): change sourcemap name to take a reference (#2779) 2024-03-23 21:40:05 +08:00
underfin
a2cfc867cb
feat: SourcemapVisualizer (#2773)
Export `SourcemapVisualizer` from codegen, it will be used oxc and
rolldown sourcemap test, so it support multiply source print, it will
using sourcemap `sourcesContent` as original source.
2024-03-21 11:19:09 +08:00
Boshen
0f86333437
refactor(ast): refactor Trivias API - have less noise around it (#2692) 2024-03-12 20:16:36 +08:00
Boshen
977c20b677
feat(coverage): add a duplicate comment check (#2688) 2024-03-12 16:52:34 +08:00
Boshen
e2d2ce3369
feat(parser): parse decorators properly (#2603)
closes #2562
2024-03-04 19:30:41 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps (#2602)
closes #2564
2024-03-04 16:03:33 +08:00
Boshen
8bb1084863
feat(codegen): add sourcemap (#2565)
Co-authored-by: underfin <2218301630@qq.com>
2024-03-03 14:44:49 +08:00
Andrew McClenaghan
6b3b260dcc
feat(Codegen): Improve codegen (#2460)
This gets all the new TS types working to the same level TS output was
before and fixes a bunch of other codegen

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-21 14:41:57 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen (#2443)
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to 
    - Function
    - FormalParameter
    - BindingPattern
 - Adds basic tests for TS generation

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
Boshen
1cbd7539fb
feat(coverage): add prettier idempotency test (#2402)
closes #1329
2024-02-12 15:30:16 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
Dunqing
0df7e296f9
feat(tasks/codegen): check node version >= 20 (#2385)
This syntax only works on node >= 20
`import value from './json-value-array_FIXTURE.json' with { type: 'json'
};`
2024-02-11 19:23:11 +08:00
Dunqing
d6d931cd80
fix(tasks/coverage): when providing filter, do not run just submodules (#2310) 2024-02-05 15:06:37 +08:00
underfin
2f97b332bd
chore: codegen test skip v8 failed test (#2283)
Because v8 isn't pass some test262 tests, we also need to skip them, you
can find it at
https://chromium.googlesource.com/v8/v8/+/refs/heads/main/test/test262/test262.status.
2024-02-04 14:02:39 +08:00
Boshen
d2f7ea2923
chore: manually clone git modules instead of using submodules (#2274)
closes #2231

Submodules are a blocker for beginners, we should make it clone on
demand.

It is also a blocker for people who wants to target this repo as a crate
for testing purposes, cargo will do a full clone if you specify
oxc_parser = { git = "this repo" } in Cargo.toml
2024-02-02 11:56:18 +00:00
Boshen
650f6c942f
refactor: use our forked version of miette::Reporter for tests (#2266) 2024-02-02 16:15:31 +08:00
Boshen
b0f4715df1
ci: disable codegen runtime tests for now
It seems to be unstable across node.js versions
2024-01-15 21:24:07 +08:00
Dunqing
4e7b7dad78
feat(task): handle expected runtime error correctly (#1987) 2024-01-11 15:04:28 +08:00
Dunqing
6417d2ce9c
feat(task): test codegen runtime in run_async (#1980)
<img width="460" alt="image" src="https://github.com/oxc-project/oxc/assets/29533304/4f2d05a1-4d3e-422e-9722-0c77d4ff989d">
2024-01-11 14:59:29 +08:00
Dunqing
ee286a0a48
feat(task): support run async in suite (#1973) 2024-01-11 14:54:30 +08:00
Dunqing
633b21c5d2
feat(task): skips some cases we don't care about in codegen-runtime (#1986)
#1977
2024-01-11 14:50:39 +08:00
Dunqing
fc7dbd9225
feat(task): codegen test262 runtime test (#1959) 2024-01-10 17:12:11 +08:00
magic-akari
9ff0ffcc6f
feat(ast): implement new proposal-import-attributes (#1476)
- [Import Attributes](https://tc39.es/proposal-import-attributes)
2023-11-25 15:56:09 +08:00
Boshen
a60b7e5856
feat(tasks): add misc tests to codegen (#1215) 2023-11-10 16:13:31 +00:00
Boshen
eca98cf2ed
s/web-infra-dev/oxc-project 2023-11-10 14:30:18 +08:00
Boshen
a442fad3b7
feat(semantic): bind function expression name (#1049)
closes #1018

We'll eventually recover the mangling tests, which should cover this
change.
2023-10-24 17:25:12 +08:00
Boshen
1b3b100475
feat(transformer_conformance): read plugins options from babel options.json (#1006)
This PR correctly handles babel `options.json` such as
https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-nullish-coalescing-operator/test/fixtures/assumption-noDocumentAll/options.json
2023-10-17 14:52:51 +08:00