fix(vite): silence optional export warnings (#3360)

Seems like vite is overly strict when accessing optional namespaced
module properties. The code is perfectly fine, so silence these
warnings.
This commit is contained in:
Marvin Hagemeister
2025-09-08 17:59:54 +02:00
committed by GitHub
parent 2c2257843e
commit be2fde6a85
+17
View File
@@ -118,6 +118,23 @@ export function fresh(config?: FreshViteConfig): Plugin[] {
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
return;
}
// Ignore optional export errors
if (
warning.code === "MISSING_EXPORT" &&
warning.id?.startsWith("\0fresh-route::")
) {
return;
}
// Ignore commonjs optional exports
if (
warning.code === "MISSING_EXPORT" &&
warning.message.includes("__require")
) {
return;
}
return handler(warning);
},
input: {