Files
kjol/go/jsruntime/env.ts

17 lines
867 B
TypeScript

// Compile-time deployment environment: "development" | "staging" | "production".
//
// `__ENV_TYPE__` is substituted at bundle time by esbuild's `define`, fed the Go
// compile-time constant `internal/constants.AppEnvironment` (see the
// `esbuildDefine` helper in internal/bundler). The production bundles and the dev
// HMR per-module transform both define it. The build-time SSR render of the
// public pages does NOT, so the `typeof` guard yields "" there — the env badge
// renders only after the client takeover, matching the prior runtime behavior.
declare const __ENV_TYPE__: string;
export const ENV_TYPE: string = typeof __ENV_TYPE__ !== "undefined" ? __ENV_TYPE__ : "";
// True in every environment except production (and the badge-less SSR render).
export function isNonProdEnv(): boolean {
return ENV_TYPE !== "" && ENV_TYPE !== "production";
}