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

fix(es/minifier): Don't inline functions if keep_fnames is enabled #8093

Merged
merged 31 commits into from
Oct 12, 2023

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Oct 10, 2023

@kdy1 kdy1 added this to the Planned milestone Oct 10, 2023
@kdy1 kdy1 self-assigned this Oct 10, 2023
@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

image

this and U is undefined

@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

It seems like it's constructed twice, and those values are undefined only on the second construction.
Second call looks like a reflection

@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

image

u(u) in the output (broken) vs u(t) in the input (below)

image

@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

image

I think the mangling variable renamer is skipping renaming u1.

@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

Ah, vercel/next.js#56281 was the cause. I'll update mangle.json

@kdy1 kdy1 changed the title fix(es/minifier): Fix exceljs fix(es/minifier): Fix keep_fnames: true of the name mangler Oct 11, 2023
@kdy1 kdy1 changed the title fix(es/minifier): Fix keep_fnames: true of the name mangler fix(es/minifier): Don't inline functions if keep Oct 11, 2023
@kdy1 kdy1 changed the title fix(es/minifier): Don't inline functions if keep fix(es/minifier): Don't inline functions if keep_fnames is enabled Oct 11, 2023
@kdy1
Copy link
Member Author

kdy1 commented Oct 11, 2023

The name mangler was correct; The problem was that inliner happily inlined t as u in a(u)


                }(u#31, t#31);
                var e#42, n#31, s#31 = e#42 = function() {
                    if ("undefined" == typeof Reflect#1 || !Reflect#1.construct || Reflect#1.construct.sham) return !1;
                    if ("function" == typeof Proxy#1) return !0;
                    try {
                        return Date#1.prototype.toString.call(Reflect#1.construct(Date#1, [], function() {})), !0;
                    } catch (t#24) {
                        return !1;
                    }
                }(), function() {
                    var r#25, n#25 = u#12(u#31);
                    if (e#42) {
                        var i#25 = u#12(this).constructor;
                        r#25 = Reflect#1.construct(n#25, arguments#1, i#25);
                    } else r#25 = n#25.apply(this, arguments#1);
                    var t#46, e#46;
                    return t#46 = this, e#46 = r#25 && "object" === n#12(e#46) || "function" == typeof e#46 ? e#46 : function(t#28) {
                        if (void 0 === t#28) throw ReferenceError#1("this hasn't been initialised - super() hasn't been called");
                        return t#28;
                    }(t#46);
                };
                function u#31(t#33) {
                    var e#33;
                    return function(t#34, e#34) {

Copy link
Member Author

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swc-bump:

  • swc_ecma_minifier

@kdy1 kdy1 marked this pull request as ready for review October 11, 2023 06:48
@kdy1 kdy1 requested a review from jridgewell October 11, 2023 06:48
kodiakhq[bot]
kodiakhq bot previously approved these changes Oct 11, 2023
kodiakhq[bot]
kodiakhq bot previously approved these changes Oct 11, 2023
kodiakhq[bot]
kodiakhq bot previously approved these changes Oct 11, 2023
jridgewell
jridgewell previously approved these changes Oct 11, 2023
@kdy1 kdy1 enabled auto-merge (squash) October 11, 2023 23:59
@kdy1 kdy1 merged commit 94bb42e into swc-project:main Oct 12, 2023
130 of 132 checks passed
@kdy1 kdy1 deleted the next-56550 branch October 12, 2023 00:39
@kdy1 kdy1 modified the milestones: Planned, v1.3.93 Oct 13, 2023
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants