oven-sh/bun

HMR suffixes component function names with a number

开放

#18,017 创建于 2025年3月9日

 (1 条评论) (0 个反应) (0 位负责人)Rust (4,486 个派生)batch import
bake:devbuggood first issue

仓库指标

星标
 (90,348 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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).

贡献者指南