Closed LaCocoRoco closed 1 year ago
Hi @LaCocoRoco! Yes, this warning happens because registerClass
is executed more than once for a class of the same name. It's meant to uncover potential bugs in your module loading, and there's no way of supressing them.
Could you elaborate on when exactly you're seeing the warning? Is it during Hot Module Replacement? Reproduction steps / a repro repo would be greatly appreciated.
Hi @Skn0tt, here is a sandbox to reproduce the problem.
Probably fast refresh from the nextjs framework is the origin of this issue, because on every change the page gets reloaded. I think it is neglectable, but perhaps there is a way to fix it.
I'm seeing it, thank you! Yeah, that looks like it's occuring during Hot Module Replacement (HMR). That means there already was a class called Foo
, and now the Next.js Dev Server dynamically loads in the updated module, which has a new version of the class Foo
, which triggers the warning.
The warning was originally supposed to warn about existing classes being overwritten, e.g. when something in the build process fails and e.g. some client stub is placed in the server bundle. It's not supposed to trigger during HMR, but apparently it does, and I don't see a good way of excluding HMR here 🤔 Maybe we should disable the warning altogether. What do you think?
Depends if there are any significant negative effects which could happen if you run in a real ambiguous class situation. But if it is a simple information for "you unnecessary load the class more then once" in my personally opinion you probably could disable it.
Removed the warning in https://github.com/blitz-js/superjson/releases/tag/v1.12.0.
Issues Reference: #105 #106 #107 #116 #118 Code Reference: superjson/blob/main/src/registry
This warning only happens in none production environment. In my use case by using next-superjson-plugin package with a custom class register in nextjs app.ts. Can someone explain why this warning exits or better how i can fix it in development? If i'm not wrong this happens because the registerClass gets executed more then once? I could not find any flag or possibility to suppress this warning.