SWC hot reload doesn't work when arrow function is used
See original GitHub issueWhenever I use arrow function
instead of function
, hot reload doesn’t work. See screenshot and how to repro below:
Repro:
- clone react-refresh-webpack-plugin
- navigate to examples/typescript-with-swc
- Change
function App() {
return (
<div>
<ClassDefault />
<ClassNamed />
<FunctionDefault />
<FunctionNamed />
<Suspense fallback={<h1>Loading</h1>}>
<LazyComponent />
</Suspense>
</div>
);
}
to
const App= () => {
return (
<div>
{/* added */}
<div> test </div>
<ClassDefault />
<ClassNamed />
<FunctionDefault />
<FunctionNamed />
<Suspense fallback={<h1>Loading</h1>}>
<LazyComponent />
</Suspense>
</div>
);
}
- Change
test
text to different text
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Why does changing componentDidMount to non-arrow ...
So all I did was change componentDidMount from an arrow function to a non-arrow function. So my question is: Why does changing it...
Read more >I don't understand the point of vite. I tried using it and the "build ...
What I want is to reload the page and see my changes. I've never seen a "hot reload" that works properly. The one...
Read more >@swc/helpers | Yarn - Package Manager
SWC (stands for Speedy Web Compiler ) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and...
Read more >[Android 4.1+] HeadUnit Reloaded for Android Auto with Wifi
If the app does not start automatically when you plug in your phone, you can always open HUR, tap the USB button and...
Read more >Getting started with NestJS, Vite, and esbuild - LogRocket Blog
In this article, we'll learn about NestJS, Vite, and esbuild; how they work together; and how to configure a NestJS app to make...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool, great to get my questions answered. I’ll send fix when I have time.
Yeah it’s me. I have spent some time for this issue and there’re multiple layers of problems in this issue:
(function () {}).bind(this)
, which is a long standing minor defect inswc
and there haven’t been a good reason to fix it(until this issue)preset-env
forswc
, so this issue should be reopened @pmmmwhbrowserslist
field topackage.json
, webpack hot reload will silently fail, I have tested with other examples and they behave the same. I have absolutely idea why this is happening