From ea88de1b81c87e7f14983a8a3c69928f8dadd44f Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Fri, 16 Dec 2022 15:04:04 -0500 Subject: [PATCH] Fix the weirdness with esbuild definition variables. Apparently it's even worse than enforcing a type, but now it requires a string in the setting in build.js, but turns that into code. --- admin/App.svelte | 2 +- client/App.svelte | 2 +- commands/build.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/App.svelte b/admin/App.svelte index 5ba87ea..48e03e8 100644 --- a/admin/App.svelte +++ b/admin/App.svelte @@ -7,7 +7,7 @@ -{#if process.env.DANGER_ADMIN === "1"} +{#if process.env.DANGER_ADMIN} {/if} diff --git a/client/App.svelte b/client/App.svelte index fdef7d3..9bf77ce 100644 --- a/client/App.svelte +++ b/client/App.svelte @@ -7,7 +7,7 @@ -{#if process.env.DANGER_ADMIN === "1"} +{#if process.env.DANGER_ADMIN} {/if} diff --git a/commands/build.js b/commands/build.js index c5104a2..b671f8d 100644 --- a/commands/build.js +++ b/commands/build.js @@ -118,8 +118,8 @@ const devMode = () => ({ setup(build) { const options = build.initialOptions; options.define = options.define || {}; - // esbuild 0.16 went insane and now type checks environment variables. What a bunch of idiots. - options.define['process.env.DANGER_ADMIN'] = options.minify ? "1" : "0"; + // esbuild 0.16 requires this to be a string, but changes it to code so this will be an actual boolean type in the code + options.define['process.env.DANGER_ADMIN'] = options.minify ? "false" : "true"; } })