Commit graph

195 commits

Author SHA1 Message Date
Boshen
414e8285cd perf(semantic): allocate symbol data in Allocator (#8012) 2024-12-20 14:13:41 +00:00
Boshen
02f968d02d refactor(semantic): change Bindings to a plain FxHashMap (#8019)
`IndexMap` was needed for the insertion order requirement in mangler.

Bindings (symbol ids) are monotonically increasing by binding
positions, which means we can get insertion order by sorting the symbol ids in
mangler.

Previous attempt: https://github.com/oxc-project/oxc/pull/4228
2024-12-19 14:16:28 +00:00
Boshen
e7476a1a28 refactor(semantic): remove serialize (#8015) 2024-12-19 09:51:12 +00:00
Boshen
1314c9763b refactor(minifier): expose dce as an API instead of an option (#7957) 2024-12-17 04:47:13 +00:00
Dunqing
e0d440a618
fix(wasm): use ScopeTree's flags rather than enter_scope's flags parameter (#7950)
close:
https://github.com/oxc-project/oxc/issues/7900#issuecomment-2545374960
2024-12-17 10:32:37 +08:00
翠 / green
db9e93b554
feat(mangler): mangle top level variables (#7907)
Adds `top_level` option which is similar to [terser's `toplevel`
option](https://terser.org/docs/cli-usage/#cli-mangle-options).

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-15 21:31:41 +08: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
overlookmotel
3542b4f55f style(wasm): re-order imports (#7864) 2024-12-14 02:30:26 +00:00
overlookmotel
8cf9766be3 refactor(semantic, syntax, wasm): remove #![allow(non_snake_case)] (#7863)
`#![allow(non_snake_case)]` was required in files using `#[derive(Tsify)]`, as a bug in Rust Analyser caused erroneous warnings. This appears to be fixed now, so we can remove these `#![allow]` attributes.
2024-12-14 01:52:32 +00:00
Boshen
0f3f67a05a refactor(linter): add capability of adding semantic data to module record (#7561)
closes #5814
closes #5816
2024-12-01 08:14:43 +00:00
Boshen
c2ced15dfd feat(parser,linter)!: use a different ModuleRecord for linter (#7554)
The parser returns a simple `ModuleRecord` that is allocated in the arena for performance reasons.

The linter uses a more complicated, `Send` + `Sync` `ModuleRecord` that will hold more cross-module information.

The next step is to return more esm information from the parser to eliminated the need of the `oxc_module_lexer` crate.
2024-11-30 16:02:01 +00:00
Boshen
0be5233c84 refactor(semantic)!: remove ModuleRecord from Semantic (#7548)
`ModuleRecord` will eventually be moved to be linter specific thing for cross module data sharing, which means we can add more data to it.
2024-11-29 16:30:54 +00:00
Boshen
8a788b8f4b feat(parser)!: Build ModuleRecord directly in parser (#7546)
This has the benefit of:

* expose dynamic import / import meta info from parser
* 1 less ast shallow in semantic builder
* no ast walk in oxc's module lexer
* some more benefits coming soon
2024-11-29 14:50:42 +00:00
Boshen
d942a8d41a
chore: Rust v1.83.0 changes (#7535)
This PR does not upgrade rustc. Only changes are applied.

We cannot upgrade to the lastet Rust version yet due to wasm-bindgen
breaking some generated types.

THere's also some elided lifetimes in `**/generated/**`, which requires
modification to ast tools.
2024-11-29 11:59:45 +08:00
Boshen
f955ba2fae feat(wasm): add transformer target API (#7513) 2024-11-28 03:45:59 +00:00
Boshen
3169bc61d1
ci: clean up wasm type check (#7466)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-25 17:56:17 +08: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
d1d187417b feat(ast)!: change comment.span to real position that contain // and /* (#7154)
closes #7150
2024-11-06 05:10:33 +00:00
Boshen
fcaba4a92a feat(transformer): add TransformerOptions::env with EnvOptions (#7037) 2024-10-31 12:30:32 +00:00
Boshen
e921df6199 refactor(transformer): rename EnvOptions to BabelEnvOptions (#7036) 2024-10-31 10:00:52 +00:00
Boshen
76947e2aec refactor(transform): refactor Babel Targets (#7026)
Found a trick from serde to get us from `BabelTargets` to `Targets`.
2024-10-30 14:08:19 +00:00
Boshen
b8daab3663 refactor(transformer)!: API to TryFrom<&EnvOptions> for TransformOptions and TryFrom<&BabelOptions> TransformOptions (#7020)
…ions` and `TryFrom<&BabelOptions> TransformOptions`
2024-10-30 09:40:09 +00:00
ottomated
7d12669d68
fix(types): move @oxc-project/types to dependencies (#6909)
Hotfix. NPM doesn't install devDependencies automatically, so types were
missing.
2024-10-26 10:26:54 +08:00
Boshen
741571f645 refactor(minifier): remove extra compress options (#6893)
Closure Compiler and ESBuild does not have these kind of granularity.
2024-10-26 01:30:13 +00:00
ottomated
b075982eaa fix(types): Change @oxc/types package name (#6874)
Closes #6862.

Possible options:
- `oxc-types`
- `@oxc-project/types`
- `@oxc-ast/types`
- `oxc-ast-types`
2024-10-24 20:04:09 +00:00
ottomated
1145341a92 feat(ast_tools): output typescript to a separate package (#6755)
Part of #6347.

Moves typescript logic from derive_estree into a new ast_tools generator.
2024-10-24 13:08:57 +00:00
overlookmotel
683c3443c0 chore(semantic, wasm): re-order dependencies in Cargo.toml files (#6657)
Nit. Move `serde` dependency into more natural place in the list.
2024-10-18 13:40:37 +00:00
Boshen
591f5dd960 chore(deps): update rust crates (#6542) 2024-10-14 03:14:15 +00:00
Boshen
cb8f4210c3 refactor(prettier)!: remove source_text argument from constructor (#6448) 2024-10-11 06:27:33 +00:00
Boshen
520096030a refactor(oxc)!: remove passing Trivias around (#6446)
part of #6426
2024-10-11 06:09:25 +00:00
Boshen
2b7be08af4 feat(ast)! add source_text to Program (#6444) 2024-10-11 04:13:41 +00:00
Boshen
020bb80b65 refactor(codegen)!: change to CodegenReturn::code and CodegenReturn::map (#6310) 2024-10-06 05:05:47 +00:00
overlookmotel
4f6bc79734 refactor(transformer)!: remove source_type param from Transformer::new (#6251)
Closes #6248.
2024-10-03 00:21:01 +00:00
IWANABETHATGUY
a111bb69af feat(oxc_wasm): add verbse option to debug_dot (#5879)
1. Adding a new option to control displaying `implicit error` edge.
**verbose**
![image](https://github.com/user-attachments/assets/cef43d5f-25d0-4408-ad4a-34bc633f2821)
**disable verbose**
![image](https://github.com/user-attachments/assets/02954103-689c-422c-8ada-5805a39335b7)
2024-09-19 06:13:03 +00:00
Boshen
6dd6f7ca26 refactor(ast): change Comment struct (#5783) 2024-09-15 09:22:58 +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
Boshen
63a830e08c
chore(dprint): format toml files (#5599)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-09-08 14:26:16 +08:00
IWANABETHATGUY
08d2b7d761 feat(oxc_wasm): add controlFlowDotString to oxc_wasm (#5571) 2024-09-07 10:41:00 +00: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
add146557c
feat(wasm): turn on all transform options 2024-09-01 00:24:10 +08:00
Boshen
cbd9a60194
fix(wasm): do not run symbols and scopes for .d.ts files 2024-08-30 19:57:09 +08:00
Boshen
8ab270b720
feat(wasm): add mangler 2024-08-30 18:45:56 +08:00
Boshen
3ae94b8801
refactor(semantic): change build_module_record to accept &Path instead of PathBuf 2024-08-30 12:24:49 +08:00
Boshen
7fa2fa386c
refactor(wasm): clean up code and add transform (#5299)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-08-28 22:14:35 +08:00
Kevin Deng 三咲智子
681bd8071a
fix(wasm): reference ast from prettier (#5268)
regression by cc3332898c
2024-08-27 22:15:26 +08:00
overlookmotel
c23104b2a2 feat(wasm): output symbol IDs in scope tree (#5266)
`oxc_wasm` include `SymbolId`s in print-out of scopes.
2024-08-27 13:49:44 +00:00
overlookmotel
6a49dc36b2 perf(wasm): generate scope text with visitor (#5264)
Follow-on after #5232. `oxc_wasm` build scopes text with a single AST traversal. Previous implementation was O($n^2$).

If we can assume scopes are listed in traversal order, then we could do it a bit more efficiently just from `ScopeTree`, but this approach of using `Visit` will handle out-of-order scope IDs (which you'd get if printing a post-transform `ScopeTree`).

Also reduce creating and discarding `String`s for indentation - reuse a single string instead.
2024-08-27 13:49:42 +00:00
overlookmotel
17d8a88415
fix(wasm): display correct scope IDs (#5263)
`ScopeId`s were printed incorrectly. `+ 1` used to be correct, but isn't
any more since `ScopeId` became a `NonMaxU32`.
2024-08-27 20:39:07 +08:00
Kevin Deng 三咲智子
cc3332898c
perf(wasm): reuse parse result for prettier (#5254) 2024-08-27 16:56:18 +08:00