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

update number renamer to avoid collisions in parent scopes #3949

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kevinkelleher12
Copy link

findNameUse looks across all parent scopes to determine if a name has been used. However, when findUnusedName begins trying to find an unused name, it uses only the nameCount in the current scope, which could require incrementing the name many times before avoiding collisions with a parent scope. With this change, findUnusedName will begin incrementing using the maximum nameCount across all scopes.

I have a bit of an unusual use case where I'm using esbuild in the browser with a plugin to fetch imports like https://cdn.jsdelivr.net/npm/react/+esm. Because these are already minified, there can be a very large number of name collisions at the topmost scope. This change speeds up builds for my use case by 2-3x.

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.

1 participant