From b041e43e98816532378c25800b4aa8f810c87380 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 29 Sep 2021 10:16:44 +0100 Subject: [PATCH] Suppress svelte runtime warnings --- packages/builder/src/helpers/warnings.js | 16 ++++++++++++++++ packages/builder/src/main.js | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 packages/builder/src/helpers/warnings.js diff --git a/packages/builder/src/helpers/warnings.js b/packages/builder/src/helpers/warnings.js new file mode 100644 index 0000000000..ad943a8578 --- /dev/null +++ b/packages/builder/src/helpers/warnings.js @@ -0,0 +1,16 @@ +export const suppressWarnings = warnings => { + if (!warnings?.length) { + return + } + const regex = new RegExp(warnings.map(x => `(${x})`).join("|"), "gi") + const warn = console.warn + console.warn = (...params) => { + const msg = params[0] + if (msg && typeof msg === "string") { + if (msg.match(regex)) { + return + } + } + warn(...params) + } +} diff --git a/packages/builder/src/main.js b/packages/builder/src/main.js index f0fd0af178..bc5ec4f009 100644 --- a/packages/builder/src/main.js +++ b/packages/builder/src/main.js @@ -7,11 +7,19 @@ import "@spectrum-css/vars/dist/spectrum-light.css" import "@spectrum-css/vars/dist/spectrum-lightest.css" import "@spectrum-css/page/dist/index-vars.css" import "./global.css" - +import { suppressWarnings } from "./helpers/warnings" import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-vite.js" +import App from "./App.svelte" + +// Init spectrum icons loadSpectrumIcons() -import App from "./App.svelte" +// Suppress svelte runtime warnings +suppressWarnings([ + "was created with unknown prop", + "was created without expected prop", + "received an unexpected slot", +]) export default new App({ target: document.getElementById("app"),