Boshen
2b2a37347c
feat(minifier): minimize a + 'b' + 'c' -> a + 'bc' ( #8137 )
2024-12-27 05:46:51 +00:00
Boshen
213364a400
feat(minifier): minimize if (x) if (y) z -> if (x && y) z ( #8136 )
2024-12-27 02:44:47 +00:00
Boshen
ad61e70186
fix(codegen): print if else without block with proper indentation ( #8135 )
2024-12-27 00:39:52 +00:00
Boshen
6b51e6dff1
feat(minifier): minimize if(foo) bar else baz -> foo ? bar : baz ( #8133 )
2024-12-26 16:21:34 +00:00
Boshen
f615bfa773
feat(minifier): minimize if (x) return; return 1 -> return x ? void 0 : 1 ( #8130 )
2024-12-26 15:36:25 +00:00
Yuichiro Yamashita
04c7d38287
chore(semantic): use assert_eq! instead of assert! (crates/oxc_semantic/src/scope.rs) ( #8128 )
...
related to https://github.com/oxc-project/oxc/pull/8124
2024-12-26 22:14:33 +08:00
Yuichiro Yamashita
eb0f57f40f
chore(semantic): use assert_eq! instead of assert! (crates/oxc_semantic/src/lib.rs) ( #8127 )
...
related to https://github.com/oxc-project/oxc/pull/8124
2024-12-26 13:54:21 +00:00
Yuichiro Yamashita
e676fdfd83
chore(tasks): use assert_eq! instead of assert! (tasks/minsize/src/lib.rs) ( #8129 )
...
related to https://github.com/oxc-project/oxc/pull/8124
2024-12-26 13:54:05 +00:00
Yuichiro Yamashita
093ddd6f4d
chore(ast): use assert_eq! instead of assert! (crates/oxc_ast/src/lib.rs) ( #8125 )
...
related to https://github.com/oxc-project/oxc/pull/8124
2024-12-26 13:52:55 +00:00
Yuichiro Yamashita
777e13c534
chore(linter): use assert_eq! instead of assert! ( #8124 )
...
This ensures that both the expected and actual values are printed in the
log when the test fails.
2024-12-26 20:21:01 +08:00
Boshen
f0b1ee5a06
feat(minifier): minimize if(!x) foo() -> x || foo() ( #8122 )
2024-12-26 09:42:34 +00:00
Boshen
f8200a8882
feat(minifier): minimize if(foo) bar -> foo && bar ( #8121 )
2024-12-26 09:01:38 +00:00
Boshen
72d996709e
feat(minifier): add Normalize ast pass ( #8120 )
2024-12-26 07:02:45 +00:00
Boshen
fef0b25fd3
feat(minifier): collapse var into for loop initializer ( #8119 )
...
`var a = 0; for(;a<0;a++) {}` => `for(var a = 0;a<0;a++) {}`
2024-12-26 05:22:02 +00:00
Boshen
c22062bab3
refactor(minifier): cleanup peephole_minimize_conditions ( #8114 )
2024-12-25 15:47:42 +00:00
Boshen
2331ea85d9
feat(minifier): typeof foo === 'number' => typeof foo == 'number' ( #8112 )
2024-12-25 14:52:58 +00:00
Boshen
e594c3988d
refactor(minifier): clean up peephole_substitute_alternate_syntax.rs ( #8111 )
2024-12-25 13:54:51 +00:00
oxc-bot
5a1311e76c
release(crates): v0.44.0 ( #8110 )
...
## [0.44.0] - 2024-12-25
- ad2a620 ast: [**BREAKING**] Add missing
`AssignmentTargetProperty::computed` (#8097 ) (Boshen)
### Features
- c2daa20 ast: Add `Expression::into_inner_expression` (#8048 )
(overlookmotel)
- 618b6aa codege: Minify whitespace in object getter / setter (#8080 )
(Boshen)
- 4727667 codegen: Minify arrow expr `(x) => y` -> `x => y` (#8078 )
(Boshen)
- 0562830 codegen: Minify string with backtick when needed (#8095 )
(Boshen)
- 6237c05 codegen: Minify more whitespace (#8089 ) (Boshen)
- 6355b7c codegen: Minify `export { 's' as 's' }` -> `export { 's' }`
(#8093 ) (Boshen)
- fccfda9 codegen: Minify `class{static[computed]}` (#8088 ) (Boshen)
- f873139 codegen: Minify `for (_ of [])` -> `for(_ of[])` (#8086 )
(Boshen)
- 8b8cbcd codegen: Minify `case "foo"` -> `case"foo"` (#8085 ) (Boshen)
- 414c118 codegen: Minify `yield "s"` -> `yield"s"` (#8084 ) (Boshen)
- f8f067b codegen: Minify class method `async*fn(){}` (#8083 ) (Boshen)
- 1d5ae81 codegen: Minify `const [foo] = bar` -> `const[foo]=bar`
(#8079 ) (Boshen)
- e3f78fb codegen: `new Foo()` -> `new Foo` when minify (#8077 ) (Boshen)
- d84d60a codegen: Minify numbers with large exponents (#8074 ) (Boshen)
- 373279b codegen: Balance string quotes when minify whitespace (#8072 )
(Boshen)
- 5397fe9 minifier: Constant fold `undefined?.bar` -> `undefined`
(#8075 ) (Boshen)
- 1932f1e minifier: Fold `foo === undefined || foo === null` (#8063 ) (翠
/ green)
- 11c4bd8 span: Implement source type `{file basename}.d.{extension}.ts`
(#8109 ) (Boshen)
- be4feb4 syntax: Add `SymbolId::new` method (#8041 ) (overlookmotel)
- e632a7b transformer: Remove typescript symbols after transform (#8069 )
(Boshen)
### Bug Fixes
- bdc241d codegen: Disallow template literals in object property key
(#8108 ) (Boshen)
- 728ed20 codegen: Print `yield * ident` correctly (Boshen)
- b605baa minifier: Constant fold strings with tab char (#8096 ) (Boshen)
- de82492 parser: Report syntax errors for missing constructor
implementations (#8081 ) (camc314)
- 55d6eb9 parser: Disallow type parameters on class constructors (#8071 )
(injuly)
- be2c60d parser: Parse `import source from from 'mod'` (#8056 ) (Boshen)
- 708e9cf semantic: Report errors for missing class method impls (#8082 )
(camc314)
- 3057686 transformer/class-properties: Unwrap parenthesised expressions
(#8049 ) (overlookmotel)
- e67cd05 transformer/class-properties: Correctly resolve private fields
pointing to private accessors (#8047 ) (overlookmotel)
- 6b08c6e transformer/class-properties: Correctly resolve private fields
pointing to private methods (#8042 ) (overlookmotel)
- 274f117 transformer/nullish-coalescing: Use correct scope id for
binding (#8053 ) (camc314)
### Performance
- 78d2e83 sourcemap: Improve perf of `search_original_line_and_column`
(#7926 ) (Cameron)
### Refactor
- 7110c7b codegen: Add `print_quoted_utf16` and `print_unquoted_utf16`
methods (#8107 ) (Boshen)
- 8b54d89 minifier: Remove parens must happen on enter (#8060 ) (Boshen)
- 7cb84f3 minifier: Only minify on ast node exit (#8059 ) (Boshen)
- 77d845a minifier: Fuse DCE AST passes (#8058 ) (Boshen)
- 6123f5e minifier: Fold statements on exit (#8057 ) (Boshen)
- cbd5169 transformer/class-properties: Do not recreate private field if
not transforming it (#8044 ) (overlookmotel)
- 98e8a72 transformer/class-properties: Do not take mut ref when immut
ref will do (#8040 ) (overlookmotel)
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-25 21:03:09 +08:00
Boshen
11c4bd8687
feat(span): implement source type {file basename}.d.{extension}.ts ( #8109 )
2024-12-25 12:24:34 +00:00
camc314
708e9cfac0
fix(semantic): report errors for missing class method impls ( #8082 )
2024-12-25 12:24:33 +00:00
camc314
de82492e97
fix(parser): report syntax errors for missing constructor implementations ( #8081 )
2024-12-25 12:24:32 +00:00
Boshen
bdc241d41d
fix(codegen): disallow template literals in object property key ( #8108 )
2024-12-25 11:22:54 +00:00
Boshen
7110c7b94c
refactor(codegen): add print_quoted_utf16 and print_unquoted_utf16 methods ( #8107 )
2024-12-25 09:19:55 +00:00
Boshen
47276679f5
feat(codegen): minify arrow expr (x) => y -> x => y ( #8078 )
2024-12-24 14:25:01 +00:00
Boshen
728ed20c1c
fix(codegen): print yield * ident correctly
2024-12-24 21:57:58 +08:00
Boshen
0562830549
feat(codegen): minify string with backtick when needed ( #8095 )
2024-12-24 13:39:31 +00:00
Boshen
ad2a620d61
fix(ast)!: add missing AssignmentTargetProperty::computed ( #8097 )
2024-12-24 13:27:00 +00:00
Boshen
b605baa4ac
fix(minifier): constant fold strings with tab char ( #8096 )
2024-12-24 12:15:06 +00:00
dalaoshu
6bd9ddb8b9
fix(linter): false positive in typescript/ban-tslint-comment ( #8094 )
...
closes #8090
2024-12-24 19:18:41 +08:00
Boshen
6237c0527f
feat(codegen): minify more whitespace ( #8089 )
2024-12-24 09:54:13 +00:00
Boshen
6355b7ca70
feat(codegen): minify export { 's' as 's' } -> export { 's' } ( #8093 )
2024-12-24 09:17:51 +00:00
Boshen
fccfda91c1
feat(codegen): minify class{static[computed]} ( #8088 )
2024-12-24 05:06:57 +00:00
Boshen
f873139a0f
feat(codegen): minify for (_ of []) -> for(_ of[]) ( #8086 )
2024-12-24 04:17:50 +00:00
Boshen
8b8cbcd2db
feat(codegen): minify case "foo" -> case"foo" ( #8085 )
2024-12-24 01:07:58 +00:00
Boshen
414c118309
feat(codegen): minify yield "s" -> yield"s" ( #8084 )
2024-12-24 00:41:28 +00:00
Boshen
f8f067bfc6
feat(codegen): minify class method async*fn(){} ( #8083 )
2024-12-24 00:35:29 +00:00
injuly
55d6eb9507
fix(parser): disallow type parameters on class constructors ( #8071 )
...
TypeScript does not allow type parameters on constructors:
```ts
class A {
constructor<T>(t: T) {} // <- should be an error
}
```
Here's a comparison snippet on:
1. [TypeScript
playground](https://www.typescriptlang.org/play/?#code/MYGwhgzhAECC0G8BQ1XWAewHYQC4CcBXYXDfAHlgD4AKASkSRTQF8kWg )
(syntax error).
2. [SWC
playground](https://play.swc.rs/?version=1.10.1&code=H4sIAAAAAAAAA0vOSSwuVnBWqOZSUEjOzysuKSpNLskvsgmx09BUqFao5aoFAOf92%2FAiAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D )
(syntax error)
3. [OXC
playground](https://playground.oxc.rs/#eNo9T8EKwjAM/ZWSk8IOKngpInjxCzx66Wo2Cl0zkk4do/9u6+guyXshL+9lAQsarDci6qaWZ1DKUpDIk43El8d1t1+nSpWaniFBAwR6AZ5CaTKHaL6gswQb8C7EisXSiBuZh5Z8ZZFNkI54AN0ZL5gaGA0Lcr6YcblS8bb6H0A03GO2AJTT4XiGvGHphT2WMJkMLrjOVXH+JTL5u6dPEb+RW5KcaTVN6QerbleM )
(parses as valid syntax)
This PR makes OXC behave exactly like `tsc`, with a little test case.
Happy holidays!
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-24 07:38:39 +08:00
Boshen
618b6aa085
feat(codege): minify whitespace in object getter / setter ( #8080 )
2024-12-23 16:36:03 +00:00
Boshen
1d5ae817d7
feat(codegen): minify const [foo] = bar -> const[foo]=bar ( #8079 )
2024-12-23 16:20:37 +00:00
Boshen
e3f78fba0b
feat(codegen): new Foo() -> new Foo when minify ( #8077 )
2024-12-23 15:34:31 +00:00
Boshen
5397fe978a
feat(minifier): constant fold undefined?.bar -> undefined ( #8075 )
2024-12-23 15:20:37 +00:00
Boshen
d84d60a3a9
feat(codegen): minify numbers with large exponents ( #8074 )
2024-12-23 13:35:52 +00:00
Boshen
373279b7f4
feat(codegen): balance string quotes when minify whitespace ( #8072 )
2024-12-23 13:24:22 +00:00
Boshen
0b04288139
feat(linter): move import/named to nursery ( #8068 )
...
There are race conditions in the runtime which may cause the module to
not find any exports from `exported_bindings_from_star_export`.
2024-12-23 20:29:43 +08:00
Boshen
e632a7b158
feat(transformer): remove typescript symbols after transform ( #8069 )
...
part of #7460
2024-12-23 08:24:54 +00:00
Boshen
8b54d898b5
refactor(minifier): remove parens must happen on enter ( #8060 )
2024-12-23 06:56:36 +00:00
Alexander S.
10a1fd57e5
fix(linter): rule: no-restricted-imports support option patterns with group key ( #8050 )
...
one/two wierd tests are not covered
> This is also an object option whose value is an array. This option
allows you to specify multiple modules to restrict using gitignore-style
patterns or regular expressions.
_https://eslint.org/docs/latest/rules/no-restricted-imports#patterns_
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-23 14:52:38 +08:00
Cameron
78d2e837f0
perf(sourcemap): improve perf of search_original_line_and_column ( #7926 )
...
this seems to show a decent speed up on perf.
the thinking behind this change is:
1. subsequent calls to `search_original_line_and_column` will **never**
look at back at lines it has already searched
2. binary search is faster in this case as typically `idx` is only
increased by a small amount
Given this, we can skip checking a bunch of lines (that will never
return true) improving performance.
This is a very hot path.
```
$ hyperfine --warmup=3 ./target/release-with-debug/examples/sourcemap-main ./target/release-with-debug/examples/sourcemap
Benchmark 1: ./target/release-with-debug/examples/sourcemap-main
Time (mean ± σ): 79.5 ms ± 5.5 ms [User: 65.1 ms, System: 12.2 ms]
Range (min … max): 76.8 ms … 111.7 ms 37 runs
Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.
Benchmark 2: ./target/release-with-debug/examples/sourcemap
Time (mean ± σ): 72.9 ms ± 0.9 ms [User: 59.2 ms, System: 12.2 ms]
Range (min … max): 70.6 ms … 75.0 ms 40 runs
Summary
./target/release-with-debug/examples/sourcemap ran
1.09 ± 0.08 times faster than ./target/release-with-debug/examples/sourcemap-main
```
---------
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2024-12-23 14:51:50 +08:00
underfin
f79e9ad91e
feat(napi/parser): add crate-type: "lib" ( #8067 )
...
The rolldown need export it to instead of `rollup/parseAst`, ref
https://rollupjs.org/javascript-api/#accessing-the-parser
2024-12-23 14:47:19 +08:00
Yuji Sugiura
922670e4b7
feat(prettier): Print directive ( #8066 )
...
Part of #5068
- [x] Directive
2024-12-23 14:46:47 +08:00