Throw error on re-registering component only if in prod environment (#5990)

This was causing an error when hot-reloading components, meaning that the components would not be refreshed.
This commit is contained in:
WithoutPants
2025-07-02 17:07:01 +10:00
committed by GitHub
parent d98e9c6618
commit dcfb3b7d37

View File

@@ -39,7 +39,13 @@ export function RegisterComponent<T extends Function>(
) {
// register with the plugin api
if (components[component]) {
throw new Error("Component " + component + " has already been registered");
// only throw an error in production, in development we allow
// multiple registrations to allow for hot reloading of components
if (!import.meta.env.DEV) {
throw new Error(
"Component " + component + " has already been registered"
);
}
}
components[component] = fn;