fix(desktop): stabilize esm shim injection (#35270)

This commit is contained in:
Luke Parker 2026-07-04 13:31:13 +10:00 committed by GitHub
parent 8b6a2b173b
commit f63a451b6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,6 +39,17 @@ export default defineConfig({
build: {
rollupOptions: {
input: { index: "src/main/index.ts", sidecar: "src/main/sidecar.ts" },
// Keep this identical to electron-vite's Node 20.11+ shim. Its regex insertion can
// corrupt bundled TypeScript, while a Rollup banner places the shim safely.
output: {
banner: `
// -- CommonJS Shims --
import __cjs_mod__ from 'node:module';
const __filename = import.meta.filename;
const __dirname = import.meta.dirname;
const require = __cjs_mod__.createRequire(import.meta.url);
`,
},
},
externalizeDeps: { include: [nodePtyPkg] },
},