Boshen
5845057bff
refactor(transformer): pass in symbols and scopes ( #3978 )
...
This PR adds a new method `build_with_symbols_and_scopes` to make semantic building optional, there may be prior steps that has the semantic data already built.
2024-06-30 06:33:48 +00:00
Boshen
4e9d8a5585
chore: fix some nightly clippy warnings
2024-06-19 00:53:58 +08:00
Boshen
051ceb6539
chore: improve some format by running cargo +nightly fmt
2024-06-19 00:48:30 +08:00
Boshen
5c38a0fd69
feat(codegen)!: new code gen API ( #3740 )
...
This PR introduces two type alias to avoid the confusing const generic `pub struct Codegen<'a, const MINIFY: bool>`
* CodeGenerator - Code generator without whitespace removal.
* WhitespaceRemover - Code generator with whitespace removal.
Usage is changed to a builder pattern:
```rust
CodeGenerator::new()
.enable_comment(...)
.enable_sourcemap(...)
.build(&program);
```
2024-06-18 15:50:12 +00:00
Boshen
982e6f08df
chore: make println and eprintln opt-in ( #3712 )
...
I noticed accidental `println` can be merged, which isn't really nice.
2024-06-17 10:40:34 +00:00
Boshen
534242a729
feat(codegen)!: remove CodegenOptions::enable_typescript ( #3674 )
...
The typescript transform pass is now required to strip typescript syntax
for codegen to print things properly.
Codegen will now print whatever is in the AST.
2024-06-14 21:56:00 +08:00
Boshen
b58d8eb88f
fix!(codegen): remove the unecessary 4th argument from Codegen::new ( #3640 )
2024-06-12 07:58:54 +00:00
Boshen
f6752b482f
feat!(ast): make Trivias clonable by adding Arc ( #3638 )
...
This makes `Trivias` cloneable and stops us from using `Rc::new` and
`Rc::clone` everywhere.
`Trivias` is rarely cloned so an `Arc` should suffice.
2024-06-12 13:16:10 +08: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
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
overlookmotel
837776e1ab
fix(transformer): TS namespace transform do not track var decl names ( #3501 )
...
Don't track variable declaration or import binding names in TS namespace transform.
Babel does, but it appears to be wrong. It's illegal to have a `var`/`let`/`const` declaration or import in same scope as a TS namespace declaration with same binding.
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAQTgMyhEcDkUCmBDAYxkwG4AoAOzxBwGcxCdE4BvAXzLIIgtvgCE4AXjgBGclRr1GcQSzJxFcADY54AD3Icyq+AGFhYidToMCTA-KUq1cTWW0A3PFDgARQ+Monp596wUlXTstMiA
2024-06-03 12:35:57 +00:00
overlookmotel
8e4f33557d
fix(transformer): output empty file for TS definition files ( #3500 )
...
As discussed in
https://github.com/oxc-project/oxc/pull/3489#issuecomment-2143482458 ,
transformer should output an empty file for TS definition files.
2024-06-03 20:25:02 +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
Dunqing
6a1f2c21df
chore(transform_conformance): skip some test cases ( #3449 )
2024-05-28 13:38:03 +00:00
Dunqing
816a782254
feat(transformer): support targets option of preset-env ( #3371 )
...
The implementation of the `targets` options was copied from
[swc](https://github.com/swc-project/swc/tree/main/crates/preset_env_base ),
which resulted in some added dependencies in transformer.
Currently, it has supported enabling plugins by `targets`
2024-05-27 10:33:40 +08:00
Dunqing
e2c6fe0cb1
feat(transformer): report errors when options have unknown fields ( #3322 )
2024-05-19 01:19:40 +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
Dunqing
8ff1ffba74
feat(transformer_conformance): skip some tests that are known to fail ( #3293 )
...
I don't think we need to be completely consistent with Babel's output.
Because Babel's output doesn't always make sense.
2024-05-15 22:06:00 +08: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
dbde5b3a04
refactor(diagnostics): remove export of miette
2024-05-12 11:46:48 +08:00
Dunqing
fd6a1aa1d2
feat(transformer_conformance): correct source type ( #3233 )
2024-05-11 09:30:43 +00:00
Dunqing
18d853bb2b
feat(transformer/react): support development mode ( #3143 )
2024-05-10 22:07:33 +08:00
Dunqing
a227050ed0
chore: update babel repo ( #3205 )
2024-05-08 20:15:15 +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
Boshen
d76507699d
chore(transform_conformance): skip transform-destructuring ( #3136 )
2024-04-30 00:09:22 +08:00
Boshen
5a3f8a5811
feat(transform_conformance): handle parse error ( #3135 )
2024-04-30 00:07:53 +08:00
Dunqing
843318cdbe
refactor(transformer/typescript): reimplementation of Enum conversion based on Babel ( #3102 )
...
The remaining test cases will perform better with a scope
implementation, and while we can implement them without the scope, it
still requires us to do what the scope did.
---------
Co-authored-by: Boshen <boshenc@gmail.com>
2024-04-29 16:26:22 +08:00
Dunqing
905ee3fef1
feat(transformer): add arrow-functions plugin ( #3083 )
...
close : #2983
2024-04-29 08:04:01 +00:00
Boshen
722d4c2350
fix(transformer): TypeScriptOptions deserialize should fallback to default ( #3012 )
2024-04-17 16:27:50 +08:00
Dunqing
b72bdcaf96
feat(transformer/react): reports duplicate __self/__source prop error ( #3009 )
2024-04-17 13:34:31 +08:00
Boshen
df1996157f
chore(transform_conformance): ignore more unsupported plugins ( #3008 )
2024-04-16 18:59:21 +08:00
Dunqing
cdd3bc5a4e
feat(transformer_conformance): enable typescript when the typescript plugin is present ( #3007 )
2024-04-16 10:47:06 +00:00
Boshen
ae9d681b4d
feat(transform_conformance): skip windows tests ( #3003 )
2024-04-16 17:50:43 +08:00
Boshen
85a3653994
feat(transformer): add "_jsxFileName" variable in jsx source plugin ( #3000 )
2024-04-16 17:40:24 +08:00
Boshen
5f4c1e1d3e
chore(transform_conformance): skip custom presets ( #3001 )
2024-04-16 17:21:34 +08:00
Boshen
82e00bc951
refactor(transformer): remove boilerplate code around decorators to reduce noise ( #2991 )
2024-04-15 13:51:09 +08:00
Boshen
b4bfa2f34c
refactor(transform_conformance): correctly handle BABEL_8_BREAKING ( #2990 )
2024-04-15 13:41:45 +08:00
Boshen
5a286c3d9f
feat(transform_conformance): drop more unsupported plugins ( #2984 )
2024-04-14 23:04:04 +08:00
Boshen
9643cba4a4
feat(transform_conformance): drop all babel 7 specific tests ( #2982 )
...
@Dunqing Is this correct?
2024-04-14 23:02:38 +08:00
Boshen
c753c9fa74
feat(transform_conformance): handle deserialization errors ( #2980 )
2024-04-14 22:47:28 +08:00
Boshen
7cf0927a38
feat(transform_conformance): skip tests with plugin.js ( #2977 )
2024-04-14 21:45:27 +08:00
Boshen
ef602af4cc
feat(transform_conformance): skip plugins we don't support yet ( #2967 )
2024-04-14 21:32:03 +08:00
Boshen
10814d5331
fix(transformer): turn on react preset by default ( #2968 )
2024-04-14 19:04:59 +08:00
Boshen
bd9fc6d169
feat(transformer): react jsx transform ( #2961 )
2024-04-14 10:50:17 +08:00
Boshen
6561392202
feat(transform_conformance): add baseline for all TypeScript and jsx plugins
2024-04-13 19:05:39 +08:00
Boshen
e651e50bda
feat(transformer): add the most basic plugin toggles ( #2950 )
2024-04-12 20:25:34 +08:00
Boshen
60ccbb105c
refactor(transformer): clean up some code ( #2949 )
2024-04-12 20:23:44 +08:00
Boshen
14754777a4
feat(transformer): implement react-jsx-source ( #2948 )
2024-04-12 20:21:54 +08:00
Boshen
f903a225a8
feat(transformer): implement react-jsx-self ( #2946 )
2024-04-12 18:08:36 +08:00
Boshen
f3a28c61b9
chore(transform_conformance): enable typescript plugin snapshot
2024-04-11 20:06:53 +08:00