2025-09-03 04:27:59 +08:00
|
|
|
// Configuration for warning suppressions - easily extensible
|
|
|
|
const WARNING_SUPPRESSIONS = {
|
|
|
|
MODULE_LEVEL_DIRECTIVE: {
|
|
|
|
patterns: ["node_modules/"],
|
2025-09-06 23:18:30 +08:00
|
|
|
reason: "Suppress 'use client' directive warnings from dependencies",
|
2025-09-03 04:27:59 +08:00
|
|
|
},
|
|
|
|
THIS_IS_UNDEFINED: {
|
|
|
|
patterns: ["node_modules/"],
|
2025-09-06 23:18:30 +08:00
|
|
|
reason: "Suppress 'this' keyword warnings in ES modules from dependencies",
|
2025-09-03 04:27:59 +08:00
|
|
|
},
|
|
|
|
CIRCULAR_DEPENDENCY: {
|
|
|
|
patterns: [
|
|
|
|
"nitropack/dist/runtime/internal/",
|
|
|
|
"@tanstack/store/dist",
|
2025-09-06 23:18:30 +08:00
|
|
|
"juice/lib/",
|
2025-09-03 04:27:59 +08:00
|
|
|
],
|
2025-09-06 23:18:30 +08:00
|
|
|
reason: "Suppress known third-party circular dependency warnings",
|
|
|
|
},
|
2025-09-03 04:27:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Additional message-based suppressions
|
|
|
|
const MESSAGE_SUPPRESSIONS = [
|
2025-09-06 23:18:30 +08:00
|
|
|
"The 'this' keyword is equivalent to 'undefined'",
|
2025-09-03 04:27:59 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
function shouldSuppressWarning(warning) {
|
|
|
|
const message = warning.message || "";
|
2025-09-06 23:18:30 +08:00
|
|
|
|
2025-09-03 04:27:59 +08:00
|
|
|
// Check code-based suppressions
|
|
|
|
const suppression = WARNING_SUPPRESSIONS[warning.code];
|
|
|
|
if (suppression) {
|
2025-09-06 23:18:30 +08:00
|
|
|
return suppression.patterns.some((pattern) => message.includes(pattern));
|
2025-09-03 04:27:59 +08:00
|
|
|
}
|
2025-09-06 23:18:30 +08:00
|
|
|
|
2025-09-03 04:27:59 +08:00
|
|
|
// Check message-based suppressions
|
2025-09-06 23:18:30 +08:00
|
|
|
return MESSAGE_SUPPRESSIONS.some((suppressionMessage) =>
|
2025-09-03 04:27:59 +08:00
|
|
|
message.includes(suppressionMessage)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-09-03 03:53:32 +08:00
|
|
|
export default {
|
2025-09-06 23:18:30 +08:00
|
|
|
rollupConfig: {
|
|
|
|
onwarn(warning, defaultHandler) {
|
|
|
|
if (shouldSuppressWarning(warning)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle all other warnings normally
|
|
|
|
defaultHandler(warning);
|
|
|
|
},
|
|
|
|
},
|
2025-09-03 03:53:32 +08:00
|
|
|
};
|