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 remove used var decl #7200

Merged
merged 6 commits into from Apr 5, 2023
Merged

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Apr 4, 2023

Description:

Related issue:


Invesitgation:

The problematic code is

let can_ignore =
matches!(&**init, Expr::Call(call) if call.span.has_mark(marks.pure));

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

kdy1 commented Apr 4, 2023

@Austaras Can you take a look?

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

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 April 4, 2023 06:10
kodiakhq[bot]
kodiakhq bot previously approved these changes Apr 4, 2023
@kdy1 kdy1 requested a review from jridgewell April 4, 2023 06:10
@Austaras
Copy link
Member

Austaras commented Apr 4, 2023

I believe a more fine grained solution would be most optimal -- the pure mark only marks the function call, but not the call arguments, but here we ignore usage in arguments as well.

kodiakhq[bot]
kodiakhq bot previously approved these changes Apr 4, 2023
e.init.visit_with(&mut *self.with_ctx(ctx));
self.used_recursively.remove(&id);

match init {
Copy link
Member Author

Choose a reason for hiding this comment

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

@Austaras Did you mean something like this?

Copy link
Member

Choose a reason for hiding this comment

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

I can't see changes, seems like they're force pushed.

kodiakhq[bot]
kodiakhq bot previously approved these changes Apr 4, 2023
@Austaras
Copy link
Member

Austaras commented Apr 4, 2023

I believe a more fine grained solution would be most optimal -- the pure mark only marks the function call, but not the call arguments, but here we ignore usage in arguments as well.

But these won't really make any real difference, self references are very rarely used.

@kdy1 kdy1 enabled auto-merge (squash) April 5, 2023 03:45
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 73bc29e into swc-project:main Apr 5, 2023
128 checks passed
@kdy1 kdy1 deleted the issue-7194 branch April 5, 2023 04:35
@kdy1 kdy1 modified the milestones: Planned, v1.3.47 Apr 10, 2023
@swc-project swc-project locked as resolved and limited conversation to collaborators May 10, 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.

SWC creates code resulting in an Uncaught ReferenceError with default minify/compress settings
4 participants