mirror of
https://github.com/Kong/insomnia.git
synced 2026-08-04 11:52:33 -04:00
* is renderer check
* fix: use __IS_RENDERER__ constant for treeshaking node-only imports
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
* fix: define __IS_RENDERER__ constant in vitest config
The __IS_RENDERER__ constant was undefined in test environments, breaking the
conditional logic in import.ts that determines whether to use the renderer IPC
path or the Node.js path. Define it as false in vitest config so tests run with
the correct code path.
(cherry picked from commit ed388d2fa9)