mirror of
https://github.com/Kong/insomnia.git
synced 2026-08-04 11:52:33 -04:00
The recent change to guard Node-only code with `typeof window !== 'undefined' && window.main != null` broke Vite's treeshaking because the expression is not statically resolvable at build time. This caused Rollup to include both the renderer (IPC) and Node-only code paths, pulling transitive imports of `node:url` and `node:crypto` into the renderer bundle. Introduced `__IS_RENDERER__` constant in the Vite `define` block (set to `true` for the renderer build) which is statically resolvable, allowing Rollup to eliminate the Node-only branch via dead code elimination. Also added the constant declarations to a new `types/vite.d.ts` file so TypeScript recognizes `__IS_RENDERER__` as a valid global constant. Fixes: MISSING_EXPORT error for node:url and node:crypto in curl.ts, openapi-3.ts, and swagger-2.ts