Commit graph

48 commits

Author SHA1 Message Date
Boshen
91c87dd380 refactor(codegen)!: remove Codegen::enableSourceMap API (#6452) 2024-10-12 04:56:43 +00:00
Boshen
7645e5c34b refactor(codegen)!: remove CommentOptions API (#6451) 2024-10-11 13:53:28 +00:00
Boshen
520096030a refactor(oxc)!: remove passing Trivias around (#6446)
part of #6426
2024-10-11 06:09:25 +00:00
Boshen
020bb80b65 refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map (#6310) 2024-10-06 05:05:47 +00:00
Boshen
a0ccc26c12 feat(napi/transform): add lang option to change source type (#6309)
part of #6274 and #6156

```
    /// Treat the source text as `js`, `jsx`, `ts`, or `tsx`.
    #[napi(ts_type = "'js' | 'jsx' | 'ts' | 'tsx'")]
    pub lang: Option<String>,
```
2024-10-06 04:53:47 +00:00
Boshen
58a8615747 refactor(napi/transform): remove context (#6306) 2024-10-06 01:57:49 +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
Boshen
2f888ed871 feat(oxc): add napi transform options (#6268) 2024-10-03 13:36:38 +00:00
Boshen
099ff3a033 refactor(napi/transform): remove "Binding" from types; fix type error (#6260)
closes #6254
closes #6255
2024-10-03 00:44:07 +00:00
overlookmotel
4f6bc79734 refactor(transformer)!: remove source_type param from Transformer::new (#6251)
Closes #6248.
2024-10-03 00:21:01 +00:00
Boshen
f98e12c13a feat(napi/transform): add inject plugin (#6250) 2024-10-02 15:15:51 +00:00
Boshen
291891e71a feat(napi/transform): add define option (#6212)
part of #6156
2024-10-01 12:57:29 +00:00
Boshen
afc3ccbece feat(napi/transform)!: rename TransformOptions::react to jsx. (#6211) 2024-10-01 10:25:21 +00:00
Boshen
54c1c53e69 refactor(napi/transform): remove a call on TransformOptions::clone (#6210) 2024-10-01 09:52:39 +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
Boshen
15552ac499 feat(napi/transform): display semantic error (#6160) 2024-09-29 04:17:26 +00:00
Boshen
f27d59f748 fix(napi/transform): remove confusing jsx option (#6159) 2024-09-29 04:09:53 +00:00
Boshen
f50fdcd0f9 feat(napi/transform): make react refresh option take a boolean (#6146) 2024-09-28 14:52:46 +00:00
Boshen
6f98aadc7f fix(sourcemap): align sourcemap type with Rollup (#6133)
closes #5578
2024-09-28 04:24:05 +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
127c88134e fix(napi/transform): fix jsdoc links (#5886) 2024-09-19 13:55:29 +00:00
Boshen
6c04fa1e46 fix(napi/transform): make isolated_declaration options optional (#5880)
closes #5871
2024-09-19 08:07:54 +00:00
Boshen
dfbde2c602 feat(isolated_declarations): print jsdoc comments (#5858) 2024-09-18 14:09:00 +00:00
overlookmotel
3230ae5842 feat(semantic): add SemanticBuilder::with_excess_capacity (#5762)
Add `SemanticBuilder::with_excess_capacity` method to request that `SemanticBuilder` over-allocate space in `Semantic`'s `Vec`s.

Use this method to reserve 200% extra capacity for transformer to create more scopes, symbols and references.

200% is an unscientific guess of how much extra capacity is required. Obviously it depends on what transforms are enabled and content of the source code.
2024-09-14 15:02:16 +00:00
Dunqing
608b7d37d6 fix(napi/transformer): refresh plugin doesn't work even after passing the refresh option (#5702) 2024-09-11 12:39:51 +00:00
Boshen
e698418d1a feat(napi/transform): align output SourceMap with Rollup's ExistingRawSourceMap (#5657)
closes #5578
2024-09-09 15:55:23 +00:00
underfin
aba9194ebc
feat(napi/transform): export react refresh options (#5533)
Co-authored-by: Boshen <boshenc@gmail.com>
2024-09-08 08:42:17 +08:00
Boshen
b06052501a refactor(semantic)!: remove source_type argument from SemanticBuilder::new (#5553)
Realized we can get the source type from the AST.

The next PR will introduce `unambiguous` to `SourceType` and directly set `Program::source_type` to either `script` or `module`.
2024-09-06 16:40:10 +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
Dunqing
0abfc5049f feat(transformer/typescript): support rewrite_import_extensions option (#5399)
close: #5395

Babel only supports `rewrite`, we also support `remove`
2024-09-03 01:57:42 +00:00
Boshen
b1d0075359 feat(napi/transform)!: align output API sourceText -> code with babel (#5398)
And `sourceMap` -> `map`

closes #5397
2024-09-02 07:53:46 +00:00
dalaoshu
72740b3f78
feat(isolated_declaration): support sourcemap option (#5170)
closes #4313
2024-08-25 13:32:47 +08:00
Boshen
01c0c3e4b2 feat(transformer): add remaining options to transformer options (#5169)
closes #5168
2024-08-24 14:52:03 +00:00
Boshen
4b49cf8ce4 feat(transformer): always pass in symbols and scopes (#5087)
We no longer need to build semantic data inside the transformer.

The caller should be responsible for handling semantic data and its
errors.

The best way to achieve this in via `CompilerInterface`.

closes #3565
2024-08-22 16:06:31 +00:00
Boshen
ce4d4698b4 feat(codegen)!: remove const generic MINIFY (#5001)
This is a premature optimization, makes the code complicated, and bloats the final binary size.

The minify option is moved to `CodegenOptions`
2024-08-20 08:13:27 +00:00
Boshen
4d0b40ad10
fix(napi/transform): fix wrong isolated declarations emit 2024-08-08 14:36:41 +08:00
DonIsaac
9b51e045c7 refactor: overhaul napi transformer package (#4592)
## What This PR Does
- Support declaration emit with `transform()`
- Consolidate shared parsing and error reporting logic into a `TransformContext`
- Add JSDoc comments to options

I'm getting this package ready for consumption in [oxc-jest](https://github.com/oxc-project/oxc-jest).
2024-08-06 01:14:10 +00:00
Boshen
725571aad1 feat(napi/transformer): add jsx option to force parsing with jsx (#4133)
To mimic the esbuild `loader=jsx` or babel `babel-plugin-syntax-jsx` behavior.
2024-07-10 11:12:10 +00:00
Boshen
720983a965
feat(napi/transform): allow setting sourceType to transform (#4113)
closes #4071

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-07-08 19:09:45 +08:00
Boshen
150f4d90fc
fix(napi/transform): display error with spanned messages 2024-07-05 23:41:39 +08:00
underfin
0b56d50899
chore(napi): make transformer options optional (#3989) 2024-07-01 16:45:00 +08:00
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
underfin
d3cd3ea2de
feat: oxc transform binding (#3896)
closes #3877

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-06-26 21:57:19 +08:00
Boshen
05e97b615d
chore: fix clippy warning 2024-06-20 23:22:01 +08:00
Boshen
fe38a20715
refactor(napi/transform): output normal error messages 2024-06-20 23:14:17 +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
f42c325a06 refactor(napi): change "isolated declarations" to "transform" (#3721) 2024-06-17 14:09:18 +00:00