Skip to content
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

Function returned by function has default parameters incorrectly stripped #4507

Closed
bluwy opened this issue May 19, 2022 · 3 comments · Fixed by #4510
Closed

Function returned by function has default parameters incorrectly stripped #4507

bluwy opened this issue May 19, 2022 · 3 comments · Fixed by #4510
Assignees

Comments

@bluwy
Copy link
Contributor

bluwy commented May 19, 2022

Rollup Version

2.74.0

Operating System (or Browser)

macos

Node Version (if applicable)

No response

Link To Reproduction

https://rollupjs.org/repl/?version=2.74.0&shareable=JTdCJTIybW9kdWxlcyUyMiUzQSU1QiU3QiUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTJDJTIyY29kZSUyMiUzQSUyMiUyRiUyRiUyMENvcHklMjBvZiUyMFN2ZWx0ZSUyMEFQSSU1Q25mdW5jdGlvbiUyMGNyZWF0ZUV2ZW50RGlzcGF0Y2hlcigpJTIwJTdCJTVDbiU1Q3Rjb25zdCUyMGNvbXBvbmVudCUyMCUzRCUyMGdldF9jdXJyZW50X2NvbXBvbmVudCgpJTNCJTVDbiU1Q24lNUN0JTJGJTJGJTIwVGhlJTIwdGhpcmQlMjBwYXJhbWV0ZXIlMjBkZWZhdWx0JTIwdmFsdWUlMjBzaG91bGRuJ3QlMjBiZSUyMHJlbW92ZWQlNUNuJTVDdHJldHVybiUyMCh0eXBlJTJDJTIwZGV0YWlsJTJDJTIwJTdCJTIwY2FuY2VsYWJsZSUyMCUzRCUyMGZhbHNlJTIwJTdEJTIwJTNEJTIwJTdCJTdEKSUyMCUzRCUzRSUyMCU3QiU1Q24lNUN0JTVDdGNvbnN0JTIwY2FsbGJhY2tzJTIwJTNEJTIwY29tcG9uZW50LiUyNCUyNC5jYWxsYmFja3MlNUJ0eXBlJTVEJTNCJTVDbiU1Q24lNUN0JTVDdGlmJTIwKGNhbGxiYWNrcyklMjAlN0IlNUNuJTVDdCU1Q3QlNUN0Y29uc3QlMjBldmVudCUyMCUzRCUyMGN1c3RvbV9ldmVudCh0eXBlJTJDJTIwZGV0YWlsJTJDJTIwJTdCJTIwY2FuY2VsYWJsZSUyMCU3RCklM0IlNUNuJTVDdCU1Q3QlNUN0Y2FsbGJhY2tzLnNsaWNlKCkuZm9yRWFjaChmbiUyMCUzRCUzRSUyMCU3QiU1Q24lNUN0JTVDdCU1Q3QlNUN0Zm4uY2FsbChjb21wb25lbnQlMkMlMjBldmVudCklM0IlNUNuJTVDdCU1Q3QlNUN0JTdEKSUzQiU1Q24lNUN0JTVDdCU1Q3RyZXR1cm4lMjAhZXZlbnQuZGVmYXVsdFByZXZlbnRlZCUzQiU1Q24lNUN0JTVDdCU3RCU1Q24lNUNuJTVDdCU1Q3RyZXR1cm4lMjB0cnVlJTNCJTVDbiU1Q3QlN0QlM0IlNUNuJTdEJTVDbiU1Q25jcmVhdGVFdmVudERpc3BhdGNoZXIoKSUyMiUyQyUyMmlzRW50cnklMjIlM0F0cnVlJTdEJTVEJTJDJTIyb3B0aW9ucyUyMiUzQSU3QiUyMmZvcm1hdCUyMiUzQSUyMmVzJTIyJTJDJTIybmFtZSUyMiUzQSUyMm15QnVuZGxlJTIyJTJDJTIyYW1kJTIyJTNBJTdCJTIyaWQlMjIlM0ElMjIlMjIlN0QlMkMlMjJnbG9iYWxzJTIyJTNBJTdCJTdEJTdEJTJDJTIyZXhhbXBsZSUyMiUzQW51bGwlN0Q=

Expected Behaviour

In the repro, the line:

return (type, detail, { cancelable = false } = {}) => {

The third parameter should be left as is.

Actual Behaviour

Rollup compiles the line to

return (type, detail, { cancelable }) => {

causing runtime errors, e.g. sveltejs/kit#4988

Note: Similar issues #4505, #4506

@lukastaegert
Copy link
Member

Thank you so much! Considering the issues, I will roll back the parameter default tree-shaking in a patch release for now and refine it for another few days. Please keep the issue open as I intend to fix it with a proper release later.

@lukastaegert
Copy link
Member

I created a new PR #4510 that reimplements parameter tree-shaking in a more conservative way. Could you verify that this PR works for you via npm install rollup/rollup#parameter-defaults?

@bluwy
Copy link
Contributor Author

bluwy commented May 26, 2022

Looks like that fixes it! I tried the repro from sveltejs/kit#4988 with

{
  "overrides": {
    "rollup": "rollup/rollup#parameter-defaults"
  }
}

And npm run build, npm run preview, and it worked without issues. Tested locally, stackblitz doesn't support overrides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants