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
fix(es/minifier): Abort sequential inliner on optional chaining #6637
Merged
Merged
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7c28495
Add tests
kdy1 eb4464a
config.json
kdy1 2896445
Update test refs (correct)
kdy1 f6db660
Reduce
kdy1 e69fe49
config.json
kdy1 ec56c8b
Remove
kdy1 d331306
Remove
kdy1 1401352
Remove
kdy1 249e794
Update test refs (correct)
kdy1 cc99469
Remove
kdy1 6ec98dc
Remove
kdy1 8df9654
passes
kdy1 77380cd
Fix
kdy1 ede8a15
Revert "Fix"
kdy1 ec7a818
Prepare reducing
kdy1 4b0bbfc
Reduce
kdy1 d3643e9
Reduce
kdy1 ea9e941
Reduce
kdy1 3585826
Reduce
kdy1 3273924
Reduce
kdy1 7e9c1d5
Reduce
kdy1 6005265
Reduce
kdy1 6394548
Reduce
kdy1 0410a6c
Revert "Revert "Fix""
kdy1 95384ce
Update test refs
kdy1 26c0862
Reduce
kdy1 cef1be2
Update test refs
kdy1 9c16c9d
Merge branch 'main' into issue-6636
swc-bot 6104977
Merge branch 'main' into issue-6636
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
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_minifier/tests/fixture/issues/6636/config.json
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"passes": 2, | ||
"toplevel": true, | ||
"defaults": true, | ||
"sequences": true, | ||
"collapse_vars": true | ||
} |
23 changes: 23 additions & 0 deletions
23
crates/swc_ecma_minifier/tests/fixture/issues/6636/input.js
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function memo(getDeps, fn, opts) { | ||
let deps = []; | ||
let result; | ||
return () => { | ||
let depTime; | ||
if (opts.key && opts.debug) depTime = Date.now(); | ||
const newDeps = getDeps(); | ||
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep); | ||
if (!depsChanged) { | ||
return result; | ||
} | ||
deps = newDeps; | ||
let resultTime; | ||
if (opts.key && opts.debug) resultTime = Date.now(); | ||
result = fn(...newDeps); | ||
opts?.onChange?.(result); | ||
if (opts.key && opts.debug) { | ||
if (opts?.debug()) { | ||
} | ||
} | ||
return result; | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function memo(getDeps, fn, opts) { | ||
let result, deps = []; | ||
return ()=>{ | ||
opts.key && opts.debug && Date.now(); | ||
const newDeps = getDeps(), depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index)=>deps[index] !== dep); | ||
return depsChanged && (deps = newDeps, opts.key && opts.debug && Date.now(), result = fn(...newDeps), opts?.onChange?.(result), opts.key && opts.debug && opts?.debug()), result; | ||
}; | ||
} |
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.
Previous output:
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 reduce this down further? Seems like https://play.swc.rs/?version=1.3.22&code=H4sIAAAAAAAAA0XMQQqDMBCF4b2neMsEylwgWBftRYpMbEFnQjLBQvHuVhvo8vE9fn4nzYZYZbSXChZe1EW5QJMVj08HzGzIXOps4bsyW80C59FfT0ZD9IjiiEh4vXMqPpx4dAZSuT0fMvFA7vdu2mr%2F%2FBa6bQf5UtPElAAAAA%3D%3D&config=H4sIAAAAAAAAA3VUQZLjIAz8C%2Bc5ZOc0NQ%2FY27yBIiAcshi5kMjElcrfVyQ2xMnMzWpaQlK3uagjWfV5UZPJBLl%2B0ZzYnNWn4nkCsjlMrN4Uk0DeRIKrBCYPwEIBet%2B97%2BQ4IhIshDc1hhT8XItZHKcMRPVbksoIianxTM74LSHnItEeMYJJL7E2pENiGCD3VIsxmolAn0xuGfU2kwNh2kCFwekp4%2FSAJhc4YJJiK%2BbAOG3RQQNCBsvhBJ0iNYSSSBprndxAB%2FsyDHWBdyacTCyGWy0439YgN7a8AwZi7UuiJ2jT6R26D7mwgtcZuOS0co4Y0mYP%2FwCkz2iIkhmhZ95wLzpsmf4HVkheROS5oaJw7yrBIMPpEHybsHYNmUPfVgZXLNQJbS%2B%2BgJuBKDjQ4L1suyXTd2B76MWqGdG3ULZmfNfgHurVT1u0WuAF%2FCtd8aMcCz4aPjxjNI97jC8lRuADuhdYFsH4DGZx73l6RktyIGsG93BQqIbNpiI%2Bo471b1v3LIaQHD1E3Df7yk85mjRUW14U4xThBHGr6K9%2B%2BAGTS05V4MWKq%2FHgo2tmxEfhz259FK61A3Rl6UDUkudBNj9iOpK69jdhrUVfC3vRG0u28GXqdSqkKBOq63%2Fb7HJPngQAAA%3D%3D can repro the issue.