Commit graph

70 commits

Author SHA1 Message Date
Boshen
f3a21a28d7
chore: do not compile test crates that have no tests 2024-06-24 00:20:04 +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
982e6f08df chore: make println and eprintln opt-in (#3712)
I noticed accidental `println` can be merged, which isn't really nice.
2024-06-17 10:40:34 +00:00
Boshen
b58d8eb88f fix!(codegen): remove the unecessary 4th argument from Codegen::new (#3640) 2024-06-12 07:58:54 +00:00
Boshen
d77ec9f95a
chore: remove trailing whitespaces for all files; add .editorconfig (#3639) 2024-06-12 15:47:26 +08:00
IWANABETHATGUY
0cdb45a1ff
feat(oxc_codegen): preserve annotate comment (#3465)
1. Copy tests from
efa3dd2d8e/internal/bundler_tests/bundler_dce_test.go (L3833-L3971)
2. Add option to preserve annotate comment like `/* #__NO_SIDE_EFFECTS__
*/` and `/* #__PURE__ */`
2024-05-30 15:25:23 +08:00
Boshen
f366d9bd7c
chore(minsize): remove brotlic because it takes too long to compile (#2954) 2024-04-13 13:24:25 +08:00
Boshen
95fc28168c
chore: apply cargo autoinherit (#2826)
See https://github.com/mainmatter/cargo-autoinherit
2024-03-26 23:57:50 +08:00
underfin
d9b77d853b
refactor(sourcemap): change sourcemap name to take a reference (#2779) 2024-03-23 21:40:05 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps (#2602)
closes #2564
2024-03-04 16:03:33 +08:00
Andrew McClenaghan
e6d536cb9b
feat(codegen): configurable typescript codegen (#2443)
- Adds option to `CodegenOptions` - `enable_typescript` to enable output
of TS.
- Stops skipping output that is TS when `enable_typescript` is enabled
- Adds TS support to 
    - Function
    - FormalParameter
    - BindingPattern
 - Adds basic tests for TS generation

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-02-20 12:09:28 +08:00
Boshen
70a0076eed
refactor: remove global allocator from non-user facing apps (#2401)
The runtime performance gains does not out weight the compilation speed from
building the custom allocators, which takes about a minute to build on
slower machines.
2024-02-12 14:09:05 +08:00
renovate[bot]
4b83d97c3b
chore(deps): update cargo (#2191) 2024-01-29 11:38:47 +08:00
Boshen
1a576f60a8
refactor(rust): move to workspace lint table (#1444) 2023-11-20 14:38:10 +08:00
Boshen
73d6d40778
rust: do not compile libs and bins that do not have tests (#1342) 2023-11-16 13:35:24 +08:00
Boshen
801d78a3c6
refactor(minifier): make the minifier api only accept an ast (#990) 2023-10-14 00:51:29 +08:00
Boshen
8c12dff8a3
perf: speed tasks run by using a global allocator 2023-10-11 20:30:30 +08:00
Boshen
c38a00b453
chore(minsize): disable the test as it is broken right now 2023-10-10 15:53:55 +08:00
Boshen
ef8aaa7bf1
feat(minifier): re-enable mangler (#972) 2023-10-10 14:32:58 +08:00
Boshen
817f8c295e
ci: turn off doc tests because they are slow to compile and run (#961) 2023-10-07 17:01:23 +08:00
Don Isaac
027a67d94c
feat(minifier): constant addition expression folding (#882)
Fold constant addition expressions. Handles string concatenation and
addition, both with implicit casting.

For example,
```ts
let x = 1 + 1
let y = "hello " + "world"
```
now becomes
```ts
let x = 2
let y = "hello world"
```

## Extra Goodies
- test(minifier): add `test_snapshot` helper to perform snapshot tests
with `insta`
- up(hir): implement `std::ops::Add` for `NumericValue`
- up(span): impl `TryFrom<Cow<'_, &str>>` for `Atom`
2023-09-11 10:38:35 +08:00
Don Isaac
fd899be4a9
feat(minifier): compress undefined variable declarations (#532) 2023-07-10 10:33:42 +08:00
Wenzhe Wang
a32320646d
feat(minfier): try fold and or operator (#472) 2023-06-28 14:58:55 +08:00
阿良仔
1182985bb0
feat(minifier): implement try_fold_shift (#478)
* feat: implement `try_fold_shift`

* update minsize
2023-06-27 04:44:23 +08:00
Wenzhe Wang
cb94937ba6
feat(minifier): fold string string comparison (#471) 2023-06-26 22:37:50 +08:00
Wenzhe Wang
b8f5e3ad92
feat(minifier): try reduce void (#457) 2023-06-23 00:10:46 +08:00
Boshen
d30735677b
refactor(semantic): merge semantic2 crate into semantic crate (#460) 2023-06-19 20:20:59 +08:00
Wenzhe Wang
5d10f96051
feat(minifier): try fold unary expression (#430) 2023-06-16 00:08:14 +08:00
u9g
db624da84d
Reimplement more of the closure var rename step (#447)
Co-authored-by: Boshen <boshenc@gmail.com>

closes #442
2023-06-15 23:37:04 +08:00
Boshen
a79480b078
feat(minifier): separate mangler pass (#439) 2023-06-14 10:46:13 +08:00
Boshen
5c91fd54e3
feat(minifier): print [-In] Context (#428) 2023-06-11 16:44:48 +08:00
Wenzhe Wang
7c79fbc026
feat(minifier): try fold typeof (#408) 2023-06-07 10:44:28 +08:00
Wenzhe Wang
ddc129262d
feat(minifer): minify number (#405) 2023-06-03 21:24:39 +08:00
Boshen
f8125af850 feat(minimizer): print parentheses 2023-06-01 22:45:26 +08:00
Wenzhe Wang
4109c8b8a5
feat(parser): distinguish exponential number (#399) 2023-06-01 15:15:22 +08:00
Wenzhe Wang
a20d5b55cd
feat(minifier): may add space before binaryOperator (#380) 2023-05-27 19:18:06 +08:00
Wenzhe Wang
a0b9628177
feat(minifer): distinguish-op-lessthan (#391) 2023-05-27 17:04:54 +08:00
Boshen
829f945479
chore(minifier): add a few passing tests 2023-05-27 12:27:25 +08:00
Boshen
8ea9e38ee5
feat(minifier): remove redundant curly braces from block statements (#390) 2023-05-27 10:52:15 +08:00
Boshen
ee6f18091b
chore(minsize): add newlines in between for better diff 2023-05-25 22:42:11 +08:00
Boshen
c4a67b6cfb
feat(minifier): fold return undefined to return (#387) 2023-05-25 22:37:55 +08:00
Boshen
a31c7ac77a
refactor(index): use static_assertions 2023-05-24 22:53:11 +08:00
Boshen
f5b57944e2
feat(minifier): print shorter numbers (#381) 2023-05-24 22:03:50 +08:00
Yoni Feng
c1d1846714
Add Brotli size to minsize task output (#377) 2023-05-23 17:00:49 +08:00
Boshen
dee09da60b
feat(minifier): implement peephole reorder constant expression from closure compiler (#376) 2023-05-23 12:29:29 +08:00
Boshen
827cef3311
chore(minsize): use default version of flate2 (removes 2 extra dependencies) 2023-05-23 00:32:00 +08:00
Boshen
42dd639e74
chore(minsize): update snapshot 2023-05-22 12:29:52 +08:00
Boshen
009fc5f285
feat(minifier): minify Infinity 2023-05-21 22:01:47 +08:00
Boshen
f8828db68c
feat(semantic2): slot based mangler (#364) 2023-05-20 19:00:57 +08:00