Commit graph

62 commits

Author SHA1 Message Date
Boshen
c16a85176d feat(napi/transform): add jsx: 'preserve' option (#7965)
closes #7958
2024-12-17 13:49:51 +00:00
overlookmotel
3858221f45 refactor(global): sort imports (#7883)
Pure refactor. Re-order imports for clarity:

1. `std`
2. External crates
3. `oxc_*` crates
4. Current crate `use crate::...`
5. Super `use super::...`
6. Local modules

This order is from "furthest away" to "closest". This makes it clearer to see what is coming from where.

`cargo +nightly fmt` (#7877) did a lot of the work, but unfortunately `rustfmt` does not have an option to (a) put workspace crates in a separate block from external crates and (b) move `mod` statements to after `use` statements.
2024-12-14 15:07:21 +00:00
Boshen
7fb9d47460 style(rust): cargo +nightly fmt (#7877) 2024-12-14 06:03:31 +00:00
Boshen
18d0ce3c06
fix(napi): rename Error to OxcError to avoid name collision (#7780) 2024-12-11 00:30:07 +08:00
Boshen
2803aec521 feat(napi/transform): return helpers information (#7737)
closes #7599
2024-12-09 14:07:40 +00:00
Boshen
c98457db5c feat(napi/transformer): add runtime helper mode (#7727)
part of #7599
2024-12-08 15:29:55 +00:00
Boshen
85eec3c82e feat(napi/transform,napi/parser): return structured error object (#7724)
closes #7261
2024-12-08 14:11:56 +00:00
Boshen
771c698a81
feat(oxc): remove oxc_napi crate (#7634)
napi has a limitation, it cannot feature gate type exposure.

closes #7623
2024-12-04 10:07:32 +08:00
Boshen
b4f3812c4a refactor(oxc_napi): remove source_map - moved to its crate (#7614) 2024-12-03 14:42:34 +00:00
Boshen
bd977cf742 feat(oxc): add oxc_napi crate (#7612) 2024-12-03 14:02:47 +00:00
Kevin Deng 三咲智子
be2293a1b5
fix(napi/transform): respect options.sourcemap for id (#7590)
Don't pass `source_map_path` if `options.sourcemap` is undefined or
false; then, `IsolatedDeclarationsResult.map` should be undefined.

Downstream issue
https://github.com/unplugin/unplugin-isolated-decl/issues/42

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-12-03 11:57:44 +08:00
Boshen
bb2c0c219b refactor(transformer)!: return String as error instead of OxcDiagnostic (#7424) 2024-11-22 16:22:49 +00:00
Boshen
846711cf41 feat(transformer)!: change API to take a &TransformOptions instead of TransformOptions (#7213)
closes #7185

`TransformOption`s has an initialization cost, it should be initialized once and shared across files.
2024-11-09 06:01:13 +00:00
Boshen
d15e408256 fix(napi/transform): fix 'typescript.declaration' option not working (#7012)
fixes #7010
2024-10-30 03:21:08 +00:00
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