Surpress react/jsx-runtime errors

This commit is contained in:
Benjamin Toby 2026-03-25 16:03:45 +01:00
parent b8bae51b32
commit 764e8f76f0
5 changed files with 23 additions and 3 deletions

View File

@ -49,6 +49,7 @@ export default async function genWebHTML({ component, pageProps, bundledMap, mod
"react-dom": `https://esm.sh/react-dom@${_reactVersion}`, "react-dom": `https://esm.sh/react-dom@${_reactVersion}`,
"react-dom/client": `https://esm.sh/react-dom@${_reactVersion}/client`, "react-dom/client": `https://esm.sh/react-dom@${_reactVersion}/client`,
"react/jsx-runtime": `https://esm.sh/react@${_reactVersion}/jsx-runtime`, "react/jsx-runtime": `https://esm.sh/react@${_reactVersion}/jsx-runtime`,
"react/jsx-dev-runtime": `https://esm.sh/react@${_reactVersion}/jsx-dev-runtime`,
}; };
// if (dev) { // if (dev) {
// browser_imports["react/jsx-dev-runtime"] = // browser_imports["react/jsx-dev-runtime"] =

View File

@ -4,9 +4,17 @@ export default async function (params) {
const { ClientWindowPagePropsName } = grabConstants(); const { ClientWindowPagePropsName } = grabConstants();
let script = ""; let script = "";
script += `console.log(\`Development Environment\`);\n\n`; script += `console.log(\`Development Environment\`);\n\n`;
const errors_to_supress = [
"hydrat",
"react/jsx-dev-runtime",
"react/jsx-runtime",
];
const supress_condition = errors_to_supress
.map((e) => `args[0].includes("${e}")`)
.join(" || ");
script += `const _ce = console.error.bind(console);\n`; script += `const _ce = console.error.bind(console);\n`;
script += `console.error = (...args) => {\n`; script += `console.error = (...args) => {\n`;
script += ` if (typeof args[0] === "string" && args[0].includes("hydrat")) return;\n`; script += ` if (typeof args[0] === "string" && (${supress_condition})) return;\n`;
script += ` _ce(...args);\n`; script += ` _ce(...args);\n`;
script += `};\n\n`; script += `};\n\n`;
script += `function __bunext_show_error(message, source, stack) {\n`; script += `function __bunext_show_error(message, source, stack) {\n`;

View File

@ -2,7 +2,7 @@
"name": "@moduletrace/bunext", "name": "@moduletrace/bunext",
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"version": "1.0.35", "version": "1.0.36",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"exports": { "exports": {

View File

@ -74,6 +74,7 @@ export default async function genWebHTML({
"react-dom": `https://esm.sh/react-dom@${_reactVersion}`, "react-dom": `https://esm.sh/react-dom@${_reactVersion}`,
"react-dom/client": `https://esm.sh/react-dom@${_reactVersion}/client`, "react-dom/client": `https://esm.sh/react-dom@${_reactVersion}/client`,
"react/jsx-runtime": `https://esm.sh/react@${_reactVersion}/jsx-runtime`, "react/jsx-runtime": `https://esm.sh/react@${_reactVersion}/jsx-runtime`,
"react/jsx-dev-runtime": `https://esm.sh/react@${_reactVersion}/jsx-dev-runtime`,
}; };
// if (dev) { // if (dev) {

View File

@ -13,9 +13,19 @@ export default async function (params?: Params) {
script += `console.log(\`Development Environment\`);\n\n`; script += `console.log(\`Development Environment\`);\n\n`;
const errors_to_supress = [
"hydrat",
"react/jsx-dev-runtime",
"react/jsx-runtime",
];
const supress_condition = errors_to_supress
.map((e) => `args[0].includes("${e}")`)
.join(" || ");
script += `const _ce = console.error.bind(console);\n`; script += `const _ce = console.error.bind(console);\n`;
script += `console.error = (...args) => {\n`; script += `console.error = (...args) => {\n`;
script += ` if (typeof args[0] === "string" && args[0].includes("hydrat")) return;\n`; script += ` if (typeof args[0] === "string" && (${supress_condition})) return;\n`;
script += ` _ce(...args);\n`; script += ` _ce(...args);\n`;
script += `};\n\n`; script += `};\n\n`;