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
oxc-bot
1428527da6
release(crates): v0.41.0 ( #7846 )
...
## [0.41.0] - 2024-12-13
- fb325dc ast: [**BREAKING**] `span` field must be the first element
(#7821 ) (Boshen)
- 96a26d3 ast: [**BREAKING**] Rename `is_strict` methods to
`has_use_strict_directive` (#7783 ) (overlookmotel)
### Features
- 8991f33 ast: Add `visit_span` to `Visit` and `VisitMut` (#7816 )
(overlookmotel)
- f7900ab ast: Add `ArrowFunctionExpression::has_use_strict_directive`
method (#7784 ) (overlookmotel)
- e727ae9 transformer/class-properties: Transform super member
expressions that are inside static prop initializer (#7815 ) (Dunqing)
### Bug Fixes
- 7610dc1 parser: Parse `import source from 'mod'` (#7833 ) (Boshen)
- 9479e2b semantic: Missing references when `export {}` references a
type-only binding and a normal (#7812 ) (Yunfei He)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813 ) (Dunqing)
- 4a3bca8 semantic: Fix identifying strict mode arrow functions (#7785 )
(overlookmotel)
- 5b7e1ad transformer: Remove span of define value (#7811 ) (Hiroshi
Ogawa)
- 14896cb transformer/class-properties: Create temp vars in correct
scope (#7824 ) (overlookmotel)
- 25bb6da transformer/class-properties: Fix `ScopeId`s in instance prop
initializers (#7823 ) (overlookmotel)
- 65b109a transformer/class-properties: No `raw` for generated
`StringLiteral` (#7825 ) (overlookmotel)
- 2964a61 transformer/class-properties: Unwrap failed when private field
expression doesn't contain optional expression in `ChainExpression`
(#7798 ) (Dunqing)
- 6fa6785 transformer/class-properties: Panic when the callee or member
is `ParenthesisExpression` or TS-syntax expressions. (#7795 ) (Dunqing)
- bb22c67 transformer/class-properties: Fix `ScopeId`s in static prop
initializers (#7791 ) (overlookmotel)
- caa57f1 transformer/class-properties: Fix scope flags in static prop
initializers (#7786 ) (overlookmotel)
### Performance
- 4448b63 codegen: Faster writing indentation (#7820 ) (overlookmotel)
- afaaffa codegen: Fast path for `options.print_comments()` (#7806 )
(Boshen)
### Refactor
- 0f367e5 semantic: Improve the logic of resolving references to be
cleaner (#7829 ) (Dunqing)
- 5710950 semantic: Move export-related reference flags logic to visit
functions (#7828 ) (Dunqing)
- b290ebd transformer: Handle `<CWD>` in test runner (#7799 ) (Dunqing)
- e70deb9 transformer/class-properties: Locate instance props insertion
location in separate step (#7819 ) (overlookmotel)
- afc5f1e transformer/class-properties: De-deduplicate code (#7805 )
(overlookmotel)
- 47a91d2 transformer/class-properties: Shorten code (#7804 )
(overlookmotel)
- 54ef2b9 transformer/class-properties: Rename
`debug_assert_expr_is_not_parenthesis_or_typescript_syntax` (#7803 )
(overlookmotel)
- 3cdc47c transformer/class-properties: `#[inline(always)]` on
`assert_expr_neither_parenthesis_nor_typescript_syntax` (#7802 )
(overlookmotel)
### Testing
- d72c888 transformer/replace-global-defines: Remove panicking test
(#7838 ) (overlookmotel)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:25:13 +08:00
oxc-bot
bd572c609b
release(crates): v0.40.1 ( #7781 )
...
## [0.40.1] - 2024-12-10
### Bug Fixes
- 18d0ce3 napi: Rename `Error` to `OxcError` to avoid name collision
(#7780 ) (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-11 00:35:34 +08:00
oxc-bot
6768f7ded2
release(crates): v0.40.0 ( #7775 )
2024-12-10 23:04:43 +08:00
Song Gao
ebc80f6749
refactor(ast)!: change 'raw' from &str to Option<Atom> ( #7547 )
...
Fix #7254
Changed all "raw" properties of literal types (if they have this property) to `Option<Atom>`.
---------
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-05 00:34:45 +00:00
oxc-bot
fee2143f4c
release(crates): v0.39.0 ( #7643 )
2024-12-04 19:43:22 +08:00
Boshen
9d6e14bb67
test(ecmascript): move tests to oxc_minifier due to cyclic dependency with oxc_parser ( #7542 )
2024-11-29 09:18:45 +00:00
Boshen
63a66cfff3
refactor(minifier): remove unused ast pass from DCE ( #7540 )
2024-11-29 08:10:07 +00:00
Boshen
62a8c5eb59
chore(minifier): temporary remove try_fold_if_block_one and try_fold_if_one_child ( #7536 )
...
They are not idempotent.
2024-11-29 05:05:07 +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
896ff860f9
fix(minifier): do not fold if statement block with lexical declaration ( #7519 )
2024-11-28 10:37:41 +00:00
Boshen
625a5bad02
refactor(minifier): improve ast passes ( #7518 )
2024-11-28 09:33:31 +00:00
overlookmotel
f2f31a8d7a
fix(traverse)!: remove unsound APIs ( #7514 )
...
It's essential to `oxc_traverse`'s safety scheme that the user cannot create a `TraverseAncestry`, because they could then substitute it for the one stored in `TraverseCtx`, and cause a buffer underrun when an ancestor gets popped off stack which should never be empty - but it is because user has sneakily swapped it for another one.
Not being able to create a `TraverseAncestry` also requires that user cannot obtain an owned `TraverseCtx` either, because you can obtain an owned `TraverseAncestry` from an owned `TraverseCtx`.
Therefore, it's unsound for `TraverseCtx::new` to be public.
However, it is useful in minifier to be able to re-use the same `TraverseCtx` over and over, which requires having an owned `TraverseCtx`.
To support this use case, introduce `ReusableTraverseCtx`. It is an opaque wrapper around `TraverseCtx`, which prevents accessing the `TraverseCtx` inside it. It's safe for user to own a `ReusableTraverseCtx`, because there's nothing they can do with it except for using it to traverse via `traverse_mut_with_ctx`, which ensures the safety invariants are upheld.
At some point, we'll hopefully be able to reduce the number of passes in the minifier, and so remove the need for `ReusableTraverseCtx`.But in the meantime, this keeps `Traverse`'s API safe from unsound abuse.
Note: Strictly speaking, there is still room to abuse the API and produce UB by initiating a 2nd traversal of a different AST in an `Traverse` visitor, and then `mem::swap` the 2 x `&mut TraverseCtx`s. But this is a completely bizarre thing to do, and would basically require you to write malicious code specifically designed to cause UB, so it's not a real risk in practice. We'd need branded lifetimes to close that hole too.
So this PR doesn't 100% ensure safety in a formal sense, but it at least makes it very hard to trigger UB *by accident*, which was the risk before.
2024-11-28 10:30:53 +08:00
Boshen
b0e1c03284
feat(ast)!: add StringLiteral::raw field ( #7393 )
...
part of #7254
2024-11-26 23:33:56 +08:00
7086cmd
97af341cac
feat(minifier): minify alternated one child if block ( #7231 )
2024-11-26 15:00:16 +00:00
Ethan Goh
ac0d25c426
feat(minifier): minify one child if statement expression ( #7230 )
2024-11-26 22:48:27 +08:00
Boshen
c133693e5c
perf(minifier): fuse ast passes ( #7493 )
2024-11-26 14:30:04 +00:00
oxc-bot
00a7372eaf
release(crates): v0.38.0 ( #7490 )
2024-11-26 14:38:47 +08:00
oxc-bot
0918e520cf
release(crates): v0.37.0 ( #7399 )
2024-11-21 22:27:55 +08:00
overlookmotel
39afb48025
feat(allocator): introduce Vec::from_array_in ( #7331 )
...
Because we lack specialization in stable Rust, `Vec::from_iter_in` is unable to take advantage of the fact that `[T; N]` has a statically knowable size.
Introduce `Vec::from_array_in` for this case, which should be able to create the `Vec` with a single static-sized memcpy, or may allow the compiler to see that it can construct the array directly in the arena, rather than construct on stack and then copy to the arena.
Also add a corresponding `AstBuilder::vec_from_array` method, and use it in various places in codebase.
2024-11-18 02:35:46 +00:00
Song Gao
cf3415b0e4
chore(doc): replace main/master to tag/commit to make the url always accessible ( #7298 )
2024-11-16 21:00:30 +08:00
7086cmd
cf99be0a0d
fix(minifier): do not compare bigint with object ( #7294 )
...
@Boshen, could you please update the snap of runtime and commit to this PR? I want to see the effects after the unit tests are added.
2024-11-16 06:01:06 +00:00
7086cmd
0d6a66aa9e
test(minifier): fix minimize condition tests ( #7222 )
2024-11-11 08:36:19 +00:00
oxc-bot
de107246c8
release(crates): v0.36.0 ( #7227 )
...
## [0.36.0] - 2024-11-09
- b11ed2c ast: [**BREAKING**] Remove useless `ObjectProperty::init`
field (#7220 ) (Boshen)
- 0e4adc1 ast: [**BREAKING**] Remove invalid expressions from
`TSEnumMemberName` (#7219 ) (Boshen)
- 846711c transformer: [**BREAKING**] Change API to take a
`&TransformOptions` instead of `TransformOptions` (#7213 ) (Boshen)
- 092de67 types: [**BREAKING**] Append `rest` field into `elements` for
objects and arrays to align with estree (#7212 ) (ottomated)
- d1d1874 ast: [**BREAKING**] Change `comment.span` to real position
that contain `//` and `/*` (#7154 ) (Boshen)
- 843bce4 ast: [**BREAKING**] `IdentifierReference::reference_id` return
`ReferenceId` (#7126 ) (overlookmotel)
### Features
- cc8a191 ast: Methods on AST nodes to get `scope_id` etc (#7127 )
(overlookmotel)
- dc0215c ast_tools: Add #[estree(append_to)], remove some custom
serialization code (#7149 ) (ottomated)
- 9d6cc9d estree: ESTree compatibility for all literals (#7152 )
(ottomated)
- b74686c isolated-declarations: Support transform TSExportAssignment
declaration (#7204 ) (Dunqing)
- ad3a2f5 tasks/compat_data: Generate our own compat table (#7176 )
(Boshen)
- b4258ee transformer: Add defaulted `Module::Preserve` option (#7225 )
(Boshen)
- 324c3fe transformer: Add `TransformOptions::module` option (#7188 )
(Boshen)
- a166a4a transformer: Add esbuild comma separated target API
`--target=es2020,chrome58` (#7210 ) (Boshen)
- 3a20b90 transformer: Add es target to `engineTargets` (#7193 ) (Boshen)
- 22898c8 transformer: Warn BigInt when targeting < ES2020 (#7184 )
(Boshen)
- a579011 transformer: Add features `ES2018NamedCapturingGroupsRegex`
and `ES2018LookbehindRegex` (#7182 ) (Boshen)
- 8573f79 transformer: Turn on async_to_generator and
async_generator_functions plugins in enable_all (#7135 ) (Dunqing)
- df77241 transformer: Enable `ArrowFunctionConverter` in
`async-to-generator` and `async-generator-functions` plugins (#7113 )
(Dunqing)
- b6a5750 transformer/arrow-function-converter: Move scope to changed
scope for `this_var` if scope have changed (#7125 ) (Dunqing)
- 1910227 transformer/async-to-generator: Support inferring the function
name from the ObjectPropertyValue's key (#7201 ) (Dunqing)
- ffa8604 transformer/async-to-generator: Do not transform await
expression if is not inside async function (#7138 ) (Dunqing)
- e536d47 transformer/babel: Add support for trying to get the `Module`
from `BabelPlugins` (#7218 ) (Dunqing)
- 5cfdc05 transformer/typescript: Support transform `export =` and
`import = require(...)` when module is commonjs (#7206 ) (Dunqing)
### Bug Fixes
- c82b273 transformer/async-generator-functions: Only transform object
method in exit_function (#7200 ) (Dunqing)
- b2a888d transformer/async-generator-functions: Incorrect
transformation for `for await` if it's not placed in a block (#7148 )
(Dunqing)
- 19892ed transformer/async-generator-functions: Transform incorrectly
for `for await` if it's in LabeledStatement (#7147 ) (Dunqing)
- ede10dc transformer/async-to-generator: Incorrect transform when super
expression is inside async method (#7171 ) (Dunqing)
- 293d072 transformer/async-to-generator: Only transform object method
in exit_function (#7199 ) (Dunqing)
- ae692d7 transformer/async_to_generator: Fix checking if function is
class method (#7117 ) (overlookmotel)
- eea4ab8 transformer/helper-loader: Incorrect `SymbolFlags` for default
import when `SourceType` is script (#7226 ) (Dunqing)
### Refactor
- d27e14f ast: `AstKind::as_*` methods take `self` (#5546 )
(overlookmotel)
- fac5042 ast: Use `scope_id` etc methods (#7130 ) (overlookmotel)
- a297765 minifier: Use `map` and `and_then` instead of let else (#7178 )
(7086cmd)
- fc86703 napi/transform: Change test files to TypeScript (#7221 )
(Boshen)
- c5485ae semantic: Add `ancestor_kinds` iterator function (#7217 )
(camchenry)
- abf1602 semantic: Rename `iter_parents` to `ancestors` (#7216 )
(camchenry)
- 42171eb semantic: Rename `ancestors` to `ancestor_ids` (#7215 )
(camchenry)
- de56083 transformer: Add `impl TryFrom<EngineTargets> for EnvOptions`
(#7191 ) (Boshen)
- 0a43c64 transformer: Move `ESTarget` to its own file (#7189 ) (Boshen)
- 0e1f12c transformer: Remove unimplemented `EnvOptions::bugfixes`
(#7162 ) (Boshen)
- a981caf transformer: Add `Engine` enum for `EngineTargets` (#7161 )
(Boshen)
- 8340243 transformer: Rename `Query` to `BrowserslistQuery` (#7143 )
(Boshen)
- 481f7e6 transformer: Change `Targets` to `EngineTargets` (#7142 )
(Boshen)
- 55e6989 transformer: Deserialize engine target strings to specific
keys (#7139 ) (Boshen)
- fdfd9a4 transformer: Use `scope_id` etc methods (#7128 )
(overlookmotel)
- ff8bd50 transformer: Move implementation of ArrowFunction to
common/ArrowFunctionConverter (#7107 ) (Dunqing)
- 4a515be transformer/arrow-function-coverter: Rename function name and
add some comments to explain confusing parts. (#7203 ) (Dunqing)
- c307e1b transformer/arrow-functions: Pass `ArenaBox` as function param
(#7169 ) (overlookmotel)
- 217d433 transformer/arrow-functions: Remove unused `&mut self`
function param (#7165 ) (overlookmotel)
- 426df71 transformer/arrow-functions: Use `scope_id` method (#7164 )
(overlookmotel)
- 11c5e12 transformer/arrow-functions: Correct comments (#7163 )
(overlookmotel)
- 1238506 transformer/async-generator-function: Remove inactive
`#[allow(clippy::unused_self)]` attrs (#7167 ) (overlookmotel)
- 84ee581 transformer/async-generator-functions: Simplify identifying
whether within an async generator function (#7170 ) (overlookmotel)
- 1b12328 transformer/async-generator-functions: Use `clone` not
`clone_in` on `LabelIdentifier` (#7172 ) (overlookmotel)
- cd1006f transformer/async-generator-functions: Do not transform yield
expression where inside generator function (#7134 ) (Dunqing)
- 2c5734d transformer/async-generator-functions: Do not transform await
expression where inside ArrowFunctionExpression (#7132 ) (Dunqing)
- 5ce83bd transformer/async-generator-functions: Remove dead code for
handle await expression (#7131 ) (Dunqing)
- e04ee97 transformer/async-generator-functions: Move handling of
`MethodDefinition`'s value to `exit_function` (#7106 ) (Dunqing)
- b57d5a5 transformer/async-to-generator: Remove unused `&self` function
param (#7166 ) (overlookmotel)
- f80085c transformer/async-to-generator: Move handling of
`MethodDefinition`'s value to `exit_function` (#7105 ) (Dunqing)
- e2241e6 transformer/jsx-self: Remove unused `&self` function params
(#7159 ) (overlookmotel)
- 1dfd241 transformer/optional-catch-binding: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7158 ) (overlookmotel)
- fd9b44c transformer/typescript: Remove inactive
`#[allow(clippy::unused_self)]` attr (#7160 ) (overlookmotel)
- cacfb9b traverse: Use `symbol_id` etc methods (#7129 ) (overlookmotel)
### Styling
- 38a6df6 transformer/arrow-functions: Semicolon after return statements
(#7168 ) (overlookmotel)
- 64b7e3a transformer/async-generator-functions: Import
`oxc_allocator::Vec` as `ArenaVec` (#7173 ) (overlookmotel)
### Testing
- be819dd napi/transform: Add test for not default es transform (Boshen)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-11-10 00:31:14 +08:00
7086cmd
a2977655c8
refactor(minifier): use map and and_then instead of let else ( #7178 )
...
For the test case, Closure Compiler doesn't handle this at all in the REPL! If it's necessary, I will turn it back.
This PR uses builtin `and_then` and `map` method, which is better instead of a lot of `if let Some`.
2024-11-09 11:48:48 +00:00
oxc-bot
12a6952782
release(crates): v0.35.0 ( #7110 )
...
## [0.35.0] - 2024-11-04
- f543a8d ast: [**BREAKING**] Remove `AstBuilder::*_from_*` methods
(#7073 ) (overlookmotel)
- b8daab3 transformer: [**BREAKING**] API to `TryFrom<&EnvOptions> for
TransformOptions` and `TryFrom<&BabelOptions> TransformOptions` (#7020 )
(Boshen)
- 9a6a2f9 semantic: [**BREAKING**] Remove
`SymbolTable::get_symbol_id_from_span` API (#6955 ) (Boshen)
### Features
- 854870e ast: Label AST fields with #[ts] (#6987 ) (ottomated)
- ce5b609 ast: Remove explicit untagged marker on enums (#6915 )
(ottomated)
- 9725e3c ast_tools: Add #[estree(always_flatten)] to Span (#6935 )
(ottomated)
- fbc297e ast_tools: Move tsify custom types to estree attribute macro
(#6934 ) (ottomated)
- 169fa22 ast_tools: Default enums to rename_all = "camelCase" (#6933 )
(ottomated)
- caa4b1f codegen: Improve printing of comments (#7108 ) (Boshen)
- 001058a codegen: Always print legal comments on its own line (#7089 )
(Boshen)
- 413973d codegen: Print linked and external legal comment (#7059 )
(Boshen)
- ee27b92 codegen: Print eof legal comments (#7058 ) (Boshen)
- 6516f9e codegen: Print inline legal comments (#7054 ) (Boshen)
- 1e2f012 linter: Add `oxc/no-map-spread` (#6751 ) (DonIsaac)
- 6d97af4 rust: Use `oxc-miette` (#6938 ) (Boshen)
- bfdbcf1 transformer: Add `EnvOptions::from_browerslist_query` API
(#7098 ) (Boshen)
- 21b8e49 transformer: Add `ESTarget` (#7091 ) (Boshen)
- fcaba4a transformer: Add `TransformerOptions::env` with `EnvOptions`
(#7037 ) (Boshen)
- 1d906c6 transformer: Class properties transform skeleton (#7038 )
(overlookmotel)
- 934cb5e transformer: Add `async_generator_functions` plugin (#6573 )
(Dunqing)
### Bug Fixes
- 0601271 ast: Fix `StaticMemberExpression.get_first_object` (#6969 )
(tomoya yanagibashi)
- da199c7 ecmascript: Allow getting PropName for object methods (#6967 )
(camchenry)
- f5a7134 linter/no-unused-vars: False positive for discarded reads
within sequences (#6907 ) (DonIsaac)
- 9ed9501 module_lexer: Add missing `export * from 'foo';` case (#7103 )
(Boshen)
- d15e408 napi/transform: Fix 'typescript.declaration' option not
working (#7012 ) (Boshen)
- dcdb9ea napi/transform: Fix test (Boshen)
- caaf00e parser: Fix incorrect parsed `TSIndexSignature` (#7016 )
(Boshen)
- b188b4a transformer: Fix typescript globals being recognized as
globals (#7100 ) (Boshen)
- a2244ff transformer/async-to-generator: Output is incorrect when arrow
function without params (#7052 ) (Dunqing)
- 7d12669 types: Move @oxc-project/types to dependencies (#6909 )
(ottomated)
### Performance
- 6ca01b9 ast: Reduce size of `Comment` (#6921 ) (overlookmotel)
- c58ec89 data_structures: Optimize `NonEmptyStack::pop` (#7021 )
(overlookmotel)
- fa9a4ec parser: Check `.` before `[` in `parse_member_expression_rest`
(#6979 ) (Boshen)
### Refactor
- b0211a1 ast: `StaticMemberExpression::get_first_object` use loop
instead of recursion (#7065 ) (overlookmotel)
- fc07458 ast: Move custom types `.d.ts` file (#6931 ) (overlookmotel)
- c41c013 ast: Rename lifetime (#6922 ) (overlookmotel)
- 335eb38 ast_tools: Faster formatting Rust code (#6972 ) (overlookmotel)
- 4cf0085 ast_tools: Reorder imports in generated code (#6926 )
(overlookmotel)
- dd79c1b codegen: Replace `daachorse` with string match for annotation
comment (#7064 ) (Boshen)
- 0bb1aa4 codegen: Move options to its own file (#7053 ) (Boshen)
- b021147 data_structures: Make all methods of `NonNull` shim
`#[inline(always)]` (#7024 ) (overlookmotel)
- fb1710a data_structures: Add `#[repr(transparent)]` to `NonNull` shim
(#7023 ) (overlookmotel)
- f1fc8db data_structures: Add `read` method to `NonNull` shim (#7022 )
(overlookmotel)
- cea0e6b isolated_declarations: Do not use `AstBuilder::*_from_*`
methods (#7071 ) (overlookmotel)
- 97caae1 minifier: Do not use `AstBuilder::*_from_*` methods (#7072 )
(overlookmotel)
- 2c7ac29 minifier: Remove `Tri`, use `Option<bool>` instead (#6912 )
(Boshen)
- 9926990 napi: Move custom types to bottom of file (#6930 )
(overlookmotel)
- 23157bd napi: Types file in root of types package (#6929 )
(overlookmotel)
- 953b051 parser: Remove `oxc_ecmascript` crate (#7109 ) (Boshen)
- fdd480d parser: Do not use `AstBuilder::*_from_*` methods (#7068 )
(overlookmotel)
- 9e85b10 parser: Add `ParserImpl::alloc` method (#7063 ) (overlookmotel)
- 17a938e parser: Use function `parse_type_member_semicolon` (#7018 )
(Boshen)
- aa1b29c parser: Remove `parse_ts_index_signature_member` function
(#7017 ) (Boshen)
- 7f1d1fe transform: Deserialize `BabelPreests::env` directly (#7051 )
(Boshen)
- 76947e2 transform: Refactor Babel Targets (#7026 ) (Boshen)
- d03e622 transformer: Do not use `AstBuilder::*_from_*` methods (#7070 )
(overlookmotel)
- 9d384ad transformer: Use `identifier_reference_with_reference_id`
builder method (#7056 ) (overlookmotel)
- 4688a06 transformer: Use `*_with_scope_id` builder methods where
possible (#7055 ) (overlookmotel)
- 7122e00 transformer: Use `ctx.alloc` over `ctx.ast.alloc` where
possible (#7066 ) (overlookmotel)
- a3b68b4 transformer: Flatten dir structure of options/babel/env
(#7049 ) (Boshen)
- 6d92f36 transformer: Deserialize `BabelOptions::compiler_assumptions`
(#7048 ) (Boshen)
- f83a760 transformer: Deserialize `BabelOptions::presets` (#7047 )
(Boshen)
- 52c20d6 transformer: Deserialize `BabelOptions::plugins` (#7045 )
(Boshen)
- e921df6 transformer: Rename `EnvOptions` to `BabelEnvOptions` (#7036 )
(Boshen)
- af5140f transformer: Isolate babel options logic (#7034 ) (Boshen)
- 12aa910 transformer: Clean up `env/targets/query.rs` (#7033 ) (Boshen)
- 3d174bb transformer: Clean up `BabelOptions` (#7029 ) (Boshen)
- 6284f84 transformer: Use `Browserslist::Version` (#7028 ) (Boshen)
- 5b11cdf transformer: Clean up TransformerOptions (#7005 ) (Boshen)
- f0c87d4 transformer: Mark all EnvOptions as not implemented (#7004 )
(Boshen)
- d9edef6 transformer: Combine ObjectRestSpread into a single file
(#7002 ) (Boshen)
- c945fe7 transformer: Import `oxc_allocator::Box` as `ArenaBox` (#6999 )
(overlookmotel)
- fc1af2e transformer: Import `oxc_allocator::Vec` as `ArenaVec` (#6998 )
(overlookmotel)
- 63e8bfe transformer: Rename `AString` to `ArenaString` (#6997 )
(overlookmotel)
- 562bb9a transformer/async-to-generator: Move transform methods to
`AsyncGeneratorExecutor` and make it public (#6992 ) (Dunqing)
- e23f7e6 transformer/common: `VarDeclarations` insert either `var` or
`let` statements (#7043 ) (overlookmotel)
- e5ecbb9 transformer/jsx: Return `&mut T` not `&mut ArenaBox<T>`
(#7001 ) (overlookmotel)
- 9e66c29 transformer/react-refresh: Small refactor (#6973 )
(overlookmotel)
- 1ca8cd2 transformer/react-refresh: Avoid panic for `init` of
`VariableDeclarator` isn't a `BindingIdentifier` (#6937 ) (Dunqing)
- 5f153ac transformer/react-refresh: Use `VarDeclarations` to insert
declarators (#6884 ) (Dunqing)
- df3b089 transformer/react-refresh: Use `StatementInjector` to insert
statements (#6881 ) (Dunqing)
- ae22671 transformer/typescript: Pass `&mut T` not `&mut ArenaBox<T>`
(#7000 ) (overlookmotel)
- 938ee87 traverse: Do not use `AstBuilder::*_from_*` methods (#7069 )
(overlookmotel)
### Styling
- 86ab091 transformer/common: Split up `StatementInjectorStore` methods
into blocks (#7042 ) (overlookmotel)
### Testing
- 64e2499 module_lexer: Use a single integration test for faster
compilation (#7097 ) (Boshen)
- 6133a50 transformer: Use a single integration test for faster
compilation (#7099 ) (Boshen)
---------
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-04 17:40:05 +08:00
overlookmotel
97caae16e2
refactor(minifier): do not use AstBuilder::*_from_* methods ( #7072 )
...
Preparation for #7073 . Avoid using `AstBuilder::*_from_*` methods to construct enums, use explicit construction instead.
Before:
```rs
let ident = self.ast.binding_pattern_kind_from_binding_identifier(ident);
```
After:
```rs
let ident = BindingPatternKind::BindingIdentifier(ident);
```
Often this produces shorter code, as well as (in my opinion) being easier to read.
2024-11-02 01:22:56 +00:00
Boshen
2c7ac29ece
refactor(minifier): remove Tri, use Option<bool> instead ( #6912 )
2024-10-26 04:28:34 +00:00
oxc-bot
238e0866cb
release(crates): v0.34.0 ( #6908 )
...
## [0.34.0] - 2024-10-26
- 4618aa2 transformer: [**BREAKING**] Rename `TransformerOptions::react`
to `jsx` (#6888 ) (Boshen)
- 90c786c regular_expression: [**BREAKING**] Support ES2025 Duplicated
named capture groups (#6847 ) (leaysgur)
- 67a7bde napi/parser: [**BREAKING**] Add typings to napi/parser (#6796 )
(ottomated)
### Features
- 1145341 ast_tools: Output typescript to a separate package (#6755 )
(ottomated)
- 4429754 ecmascript: Constant eval `null` to number (#6879 ) (Boshen)
- fd57e00 ecmascript: Add abstract_relational_comparison to dce (#6846 )
(Boshen)
- 8bcaf59 minifier: Late peeophole optimization (#6882 ) (Boshen)
- 860cbca minifier: Implement folding simple arrow fns (#6875 ) (camc314)
- c26020e minifier: Implement folding String.prototype.replaceAll
(#6871 ) (camc314)
- 50744f3 minifier: Implement folding String.prototype.replace (#6870 )
(camc314)
- fccf82e minifier: Implement folding `substring` string fns (#6869 )
(camc314)
- e6a5a1b minifier: Implement folding `charCodeAt` string fns (#6475 )
(camc314)
- 0d0bb17 transformer: Complete the async-to-generator plugin (#6658 )
(Dunqing)
- 419343b traverse: Implement `GetAddress` for `Ancestor` (#6877 )
(overlookmotel)
### Bug Fixes
- a47c70e minifier: Fix remaining runtime bugs (#6855 ) (Boshen)
- 686727f minifier: Reference read has side effect (#6851 ) (Boshen)
- c658d93 minifier: Keep template literals with expressions (#6849 )
(Boshen)
- 4dc5e51 transformer: Only run typescript plugin for typescript source
(#6889 ) (Boshen)
- 076f5c3 transformer/typescript: Retain ExportNamedDeclaration without
specifiers and declaration (#6848 ) (Dunqing)
- b075982 types: Change @oxc/types package name (#6874 ) (ottomated)
### Documentation
- 6eeb0e6 ast: Mention typescript-eslint, field ordering and shape
(#6863 ) (Boshen)
- 99e3b32 napi: Remove JSON.parse from example (#6836 ) (ottomated)
### Refactor
- adb5039 allocator: Add `impl GetAddress for Address` (#6891 )
(overlookmotel)
- 3e7507f ast_tools: Reduce macro usage (#6895 ) (overlookmotel)
- 423d54c rust: Remove the annoying `clippy::wildcard_imports` (#6860 )
(Boshen)
- 2d95009 transformer: Implement `Debug` on `StatementInjector` internal
types (#6886 ) (overlookmotel)
- c383c34 transformer: Make `StatementInjectorStore` methods generic
over `GetAddress` (#6885 ) (overlookmotel)
- 1f29523 transformer: Rename ReactJsx to Jsx (#6883 ) (Boshen)
- 333b758 transformer: `StatementInjectorStore` methods take
`&Statement` as target (#6858 ) (overlookmotel)
- c19996c transformer: Add `StatementInjectorStore::insert_many_before`
method (#6857 ) (overlookmotel)
- 7339dde transformer: `StatementInjectorStore::insert_many_after` take
an iterator (#6856 ) (overlookmotel)
- 4348eae transformer/typescript: Re-order visitor methods (#6864 )
(overlookmotel)
- 3a56d59 transformer/typescript: Insert assignments after super by
`StatementInjector` (#6654 ) (Dunqing)
- a366fae traverse: Rename
`TraverseScoping::generate_binding_in_current_scope` (#6832 )
(overlookmotel)
- 3b99fe6 traverse: Move `generate_binding` to `TraverseScoping` (#6831 )
(overlookmotel)
- 60f487a traverse: `TraverseCtx::generate_binding` take an `Atom`
(#6830 ) (overlookmotel)
### Styling
- 262b2ed ast: Move crate doc comment to top of file (#6890 )
(overlookmotel)
---------
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-26 09:39:53 +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
Boshen
8bcaf59cf9
feat(minifier): late peeophole optimization ( #6882 )
2024-10-25 16:12:29 +00:00
camc314
860cbca446
feat(minifier): implement folding simple arrow fns ( #6875 )
...
basically
```ts
const foo = () => {
return baz
}
```
becomes
```ts
const foo = () => baz
```
2024-10-25 10:26:33 +00:00
Boshen
442975408b
feat(ecmascript): constant eval null to number ( #6879 )
2024-10-25 04:23:24 +00:00
camc314
c26020e553
feat(minifier): implement folding String.prototype.replaceAll ( #6871 )
2024-10-25 01:29:57 +00:00
camc314
50744f341b
feat(minifier): implement folding String.prototype.replace ( #6870 )
2024-10-25 01:29:57 +00:00
camc314
fccf82e4df
feat(minifier): implement folding substring string fns ( #6869 )
2024-10-25 01:29:56 +00:00
camc314
322f9d44b7
chore(minifier): remove planned minification for String.substr as its deprecated ( #6868 )
...
According to mdn, `String.prototype.substr()` has been deprecated, hence i do not think it makes sense to attempt to optimize this code.
This pull request removes the test cases along with the placeholder code for minification of this method
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
2024-10-24 14:53:22 +00:00
camc314
e6a5a1b11c
feat(minifier): implement folding charCodeAt string fns ( #6475 )
2024-10-24 14:37:50 +00:00
Boshen
423d54cb74
refactor(rust): remove the annoying clippy::wildcard_imports ( #6860 )
2024-10-24 13:57:19 +00:00
Boshen
a47c70e425
fix(minifier): fix remaining runtime bugs ( #6855 )
2024-10-24 12:22:18 +00:00
Boshen
686727fc96
fix(minifier): reference read has side effect ( #6851 )
2024-10-24 08:32:38 +00:00
Boshen
c658d9336d
fix(minifier): keep template literals with expressions ( #6849 )
2024-10-24 08:12:44 +00:00
Boshen
fd57e00108
feat(ecmascript): add abstract_relational_comparison to dce ( #6846 )
...
I removed bigint comparisons because they were incorrect
2024-10-24 06:46:07 +00:00
oxc-bot
8f392e828e
release(crates): v0.33.0 ( #6843 )
2024-10-24 10:29:22 +08:00
Boshen
ca799936b0
fix(minifier): do not dce object literals yet ( #6839 )
...
closes #6769
2024-10-24 01:05:07 +00:00
Boshen
ec5a19b880
fix(minifier): do not remove binary expressions ( #6829 )
2024-10-23 16:07:29 +00:00
Boshen
22355f73f3
fix(minifier): do not remove undefined for destructuring patterns ( #6828 )
2024-10-23 15:42:04 +00:00
Boshen
2f6ad42348
fix(codegen): print negative bigint 1n- -1n correctly after constant folding ( #6798 )
...
closes #6767
2024-10-23 04:56:50 +00:00
camc314
b4bc300ebf
feat(minifier): improve folding block stmts ( #6793 )
2024-10-23 04:13:58 +00:00