Commit graph

337 commits

Author SHA1 Message Date
Boshen
2e2b7587ac
feat(playground): add transform and minify (#993) 2023-10-14 19:49:58 +08:00
Boshen
801d78a3c6
refactor(minifier): make the minifier api only accept an ast (#990) 2023-10-14 00:51:29 +08:00
Boshen
e0ca09b1c9
feat(codegen): implement the basics of non-minifying codegen (#987) 2023-10-13 13:34:21 +08:00
Boshen
efad0fce2d
deps(rust): bump deps 2023-10-12 21:03:17 +08:00
Boshen
ce79bc12ab
feat(transform_conformance): move Formatter to codegen (#986) 2023-10-12 15:13:14 +08:00
Boshen
809f050a5f
feat(codegen): move minifying printer to codegen crate (#985) 2023-10-12 14:56:30 +08:00
Boshen
903854dac0
refactor(ast): fix the lifetime annotations around Vist and VisitMut (#973) 2023-10-10 17:05:48 +08:00
Boshen
ef8aaa7bf1
feat(minifier): re-enable mangler (#972) 2023-10-10 14:32:58 +08:00
Boshen
14e1dacd0a
feat(minifier): reenable minifier tests (#969) 2023-10-09 11:25:29 +08:00
Boshen
f0029d5310 feat(minifier): reenable mangler
closes #952
closes #955
2023-10-09 09:59:14 +08:00
Boshen
55b2f031df
feat(minifier): partially re-enable minifier (#963)
closes #949
closes #950
closes #951

All minifier tests are disable from this PR.

We are going to fix the compilation errors first, then the behavioral
errors.
2023-10-08 11:06:42 +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
Cameron
5b1e1e5408
feat(parser): TypeScript 5.2 (#811)
- adds support for [Using
Declarations](https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#using-declarations-and-explicit-resource-management)

Closes #786
2023-10-05 12:52:14 +13:00
Boshen
38bbc96fb0
Release oxc v0.2.0 2023-09-14 23:41:44 +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
Boshen
93adc9b9c2
Release oxc v0.1.3 2023-09-03 12:22:05 +08:00
Boshen
37bf4c4421
Release oxc v0.1.2 2023-09-03 11:30:44 +08:00
Boshen
1f27426570
Release crates as v0.1.1 2023-08-26 17:53:11 +08:00
Boshen
5152b39b17
chore: clean up Cargo.toml with cargo machete (#767) 2023-08-20 15:29:09 +08:00
Yunfei He
35167599bc
refactor(ast): use atom for Directive and Hashbang (#701)
The main reason is using Atom to remove the lifetime for convenience.

And after removing the lifetime of these nodes, the `Program<'a>`
doesn't rely on `&'a source` anymore, which allows us to [specify more
accurate
lifetimes](https://github.com/web-infra-dev/oxc/discussions/700).
2023-08-09 13:52:56 +08:00
Makoto Tateno
c5ff534b08
feat(semantic): add node_id to Reference (#689)
Closes #685 

Intend to use this in the following ways in #672.
```rs
let node = ctx.nodes().get_node(reference.node_id());
if !self.type_of && has_typeof_operator(node, ctx) {
    return;
}
```
2023-08-05 12:45:22 +08:00
阿良仔
e090b560be
feat(minifier): initialize conditions folding (#658)
related: #401
2023-07-30 01:02:32 +08:00
Boshen
1012d8300c
chore: release crates as v0.1.0 2023-07-27 13:54:17 +08:00
Boshen
d587065436
chore(rust): update crate info, add minimal rust-version, add categories 2023-07-27 13:33:18 +08:00
Boshen
fa82f940f0 chore: stable Rust
closes #626
2023-07-27 13:11:46 +08:00
Boshen
b34ef4f07a chore: reformat 2023-07-27 13:11:46 +08:00
Boshen
f2df32d1c0
fix(taplo): adjust the include glob so it doesn't time out searching for files 2023-07-27 12:30:34 +08:00
Matthew "strager" Glazar
318d55806f refactor: format code
Removing uses of let_chains now allows rustfmt to format some files.
Run 'cargo fmt' to reformat these files.
2023-07-27 09:44:57 +08:00
Matthew "strager" Glazar
ad00720d75 refactor: avoid unstable let_chains
The let_chains Rust feature is unstable, preventing Oxc from using a
stable Rust compiler. Refactor the code to avoid let_chains.
2023-07-27 09:44:57 +08:00
Sg
fbb8aa3338
refactor: remove unstable feature const_trait_impl & const_slice_index & slice_group_by (#629) 2023-07-26 17:37:09 +08:00
Don Isaac
87e65ac0f7
refactor(semantic): symbol declarations and references (#594) 2023-07-24 10:55:56 +08:00
阿良仔
3c76cef11c
feat(minifier): fold NaN comparison (#580) 2023-07-21 11:00:21 +08:00
阿良仔
3cbec3459a
test: add tests for boolean related comparison (#563) 2023-07-17 20:55:42 +08:00
Don Isaac
2591194dba
feat(minifier): drop console statements and exprs (#552) 2023-07-16 14:41:51 +08:00
阿良仔
c09678a48f
test: add tests for null comparison (#548) 2023-07-14 23:25:25 +08:00
Boshen
38e11956be
chore(rust): rust version 1.71.0 nightly 2023-07-13 23:10:10 +08:00
阿良仔
db3ef449fc
test(minifier): add tests for bigint string comparison (#541) 2023-07-13 11:44:03 +08:00
阿良仔
f0495ef924
feat(minifier): fold string number comparison (#538) 2023-07-11 21:50:51 +08:00
阿良仔
2d984f0401
feat(minifier): fold bigint number comparison (#536) 2023-07-10 23:11:28 +08:00
Don Isaac
fd899be4a9
feat(minifier): compress undefined variable declarations (#532) 2023-07-10 10:33:42 +08:00
Boshen
2e32140450
publish: bump all crates to v0.0.7 2023-07-06 14:27:13 +08:00
Boshen
19c68c8c57
chore(Cargo): change how crates are version and published
Let's publish everything under `oxc` instead of individual crates
2023-07-06 14:14:29 +08:00
Boshen
bc0b69e5e7
chore(rust): fix clippy 2023-07-04 16:09:51 +08:00
Wenzhe Wang
9e24dbb0fa
chore(minifier): remove unused param (#494) 2023-06-28 20:21:26 +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
阿良仔
26c3ece37c
feat: handle UnaryOpsWithBigInt (#475) 2023-06-25 22:37:36 +08:00
Wenzhe Wang
b8f5e3ad92
feat(minifier): try reduce void (#457) 2023-06-23 00:10:46 +08:00
Wenzhe Wang
a5ccc7da30
feat(minifier): port undefined_comparison1 (#458) 2023-06-20 22:25:28 +08:00
Boshen
527b94fba6
refactor(hir): use Cell for SymbolId instead of RefCell 2023-06-19 20:23:46 +08:00
Boshen
d30735677b
refactor(semantic): merge semantic2 crate into semantic crate (#460) 2023-06-19 20:20:59 +08:00
Boshen
c4008d8014
perf(manger): use RefCell<SymbolId> instead of roundtrip with BTreeMap (#455) 2023-06-16 21:15:30 +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
Carter Snook
985b8f21d9
feat: support hashbang interpreter comments (#431) 2023-06-11 23:55:58 +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
1a31c76ee9
refactor(minifier): reduce and clean match checks (#406) 2023-06-06 12:46:13 +08:00
Boshen
2bebbb5a77
feat(website): add linter / minifier / formatter to the playground (#407) 2023-06-04 15:30:55 +08:00
Wenzhe Wang
ddc129262d
feat(minifer): minify number (#405) 2023-06-03 21:24:39 +08:00
Boshen
180eac5523
refactor(rust): fix clippy errors 2023-06-02 10:09:32 +08:00
Boshen
f8125af850 feat(minimizer): print parentheses 2023-06-01 22:45:26 +08:00
Yagiz Nizipli
63c0491ec2 refactor: remove paranthesis expression from printer 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
3792b70dbd
feat(minifier): may add space before RegExpLiteral (#397) 2023-05-29 23:11:40 +08:00
Boshen
c01df484db
refactor(hir,syntax): define Precedence for hir expressions 2023-05-29 14:15:14 +08:00
Boshen
87a0b6c889
refactor(ast): s/ArrowFunctionExpression/ArrowExpression 2023-05-28 22:40:16 +08:00
Boshen
6ffc348e34
feat(minifier): initialize constant folding (#393)
Co-authored-by: Wenzhe Wang <mysteryven@gmail.com>
2023-05-28 11:32:10 +08:00
Wenzhe Wang
a20d5b55cd
feat(minifier): may add space before binaryOperator (#380) 2023-05-27 19:18:06 +08:00
Boshen
22664a3a83
fix(minifier): the mangle phase should come after the compress phase
To align with terser
2023-05-27 19:12:51 +08:00
Wenzhe Wang
a0b9628177
feat(minifer): distinguish-op-lessthan (#391) 2023-05-27 17:04:54 +08:00
Wenzhe Wang
b52efcb8d6
refactor(minifer): rename commented tests too (#392) 2023-05-27 16:47:28 +08:00
Boshen
b22c62de4f
refactor(minifier): rename expect to test 2023-05-27 13:54:46 +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
db51772c8c
chore(minifier): add "undefined" tests from closure compiler 2023-05-26 12:29:18 +08:00
Boshen
c4a67b6cfb
feat(minifier): fold return undefined to return (#387) 2023-05-25 22:37:55 +08:00
Boshen
b244065954
chore(minifier): enable some tests 2023-05-24 23:23:19 +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
Boshen
6811d67eb3
refactor(ast): move NumberBase to oxc_syntax; add NumberBase::Float 2023-05-24 18:33:19 +08:00
Boshen
6325b4f862
chore(minifier): enable a few passing tests 2023-05-23 19:28:25 +08:00
Boshen
1f96a05d47
chore(minifier): port printer test from closure compiler
closes #372
2023-05-23 14:16:28 +08:00
Boshen
1e27903243
chore(minifier): port tests from tdewolff/minify
closes #374
2023-05-23 13:37:46 +08:00
Boshen
af95d5bd0f
chore(minifier): port esbuild tests 2023-05-23 13:02:10 +08:00
Boshen
dee09da60b
feat(minifier): implement peephole reorder constant expression from closure compiler (#376) 2023-05-23 12:29:29 +08:00
Boshen
ad33954f52
refactor(ast): remove redundant prefix field from UnaryExpression 2023-05-22 22:32:47 +08:00
Boshen
349417e6c7
fix(minifier): fix dev dependencies 2023-05-22 12:36:28 +08:00
Boshen
d407cd9675
feat(minifier): add allocator to minifier example 2023-05-22 12:23:04 +08:00
Boshen
009fc5f285
feat(minifier): minify Infinity 2023-05-21 22:01:47 +08:00
Boshen
60fc7334db
feat(hir): remove EmptyStatement from hir 2023-05-21 20:20:03 +08:00
Boshen
69b3aff858
feat(minifier): add --mangle option to example 2023-05-21 14:45:24 +08:00
Boshen
70a713126f
feat(minifier): setup minifier tests 2023-05-21 14:33:06 +08:00
Boshen
61f0483891
feat(minifier): move terser tests do its directory 2023-05-21 14:19:50 +08:00
Boshen
ad2835f11b
chore(rustfmt): run cargo fmt 2023-05-21 11:52:26 +08:00
Boshen
f8828db68c
feat(semantic2): slot based mangler (#364) 2023-05-20 19:00:57 +08:00
Wenzhe Wang
9678832f2b
fix: add parens for unary expression (#362) 2023-05-17 10:13:48 +08:00
Boshen
0607b1493f
feat(minifier): remove whitespace printing from minifier
This should make the minifier even faster.
Use the formatter for debugging instead.
2023-05-16 23:22:43 +08:00
Boshen
a0b09a3f27
refactor(ast): remove RestElement from BindingPattern 2023-05-16 22:25:52 +08:00
Wenzhe Wang
bd56bb7abe
fix(minifier): break directive prologue (#360) 2023-05-16 21:35:58 +08:00
Boshen
af95b59a0e
feat(ast): split Property into ObjectProperty and BindingProperty (#361) 2023-05-16 15:51:50 +08:00
Boshen
5be0d1b9fa
fix(hir): bring back ParenthesizedExpression as it caused too much chaos 2023-05-14 22:54:57 +08:00
Boshen
dc768ba8ad
feat(minifier): turn on mangle by default 2023-05-14 18:33:29 +08:00
Boshen
2914b439b3
feat(semantic2): add slot based mangler 2023-05-14 18:21:07 +08:00
Boshen
73b2a9a52b
feat(minifier): print decorators 2023-05-14 18:18:39 +08:00
Wenzhe Wang
e6737fdc48
fix(minifier): continue compress left expr (#356) 2023-05-14 13:03:34 +08:00
Boshen
d14329e74e
feat(semantic2): bind identifiers 2023-05-13 22:58:42 +08:00
Boshen
48398ea74c
feat(hir,minifier): wire up identifier reference for mangle 2023-05-13 21:59:42 +08:00
Boshen
ebfaa3b940
feat(hir,minifier): wire up mangling 2023-05-13 21:59:42 +08:00
Boshen
6db5f4e59b
fix(minifier): print SequenceExpression and ObjectExpression with parens 2023-05-13 21:57:02 +08:00
Boshen
6e8d342403
feat(minifier): add mangle option 2023-05-13 16:03:43 +08:00
Boshen
1f5fa8d6cb
feat: reimplement semantic builder (#354) 2023-05-13 15:20:00 +08:00
Wenzhe Wang
7b834d4bd9
fix(minifier): not merge different kinds of declarations. (#353) 2023-05-13 10:51:10 +08:00
Boshen
14720e7c69
refactor: move SourceType from oxc_ast to oxc_span (#351)
related #350
2023-05-12 23:16:14 +08:00
Boshen
7f93e58f10
chore: remove all #[must_use] 2023-05-11 21:08:00 +08:00
Boshen
7496bb521f
fix(minifier): print if.consequent correctly (#349) 2023-05-11 11:00:49 +08:00
Boshen
48e524ddcf
feat(ast_lower): scope tree (#344) 2023-05-10 22:38:34 +08:00
Boshen
b6fb509b87
refactor: remove unused code from formatter and printer 2023-05-09 23:19:34 +08:00
Boshen
b94fe5ebfa
refactor(syntax): clean up Operator 2023-05-09 22:04:50 +08:00
Boshen
e753a886d2
fix(minifier): add parentheses to CallExpression on FunctionExpression 2023-05-08 23:04:35 +08:00
Boshen
65a445f512
refactor: move operator to oxc_syntax (#341) 2023-05-08 15:35:01 +08:00
Boshen
c2428d8abd
chore: rename oxc_printer to oxc_formatter (#336) 2023-05-07 17:47:13 +08:00
Boshen
86c01c7fb8
feat(minifier): use hir (#335) 2023-05-07 17:23:00 +08:00
Boshen
cd276c2850
feat: add oxc_span crate (#323) 2023-04-27 21:51:15 +08:00
Boshen
1004a1d197
chore: clean up workspace dependencies (#320) 2023-04-27 11:38:39 +08:00
Boshen
080baaa2db
chore: use taplo to reformat toml files 2023-04-22 15:58:59 +08:00
Boshen
7f946fb75d
chore: bump nightly to nightly-2023-04-20 (#304) 2023-04-20 23:35:38 +08:00
Boshen
c14c82b15d
feat(printer,semantic): mangler (#285)
closes #284
2023-04-18 21:32:35 +08:00
Boshen
aa478c585c
chore(minifier): add test fixture (#287) 2023-04-17 11:24:58 +08:00
Boshen
4939eeab6a
refactor(oxc_ast): cleanup docs and exports 2023-04-15 18:02:17 +08:00
Boshen
9eec306818
chore(minifier): add SemanticBuilder to minifier example
so we can start measuring perf
2023-04-14 13:21:04 +08:00
Boshen
79fd35c9cb
deps: fix versions depending on each other 2023-03-30 23:59:41 +08:00
Boshen
9e3675a575
chore: clean up Cargo.toml 2023-03-30 23:27:26 +08:00
Boshen
d46c7aabd9
chore: do not publish some of the crates 2023-03-30 22:41:52 +08:00
Boshen
a35d08ea23
Minifier Prototype (#215)
feat(minifier): minifier prototype
2023-03-29 06:51:50 -07:00