New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(es/minifier): Don't create invalid nodes #6191
Merged
Merged
Changes from 68 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
bc327eb
Add assertions
kdy1 ba40d58
More assertions
kdy1 b20c98f
normalize
kdy1 d971155
More assertions
kdy1 dbe4499
normalize more
kdy1 d353009
Some fix
kdy1 c0e2f8a
More assertions
kdy1 8ebc740
More assertions
kdy1 b4cb8dd
More assertions
kdy1 9c87028
More assertions
kdy1 aad6e2c
More assertions
kdy1 df2b84f
Remove wrong asssertion
kdy1 b43dd47
Remove wrong asssertion
kdy1 b3dac37
More assertions
kdy1 2c1c70d
Remove one normalization
kdy1 14e3701
Some fix
kdy1 09a415a
More fix
kdy1 e833d9c
More assertions
kdy1 1ab82fb
Fix
kdy1 259855f
Fix
kdy1 86b964c
Fix
kdy1 76db4c0
lints
kdy1 b714285
Fix
kdy1 e73abff
More assertions
kdy1 da95580
Normalize more
kdy1 4a6b807
More assertions
kdy1 97753d0
More assertions
kdy1 d98d69c
Fix `ignore_return_value`
kdy1 536a7d4
More assertions
kdy1 3529a53
Fix `ignore_return_value`
kdy1 2afd1a5
Fix `ignore_return_value`
kdy1 a055031
Fix dead branch remover pass
kdy1 8e1bacc
Better message
kdy1 49c5da6
Fix dead branch remover pass
kdy1 01131cb
Fix pure
kdy1 21c7037
Fix wrong assertion
kdy1 679fb9c
Merge assertvalid
kdy1 80ed754
lints
kdy1 cab6b92
Fix pure
kdy1 5dfee1d
Fix pure
kdy1 c4ce3ad
Fix compressor
kdy1 8d97676
More assertions
kdy1 1b47b32
More assertions
kdy1 baecb60
More assertions
kdy1 4a0f9df
More fix
kdy1 76f7de5
More fix
kdy1 9b5f720
clippy
kdy1 128cb59
lints
kdy1 5bce62f
More asseryions
kdy1 5282ef2
lints
kdy1 b99d682
Normalize
kdy1 405c168
Fix
kdy1 b74ca3c
Improve expression normalization
kdy1 d53c98b
Normalize more
kdy1 e2d5d4c
Change order
kdy1 f42ee81
Normalize more
kdy1 2e2e09d
More assertions
kdy1 5596457
Merge code
kdy1 177708b
More assertion
kdy1 dedc237
More assertion
kdy1 71776d2
More assertion
kdy1 bed4083
More assertion
kdy1 8037b3a
TODO
kdy1 2f0e900
Log
kdy1 f25d4e2
Add more assertions
kdy1 7cdbbe3
Log
kdy1 adf8317
Fix
kdy1 b45f828
Update test refs
kdy1 f13fc4e
Merge branch 'main' into more-rules
swc-bot File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,7 +450,6 @@ where | |
Callee::Super(_) | Callee::Import(_) => return, | ||
Callee::Expr(e) => &mut **e, | ||
}; | ||
self.normalize_expr(callee); | ||
|
||
if self.ctx.dont_invoke_iife { | ||
log_abort!("iife: Inline is prevented"); | ||
|
@@ -582,10 +581,7 @@ where | |
exprs.push(body.take()); | ||
|
||
report_change!("inline: Inlining a call to an arrow function"); | ||
*e = Expr::Seq(SeqExpr { | ||
span: DUMMY_SP, | ||
exprs, | ||
}); | ||
*e = *Expr::from_exprs(exprs); | ||
e.visit_mut_with(self); | ||
} | ||
} | ||
|
@@ -986,7 +982,9 @@ where | |
}; | ||
self.merge_sequences_in_seq_expr(&mut e); | ||
|
||
return Some(Expr::Seq(e)); | ||
let mut e = Expr::Seq(e); | ||
self.normalize_expr(&mut e); | ||
return Some(e); | ||
} | ||
_ => {} | ||
} | ||
|
@@ -1008,7 +1006,9 @@ where | |
}; | ||
self.merge_sequences_in_seq_expr(&mut e); | ||
|
||
Some(Expr::Seq(e)) | ||
let mut e = Expr::Seq(e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
self.normalize_expr(&mut e); | ||
Some(e) | ||
} | ||
|
||
fn can_be_inlined_for_iife(&self, arg: &Expr) -> bool { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know
exprs
has more than 1 element?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normalize instead of verifying, at the line below.
I think we can improve this in the future