Skip to content

Commit 7e61c29

Browse files
committed
added an build config option for terser checking
1 parent b7dd022 commit 7e61c29

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

build/validateTerser.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ import { fileURLToPath } from "url";
44
import { minify } from "terser";
55
import * as chalkUtils from "./chalkUtils.js";
66
import fromConsole from "./fromConsole.js";
7+
import { terserValidation } from "../buildconfig.js";
78

89
const __filename = fileURLToPath(import.meta.url);
910
const __dirname = path.dirname(__filename);
1011

1112
export default async function validateTerser() {
13+
// Check if validation is skipped
14+
if (terserValidation === "skip") {
15+
chalkUtils.info(
16+
"Terser validation is disabled (terserValidation = 'skip')"
17+
);
18+
return false;
19+
}
20+
1221
chalkUtils.step("Validating Terser build (mangle-props keep_quoted)");
1322

1423
const filesToCheck = [
@@ -49,19 +58,28 @@ export default async function validateTerser() {
4958
}
5059
chalkUtils.success(`Terser validation passed for ${file}`);
5160
} catch (error) {
52-
chalkUtils.error(`Terser validation failed for ${file}`);
53-
chalkUtils.error(error.message || error);
54-
hadError = true;
61+
if (terserValidation === "warning") {
62+
chalkUtils.warning(`Terser validation failed for ${file}`);
63+
chalkUtils.warning(error.message || error);
64+
hadError = true;
65+
} else {
66+
chalkUtils.error(`Terser validation failed for ${file}`);
67+
chalkUtils.error(error.message || error);
68+
hadError = true;
69+
}
5570
}
5671
}
5772

58-
if (hadError) {
73+
if (hadError && terserValidation === "warning") {
74+
chalkUtils.info("Terser validation completed with warnings.");
75+
return { hadOptionalError: true };
76+
} else if (hadError) {
5977
chalkUtils.failed("Terser validation failed.");
78+
return true;
6079
} else {
6180
chalkUtils.success("Terser validation successful!");
81+
return false;
6282
}
63-
64-
return hadError;
6583
}
6684

6785
// if is being called from the command line

buildconfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export const disableTips = false;
1515

1616
export const disableWarnings = false;
1717

18+
// Terser validation configuration
19+
// Options: "error" (fail build), "warning" (show warning but continue), "skip" (disable check)
20+
export const terserValidation = "error";
21+
1822
export const publishConfig = {
1923
addonUrl: "",
2024
autoGenReadme: true,

0 commit comments

Comments
 (0)