vite-on-swc
vite-on-swc copied to clipboard
[t|j]sx files without a component causing infinite browser load.
Thanks for this library.
I've noticed one strange issue with it, which is whereby the page will continually refresh when importing a tsx file which doesn't contain any react components. (This is in a large codebase, which seems to use the tsx extension for a lot of classes)
e.g. if you call the below store.tsx
and import it into the example App.tsx, then the page will hit a refresh loop.
class Store {
constructor(initial: number) {
this.value = initial
}
value: number = 1
update(newValue: number) {
this.value = newValue
}
}
export default Store
I'm wondering if the call to invalidate
should only be called in a hot.on
context? https://vitejs.dev/guide/api-hmr.html#hot-on-event-cb
Thanks for using the library. You are right about when to call the invalidate
function. I just don't have time to fix it(PR welcome :).
The official vite react plugin does an amazing job, you should use it.
I feel like transpiling is not the bottleneck of vite, so kind of lose the interest to maintain this plugin.