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

Bug: should generate conflict-less name for duplicated generated names #364

Closed
underfin opened this issue Nov 22, 2023 · 0 comments · Fixed by #365
Closed

Bug: should generate conflict-less name for duplicated generated names #364

underfin opened this issue Nov 22, 2023 · 0 comments · Fixed by #365
Assignees

Comments

@underfin
Copy link
Contributor

The current implementation assigned symbol name is append ${count} if the symbol is conflicting. But the new name maybe also happen conflict. See blowing example.

Input

// shared.js
const a = 'shared.js'

export { a }

// main.js
import { a as a2 } from './shared'
const a = 'index.js'
const a$1 = 'index.js'

console.log(a, a2, a$1)

Build Output

// shared.js
const a = 'shared.js'


// main.js

const a$1 = 'index.js'
const a$1 = 'index.js'

console.log(a$1, a, a$1)

We should assign a name with the current scope that is not a used name, like esbuild findNameUse https://github.com/evanw/esbuild/blob/main/internal/renamer/renamer.go#L564. We need to collect the all symbols for scope at first, we only collect unresolved symbols at now.

@hyf0 hyf0 changed the title Make renamer assign symbol name stable. Bug: should generate conflict-less name for duplicated generated names Nov 22, 2023
Boshen pushed a commit that referenced this issue Nov 27, 2023
<!-- Thank you for contributing! -->

### Description

Fixes #364

<!-- Please insert your description here and provide especially info about the "what" this PR is solving -->

### Test Plan

<!-- e.g. is there anything you'd like reviewers to focus on? -->

---
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 a pull request may close this issue.

2 participants