Skip to content

Commit f63a451

Browse files
authored
fix(desktop): stabilize esm shim injection (#35270)
1 parent 8b6a2b1 commit f63a451

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/desktop/electron.vite.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ export default defineConfig({
3939
build: {
4040
rollupOptions: {
4141
input: { index: "src/main/index.ts", sidecar: "src/main/sidecar.ts" },
42+
// Keep this identical to electron-vite's Node 20.11+ shim. Its regex insertion can
43+
// corrupt bundled TypeScript, while a Rollup banner places the shim safely.
44+
output: {
45+
banner: `
46+
// -- CommonJS Shims --
47+
import __cjs_mod__ from 'node:module';
48+
const __filename = import.meta.filename;
49+
const __dirname = import.meta.dirname;
50+
const require = __cjs_mod__.createRequire(import.meta.url);
51+
`,
52+
},
4253
},
4354
externalizeDeps: { include: [nodePtyPkg] },
4455
},

0 commit comments

Comments
 (0)