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): Add WeakRef as a safe global reference #8458

Merged
merged 1 commit into from
Dec 29, 2023

Conversation

lukeapage
Copy link
Contributor

Description:

I was trying to remove references to Weak Ref from minified code and despite the expression not being used, it was still included.

E.g.

var x = WeakRef;

with

{
   "minify": true,
  "jsc": {
      "minify": {
            "compress": {
                "pure_getters": true,
                "unused": true
            },
            "mangle": true
        }
    }
}

outputs

WeakRef;

but when I use something on this list e.g. parseFloat, it gets cleaned up and outputs empty string.

btw - I tried different options for pure_getters that I assumed would allow me to say WeakRef as a getter was pure, but it had no effect.

WeakRef getter is as safe to remove as the other items on this list and has no effect in accessing it.

@lukeapage lukeapage requested a review from a team as a code owner December 29, 2023 09:56
@CLAassistant
Copy link

CLAassistant commented Dec 29, 2023

CLA assistant check
All committers have signed the CLA.

@lukeapage lukeapage changed the title Add WeakRef as a safe global reference fix(es/minifier): Add WeakRef as a safe global reference Dec 29, 2023
@kdy1 kdy1 self-assigned this Dec 29, 2023
@kdy1 kdy1 added this to the Planned milestone Dec 29, 2023
Copy link
Member

@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.

Thank you!


swc-bump:

  • swc_ecma_usage_analyzer

@kdy1 kdy1 enabled auto-merge (squash) December 29, 2023 12:25
@kdy1 kdy1 merged commit d681785 into swc-project:main Dec 29, 2023
141 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.3.102 Dec 31, 2023
@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 30, 2024
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.

3 participants