-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(es/minifier): mark some builtin functions pure. #6842
base: main
Are you sure you want to change the base?
Conversation
member_expr!(DUMMY_SP, console.groupCollapsed), | ||
member_expr!(DUMMY_SP, console.groupEnd), | ||
member_expr!(DUMMY_SP, console.info), | ||
member_expr!(DUMMY_SP, console.log), |
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.
I'm not sure about console
. I often use console.log
to debug or capture some variables to make the minifier/mangler not optimize it.
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.
Same here 🤣
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.
I used it while debugging the minifier
if let Callee::Expr(e) = &n.callee { | ||
// Check for pure_funcs | ||
if pure_fns.contains(&HashEqIgnoreSpanExprRef(e)) { | ||
if self.pure_funcs.contains(&HashEqIgnoreSpanExprRef(e)) { |
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.
Can we use two hashset instead?
I think it will avoid allocations
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.
One hashset with type Lazy<FxHashSet<HashEqIgnoreSpanExprRef<'static>>>
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.
Get it.
I think I misunderstand the usage of the esbuild's list.
|
But still, there are indeed some expressions in the list that are calling without side effects. I need to tweak the list. |
Description:
Originally posted by @kdy1 in #6840 (comment)
BREAKING CHANGE:
Related issue (if exists):
The PR relies on code in #6840.