-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(es/minifier): Fix minification of framer-motion
by checking cons.termniates()
#9818
fix(es/minifier): Fix minification of framer-motion
by checking cons.termniates()
#9818
Conversation
🦋 Changeset detectedLatest commit: 91ed6a3 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
52df9f2
to
a60aa86
Compare
framer-motion
framer-motion
CodSpeed Performance ReportMerging #9818 will not alter performanceComparing Summary
|
Thank you for reducing the edge case! Actually it's the most hard part of minifier work... |
A more simple example of why we need to check if |
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.
Thank you!
framer-motion
framer-motion
by checking cons.termniates()
Description:
Next.js 15 seems to minify parts of
framer-motion
's code in an invalid way, changing the meaning. The original function modifies the singledefinition
variable as it changes meaning (seeinput.js
):definition
is a function, it calls it and saves the return value asdefinition
definition
is a string, it resolves animation variant based on value as name and saves the variant asdefinition
definition
is again a function, it calls it again and saves the return value asdefinition
againHowever,
swc
seems to be not noticing thatdefinition
may be mutated between the calls and collapses allif
s into one:which skips the first call to
definition
, first "resolution" step.Note: I suspect the
output.js
may not be precisely what SWC may output as minified code (maybe there is a way to minify it further). It definitely differs from the current output though by the initial call and reassignment todefinition
.