buster/apps/web/nitro.config.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-09-03 04:27:59 +08:00
// Configuration for warning suppressions - easily extensible
const WARNING_SUPPRESSIONS = {
MODULE_LEVEL_DIRECTIVE: {
2025-09-24 11:30:12 +08:00
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: {
2025-09-24 11:30:12 +08:00
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: {
2025-09-24 11:30:12 +08:00
patterns: ['nitropack/dist/runtime/internal/', '@tanstack/store/dist', 'juice/lib/'],
reason: 'Suppress known third-party circular dependency warnings',
2025-09-06 23:18:30 +08:00
},
2025-09-03 04:27:59 +08:00
};
// Additional message-based suppressions
2025-09-24 11:30:12 +08:00
const MESSAGE_SUPPRESSIONS = ["The 'this' keyword is equivalent to 'undefined'"];
2025-09-03 04:27:59 +08:00
function shouldSuppressWarning(warning) {
2025-09-24 11:30:12 +08:00
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-24 11:30:12 +08:00
return MESSAGE_SUPPRESSIONS.some((suppressionMessage) => message.includes(suppressionMessage));
2025-09-03 04:27:59 +08:00
}
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
};