oven-sh/bun

HMR suffixes component function names with a number

Open

#18,017 建立於 2025年3月9日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)Rust (90,348 star) (4,486 fork)batch import
bake:devbuggood first issue

描述

What version of Bun is running?

1.2.5-canary.70+8a177f6c8

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Set up a Bun + React web app with HTML imports and HMR.

  1. Bun.serve with routes
  2. import index from './index.html
  3. routes: { '/': index }
  4. bun add react react-dom
  5. <script src="index.tsx"></script>
  6. import React from 'react; import ReactDOM from 'react-dom/client; ReactDOM.render(document.body, <App />
  7. export default function App() { return (<div className={App.name}>TODO</div>) }

What is the expected behavior?

class="App"

What do you see instead?

class="App2"

Additional information

This really seems like a problem to me, because these names are programmer-originated and the bundler shouldn't mangle them the same way it shouldn't mangle any other identifier it cannot be sure isn't used outside of JS (e.g. there is no minification of data attribute names because they could have meaning in CSS selectors).

貢獻者指南