mirror of https://github.com/buster-so/buster.git
Update nitro.config.js
This commit is contained in:
parent
7c0b49c9e7
commit
6ea91facda
|
@ -1,46 +1,51 @@
|
|||
// Configuration for warning suppressions - easily extensible
|
||||
const WARNING_SUPPRESSIONS = {
|
||||
MODULE_LEVEL_DIRECTIVE: {
|
||||
patterns: ["node_modules/"],
|
||||
reason: "Suppress 'use client' directive warnings from dependencies"
|
||||
},
|
||||
THIS_IS_UNDEFINED: {
|
||||
patterns: ["node_modules/"],
|
||||
reason: "Suppress 'this' keyword warnings in ES modules from dependencies"
|
||||
},
|
||||
CIRCULAR_DEPENDENCY: {
|
||||
patterns: [
|
||||
"nitropack/dist/runtime/internal/",
|
||||
"@tanstack/store/dist",
|
||||
"juice/lib/"
|
||||
],
|
||||
reason: "Suppress known third-party circular dependency warnings"
|
||||
}
|
||||
};
|
||||
|
||||
// Additional message-based suppressions
|
||||
const MESSAGE_SUPPRESSIONS = [
|
||||
"The 'this' keyword is equivalent to 'undefined'"
|
||||
];
|
||||
|
||||
function shouldSuppressWarning(warning) {
|
||||
const message = warning.message || "";
|
||||
|
||||
// Check code-based suppressions
|
||||
const suppression = WARNING_SUPPRESSIONS[warning.code];
|
||||
if (suppression) {
|
||||
return suppression.patterns.some(pattern => message.includes(pattern));
|
||||
}
|
||||
|
||||
// Check message-based suppressions
|
||||
return MESSAGE_SUPPRESSIONS.some(suppressionMessage =>
|
||||
message.includes(suppressionMessage)
|
||||
);
|
||||
}
|
||||
|
||||
export default {
|
||||
sourcemap: false,
|
||||
rollupConfig: {
|
||||
onwarn(warning, defaultHandler) {
|
||||
const message = warning.message || "";
|
||||
|
||||
// Suppress "use client" directive warnings
|
||||
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
|
||||
if (message.includes("node_modules/")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress 'this' keyword warnings in ES modules
|
||||
if (warning.code === "THIS_IS_UNDEFINED") {
|
||||
// Only suppress for node_modules dependencies
|
||||
if (message.includes("node_modules/")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Also suppress by message content for broader coverage
|
||||
if (message.includes("The 'this' keyword is equivalent to 'undefined'")) {
|
||||
if (shouldSuppressWarning(warning)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Suppress legitimate third-party circular dependency warnings
|
||||
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
||||
// Suppress nitropack internal circular dependencies (framework issue)
|
||||
if (message.includes("nitropack/dist/runtime/internal/")) {
|
||||
return;
|
||||
}
|
||||
// Suppress TanStack store internal circular dependencies (library issue)
|
||||
if (message.includes("@tanstack/store/dist")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Suppress juice library circular dependencies (library issue)
|
||||
if (message.includes("juice/lib/")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle all other warnings normally
|
||||
defaultHandler(warning);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue