From 712b3122b2c6ab01da8b83a0a8467288fddc1c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kt=C3=BCrk=20Acar?= Date: Tue, 22 Sep 2026 18:27:20 +0300 Subject: [PATCH] Inline the app's .env in the web dev server The embedded build inlines every `process.env.` an app reads through dotEnvDefines (build-gea-vite-geatsc.mjs); this dev server did not, so the same source threw ReferenceError in the browser. Weather reads GEA_WIFI_SSID at module scope, so the whole app failed to mount and `gea dev weather` served a blank page. That page is the real-DOM, real-CSS rendering the native targets are compared against, so it has to run the source the device build runs. Co-Authored-By: Claude Opus 5 (1M context) --- targets/web/dev-web.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/targets/web/dev-web.mjs b/targets/web/dev-web.mjs index 73b6dee..e68ee91 100644 --- a/targets/web/dev-web.mjs +++ b/targets/web/dev-web.mjs @@ -108,6 +108,21 @@ try { process.exit(1) } +// The app's `.env` inlined the same way the embedded build does it +// (build-gea-vite-geatsc.mjs). Without this every `process.env.` the app +// reads throws ReferenceError in the browser and the whole app fails to mount — +// which is what happened to weather, whose store reads GEA_WIFI_SSID at module +// scope. This dev server is the CSS reference the native targets are compared +// against, so it has to run the same source the device build runs. +let envDefines = {} +try { + const mod = await import(path.join(coreRoot, 'scripts/dotenv-defines.mjs')) + envDefines = mod.dotEnvDefines(appDir) +} catch (error) { + console.warn(` (no .env defines: ${error.message})`) + envDefines = {} +} + const alias = buildAliases({ coreRoot, appDir }) const babel = loadBabel(coreRoot) const compatTransform = createCompatPlugin(transformGeaEmbeddedCompatSource, babel) @@ -212,6 +227,7 @@ const server = await createServer(await webViteConfig(coreRoot, appDir, 'serve', compatTransform, withoutTsconfigWrite(geaPlugin()), ], + define: envDefines, esbuild: { jsx: 'preserve' }, // geaPlugin (pre) rewrites every JSX site; esbuild must not touch it resolve: { alias }, // Never pre-bundle the framework. The reactive runtime keys its subscriber