From edcf96fcd6245f7c4d0473539f1f5e83731019e6 Mon Sep 17 00:00:00 2001 From: jackkav Date: Thu, 4 Jun 2026 08:50:35 +0200 Subject: [PATCH 1/4] refactor: remove dead vite.config stubs and fix comments - Remove @apidevtools/swagger-parser and mocha from externalDependencies since both are only used in the main process (importers and IPC handler), never in the renderer - Update stale comment claiming nodeIntegration: true is still used - Remove misleading insomnia-testing example from SSR conditions comment - Remove main/types fields from insomnia-testing package.json since they point to a non-existent src/index.ts; all consumers use explicit deep path imports --- packages/insomnia-testing/package.json | 2 -- packages/insomnia/vite.config.ts | 14 ++++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/insomnia-testing/package.json b/packages/insomnia-testing/package.json index d767e046ef59..7f4420fcc184 100644 --- a/packages/insomnia-testing/package.json +++ b/packages/insomnia-testing/package.json @@ -12,8 +12,6 @@ "bugs": { "url": "https://github.com/Kong/insomnia/issues" }, - "main": "src/index.ts", - "types": "src/index.ts", "scripts": { "lint": "eslint . --ext .js,.ts,.tsx --cache", "test": "vitest run", diff --git a/packages/insomnia/vite.config.ts b/packages/insomnia/vite.config.ts index f5ff1678afdc..b968280087cb 100644 --- a/packages/insomnia/vite.config.ts +++ b/packages/insomnia/vite.config.ts @@ -7,7 +7,7 @@ import { defaultServerConditions, defineConfig } from 'vite'; import pkg from './package.json'; //These will be excluded from the bundle and remain as runtime dependencies -export const externalDependencies = ['@apidevtools/swagger-parser', 'mocha']; +export const externalDependencies = []; export default defineConfig(({ mode }) => { const __DEV__ = mode !== 'production'; const browserSafeBuiltinModules = new Set(['assert', 'buffer', 'events', 'path', 'util']); @@ -77,7 +77,9 @@ export default defineConfig(({ mode }) => { plugins: [ // Allows us to import modules that will be resolved by Node's require() function. // e.g. import fs from 'fs'; will get transformed to const fs = require('fs'); so that it works in the renderer process. - // This is necessary because we use nodeIntegration: true in the renderer process and allow importing modules from node. + // Still needed: renderer files (plugins/index.ts, sync/git/providers/*.ts) import `electron` as a value, + // and non-browser-safe node builtins must not be bundled into the renderer. The plugin converts + // these to require() calls, which resolve correctly because contextIsolation is currently false. electronNodeRequire({ modules: [ 'electron', @@ -94,10 +96,10 @@ export default defineConfig(({ mode }) => { }, // The Electron renderer is browser-like even in React Router's SSR (server) build. // Vite's DEFAULT_SERVER_CONDITIONS excludes "browser", so packages with a - // "browser" exports condition (e.g. insomnia-testing) would otherwise resolve to - // their full Node entry point in the server bundle — pulling in Node-only modules - // like mocha. Prepending "browser" here keeps the server bundle consistent with - // the client build while retaining all other default server conditions. + // "browser" exports condition would otherwise resolve to their full Node entry point + // in the server bundle — pulling in Node-only modules. Prepending "browser" here + // keeps the server bundle consistent with the client build while retaining all other + // default server conditions. ssr: { resolve: { conditions: ['browser', ...defaultServerConditions], From 68220b1bde8f1d5cdf16fc629157d3f16c46ceca Mon Sep 17 00:00:00 2001 From: jackkav Date: Thu, 4 Jun 2026 09:26:57 +0200 Subject: [PATCH 2/4] refactor: remove unused assert polyfill alias, clarify dep chain in comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove assert/node:assert aliases — no renderer consumer (jshint, isomorphic-git, events, tough-cookie) requires 'assert' - Condense polyfill comments to show only the evidence (which library needs it) - Update util comment from tough-cookie (moved to main process) to jshint (actual renderer consumer) --- packages/insomnia/vite.config.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/insomnia/vite.config.ts b/packages/insomnia/vite.config.ts index b968280087cb..f3306bac5e05 100644 --- a/packages/insomnia/vite.config.ts +++ b/packages/insomnia/vite.config.ts @@ -57,19 +57,16 @@ export default defineConfig(({ mode }) => { '~/templating/render-adapter': path.resolve(__dirname, './src/templating/render-adapter.renderer'), '~/utils/crypt-adapter': path.resolve(__dirname, './src/utils/crypt-adapter.renderer'), '~': path.resolve(__dirname, './src'), - // Shim Node's `path` module for browser-safe dependencies (e.g. mime-types uses path.extname). + // mime-types uses path.extname 'path': path.resolve(__dirname, './src/path-shim.ts'), 'node:path': path.resolve(__dirname, './src/path-shim.ts'), - // Shim Node's `assert` module for browser-safe dependencies that still use runtime invariants. - 'assert': path.resolve(__dirname, '../../node_modules/assert'), - 'node:assert': path.resolve(__dirname, '../../node_modules/assert'), - // Shim Node's `events` module for browser-safe dependencies (e.g. jshint uses EventEmitter). + // jshint uses EventEmitter 'events': path.resolve(__dirname, '../../node_modules/events'), 'node:events': path.resolve(__dirname, '../../node_modules/events'), - // Shim Node's `util` module for browser-safe dependencies (e.g. tough-cookie uses util.inherits). + // jshint uses util 'util': path.resolve(__dirname, '../../node_modules/util'), 'node:util': path.resolve(__dirname, '../../node_modules/util'), - // Buffer is also browser-safe in this renderer bundle, so keep it bundled instead of externalized. + // isomorphic-git/sha.js/safe-buffer use Buffer 'buffer': path.resolve(__dirname, '../../node_modules/buffer'), 'node:buffer': path.resolve(__dirname, '../../node_modules/buffer'), }, From 4ebc01fcd7f5a240df8a16dc6be925fab3ff1e99 Mon Sep 17 00:00:00 2001 From: jackkav Date: Thu, 4 Jun 2026 09:29:54 +0200 Subject: [PATCH 3/4] clean up vite config --- packages/insomnia/vite.config.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/insomnia/vite.config.ts b/packages/insomnia/vite.config.ts index f3306bac5e05..a6ccf46bd70b 100644 --- a/packages/insomnia/vite.config.ts +++ b/packages/insomnia/vite.config.ts @@ -7,7 +7,6 @@ import { defaultServerConditions, defineConfig } from 'vite'; import pkg from './package.json'; //These will be excluded from the bundle and remain as runtime dependencies -export const externalDependencies = []; export default defineConfig(({ mode }) => { const __DEV__ = mode !== 'production'; const browserSafeBuiltinModules = new Set(['assert', 'buffer', 'events', 'path', 'util']); @@ -47,7 +46,12 @@ export default defineConfig(({ mode }) => { optimizeDeps: { exclude: ['@getinsomnia/node-libcurl'], force: true, // wipe vite cache - include: ['codemirror-graphql/utils/SchemaReference', '@stoplight/spectral-core', 'isomorphic-git', 'json-bigint'], + include: [ + 'codemirror-graphql/utils/SchemaReference', + '@stoplight/spectral-core', + 'isomorphic-git', + 'json-bigint', + ], }, resolve: { alias: { @@ -59,16 +63,12 @@ export default defineConfig(({ mode }) => { '~': path.resolve(__dirname, './src'), // mime-types uses path.extname 'path': path.resolve(__dirname, './src/path-shim.ts'), - 'node:path': path.resolve(__dirname, './src/path-shim.ts'), // jshint uses EventEmitter 'events': path.resolve(__dirname, '../../node_modules/events'), - 'node:events': path.resolve(__dirname, '../../node_modules/events'), // jshint uses util 'util': path.resolve(__dirname, '../../node_modules/util'), - 'node:util': path.resolve(__dirname, '../../node_modules/util'), // isomorphic-git/sha.js/safe-buffer use Buffer 'buffer': path.resolve(__dirname, '../../node_modules/buffer'), - 'node:buffer': path.resolve(__dirname, '../../node_modules/buffer'), }, }, plugins: [ @@ -78,12 +78,7 @@ export default defineConfig(({ mode }) => { // and non-browser-safe node builtins must not be bundled into the renderer. The plugin converts // these to require() calls, which resolve correctly because contextIsolation is currently false. electronNodeRequire({ - modules: [ - 'electron', - ...externalDependencies, - ...nodeBuiltinModules, - ...nodeBuiltinModules.map(m => `node:${m}`), - ], + modules: ['electron'], }), reactRouter(), tailwindcss(), From d7be10b25a1eb565fcbfbd66c097a3ab2b37ed64 Mon Sep 17 00:00:00 2001 From: jackkav Date: Thu, 4 Jun 2026 09:30:53 +0200 Subject: [PATCH 4/4] fix lint --- packages/insomnia/vite.config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/insomnia/vite.config.ts b/packages/insomnia/vite.config.ts index a6ccf46bd70b..389c08e22681 100644 --- a/packages/insomnia/vite.config.ts +++ b/packages/insomnia/vite.config.ts @@ -1,4 +1,3 @@ -import { builtinModules } from 'node:module'; import path from 'node:path'; import { reactRouter } from '@react-router/dev/vite'; @@ -9,8 +8,6 @@ import pkg from './package.json'; //These will be excluded from the bundle and remain as runtime dependencies export default defineConfig(({ mode }) => { const __DEV__ = mode !== 'production'; - const browserSafeBuiltinModules = new Set(['assert', 'buffer', 'events', 'path', 'util']); - const nodeBuiltinModules = builtinModules.filter(m => !browserSafeBuiltinModules.has(m)); return { define: {