@thi.ng/expose
Version:
Conditional global variable exposition
10 lines (9 loc) • 523 B
JavaScript
const exposeGlobal = (id, value, always = false) => {
const glob = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : void 0;
if (glob && (always || (typeof process !== "undefined" && process.env !== void 0 ? process.env.NODE_ENV !== "production" || !!process.env.UMBRELLA_GLOBALS : import.meta.env ? import.meta.env.MODE !== "production" || !!import.meta.env.UMBRELLA_GLOBALS || !!import.meta.env.VITE_UMBRELLA_GLOBALS : true))) {
glob[id] = value;
}
};
export {
exposeGlobal
};