Skip to content

Commit 0939a38

Browse files
committed
refactor: move silent warn codes to shared config
1 parent 696a3c5 commit 0939a38

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

src/build/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ export function baseBuildConfig(nitro: Nitro) {
4646

4747
const noExternal: RegExp[] = getNoExternals(nitro);
4848

49+
const ignoreWarningCodes = new Set([
50+
"EVAL",
51+
"CIRCULAR_DEPENDENCY",
52+
"THIS_IS_UNDEFINED",
53+
"EMPTY_BUNDLE",
54+
]);
55+
4956
return {
5057
extensions,
5158
isNodeless,
5259
replacements,
5360
env,
5461
aliases,
5562
noExternal,
63+
ignoreWarningCodes,
5664
};
5765
}
5866

src/build/rolldown/config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ export const getRolldownConfig = (nitro: Nitro): RolldownOptions => {
3838
},
3939
},
4040
onwarn(warning, warn) {
41-
if (
42-
!["CIRCULAR_DEPENDENCY", "EVAL", "EMPTY_CHUNK"].includes(
43-
warning.code || ""
44-
) &&
45-
!warning.message.includes("Unsupported source map comment")
46-
) {
41+
if (!base.ignoreWarningCodes.has(warning.code || "")) {
42+
console.log(warning.code);
4743
warn(warning);
4844
}
4945
},

src/build/rollup/config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,7 @@ export const getRollupConfig = (nitro: Nitro): RollupConfig => {
5353
(inject as unknown as typeof inject.default)(base.env.inject),
5454
],
5555
onwarn(warning, rollupWarn) {
56-
if (
57-
![
58-
"EVAL",
59-
"CIRCULAR_DEPENDENCY",
60-
"THIS_IS_UNDEFINED",
61-
"EMPTY_CHUNK",
62-
].includes(warning.code || "") &&
63-
!warning.message.includes("Unsupported source map comment")
64-
) {
56+
if (!base.ignoreWarningCodes.has(warning.code || "")) {
6557
rollupWarn(warning);
6658
}
6759
},

src/build/vite/rollup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export const getViteRollupConfig = (
3939
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
4040
},
4141
},
42+
onwarn(warning, warn) {
43+
if (!base.ignoreWarningCodes.has(warning.code || "")) {
44+
warn(warning);
45+
}
46+
},
4247
output: {
4348
format: "esm",
4449
entryFileNames: "index.mjs",

0 commit comments

Comments
 (0)