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

Remove decl_collector pass and use SWC's unresolved_mark instead #9520

Merged
merged 1 commit into from Feb 4, 2024

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Feb 3, 2024

The decl_collector pass stored all declarations in a HashSet so we could determine if a variable is a global (i.e. undeclared). This is used to find require calls and much more. Turns out we don't really need this anymore because SWC has an unresolved_mark that it sets on these identifiers in its resolver. Removing this saves us a pass, reduces some memory usage, and simplifies the code by reducing the number of places we need to keep up to date.

@mischnic
Copy link
Member

mischnic commented Feb 3, 2024

Are we sure this is always correct? I just remember the multiple times where swc's unresolved and global mark don't really do what they say they do: #8151 and #8029

@devongovett
Copy link
Member Author

I think it may have been improved. I noticed that SWC's minifier and Turbopack both use this same check. I did also try to remove the second pass of the resolver after preset env that you added before as well, but that was still broken. Otherwise it seems to pass all of our tests here and we can test on some apps too.

@mischnic mischnic merged commit e0b99c2 into v2 Feb 4, 2024
14 of 16 checks passed
@mischnic mischnic deleted the remove-decl-collector branch February 4, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants