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 drop inlined parameter as duplicate #6293

Merged
merged 15 commits into from Nov 2, 2022

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Oct 30, 2022

Description:

Previously, we prepend a variable declaration using IIFE invoker, and dropped it as a duplicate because it's declared as a function parameter.

Related issue:


Investigation

  DEBUG  Removing a variable statement because it's a function parameter, kind: "change"
    at crates/swc_ecma_minifier/src/compress/optimize/unused.rs:765
    in visit_mut_stmt
    in handle_stmt_likes
    in visit_mut_function
    in visit_mut_prop
    in seq_expr_with_children
    in visit_mut_seq_expr
    in visit_mut_call_expr
    in visit_mut_arrow_expr
    in seq_expr_with_children
    in visit_mut_seq_expr
    in visit_mut_expr_stmt
    in visit_mut_stmt
    in handle_stmt_likes
    in apply full optimizer
    in optimize with pass: 1
    in compress ast
    in minify

```

@kdy1 kdy1 added this to the Planned milestone Oct 30, 2022
@kdy1 kdy1 self-assigned this Oct 30, 2022
@kdy1 kdy1 changed the title fix(es/resolver): Fix resolving of nested arrow paramters fix(es/minifier): Declare variables while invoking IIFE with arrow callee Oct 30, 2022
@kdy1 kdy1 changed the title fix(es/minifier): Declare variables while invoking IIFE with arrow callee fix(es/minifier): Don't drop variable inlined from parameter as duplicate Oct 31, 2022
if let Some(usage) = self.data.vars.get_mut(&name.to_id()) {
if usage.is_fn_local
&& usage.declared_as_fn_param
&& usage.declared_count >= 2
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix

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 changed the title fix(es/minifier): Don't drop variable inlined from parameter as duplicate fix(es/minifier): Don't drop inlined parameter as duplicate Oct 31, 2022
state: d
});
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Previous output:

"use strict";
Yp.revoke, (o)=>Yp.config({
        aria: {
            mode: "checked"
        },
        ...ge(o, (o, g)=>"exclusive" !== g),
        onToggled (g, t) {
            p(o.onToggled) && o.onToggled(g, t), e = g, f = t, Or(e, th, {
                item: e,
                state: f
            });
        }
    });

@kdy1 kdy1 requested a review from jridgewell October 31, 2022 04:22
@kdy1 kdy1 marked this pull request as ready for review October 31, 2022 04:22
crates/swc_ecma_codegen/benches/bench.rs Outdated Show resolved Hide resolved
@kdy1 kdy1 enabled auto-merge (squash) November 2, 2022 00:50
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 merged commit dd797f7 into swc-project:main Nov 2, 2022
@kdy1 kdy1 deleted the m-tinymce branch November 2, 2022 01:57
@kdy1 kdy1 modified the milestones: Planned, v1.3.12, v1.3.13 Nov 2, 2022
huozhi pushed a commit to vercel/next.js that referenced this pull request Nov 4, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Dec 3, 2022
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.

None yet

3 participants