Search existing issues
Describe the bug
Running npm run dev on a fresh clone fails during the Vite build of the Electron main process. The recordly-electron-main-cjs-guard plugin throws because dist-electron/main.cjs is emitted with ESM export { ... } syntax instead of CommonJS, so node --check rejects it.
The build log shows dist-electron/main.cjs being written twice in succession with different byte sizes, which suggests Rollup is producing both a CJS and an ESM output to the same [name].cjs filename and the ESM one ends up overwriting the CJS one. The relevant config is in vite.config.ts:36-48, where lib.formats: ["cjs"] is combined with a single-object rollupOptions.output that also sets format: "cjs" and entryFileNames: "[name].cjs".
Expected behavior
npm run dev should produce a valid CommonJS dist-electron/main.cjs, pass the smoke check, and launch the Electron app against the Vite dev server.
To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/webadderall/Recordly.git recordly
cd recordly
npm install
npm run dev
- Build completes, then the guard plugin throws
Electron main CJS smoke failed after Vite build with SyntaxError: Unexpected token 'export' from dist-electron/main.cjs.
Screenshots
Attaching terminal standard output.
❯ npm run dev
> recordly@1.3.0-beta.1 dev
> vite --config vite.config.ts
vite v5.4.21 building for development...
watching for file changes...
vite v5.4.21 building for development...
watching for file changes...
build started...
build started... (x2)
VITE v5.4.21 ready in 154 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
✓ 1 modules transformed.
dist-electron/preload.mjs 21.23 kB │ gzip: 3.76 kB
built in 220ms.
✓ 435 modules transformed.
dist-electron/main.cjs 1,003.03 kB │ gzip: 205.31 kB
dist-electron/main.cjs 996.43 kB │ gzip: 204.12 kB
built in 1049ms.
file:///Users/devuser/Documents/GitHub/Recordly/vite.config.ts.timestamp-1778296263787-382699a40ac88.mjs:19
throw new Error(
^
Error: Electron main CJS smoke failed after Vite build.
file:///Users/devuser/Documents/GitHub/Recordly/scripts/smoke-electron-main-cjs.mjs:25
throw new Error(
^
Error: dist-electron/main.cjs does not parse as CommonJS:
(node:30565) Warning: Failed to load the ES module: /Users/devuser/Documents/GitHub/Recordly/dist-electron/main.cjs. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/devuser/Documents/GitHub/Recordly/dist-electron/main.cjs:28499
export {
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1762:18)
at checkSyntax (node:internal/main/check_syntax:76:3)
Node.js v25.9.0
at file:///Users/devuser/Documents/GitHub/Recordly/scripts/smoke-electron-main-cjs.mjs:25:8
Node.js v25.9.0
at Object.closeBundle (file:///Users/devuser/Documents/GitHub/Recordly/vite.config.ts.timestamp-1778296263787-382699a40ac88.mjs:19:15)
at file:///Users/devuser/Documents/GitHub/Recordly/node_modules/rollup/dist/es/shared/node-entry.js:22426:40
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async Promise.all (index 0)
at async PluginDriver.hookParallel (file:///Users/devuser/Documents/GitHub/Recordly/node_modules/rollup/dist/es/shared/node-entry.js:22336:9)
at async Object.close (file:///Users/devuser/Documents/GitHub/Recordly/node_modules/rollup/dist/es/shared/node-entry.js:23347:13) {
code: 'PLUGIN_ERROR',
plugin: 'recordly-electron-main-cjs-guard',
hook: 'closeBundle'
}
Node.js v25.9.0
OS
macOS
OS Version
MacOS Tahoe 26.4.1 (Darwin 25.4.0, Apple Silicon / arm64)
Other OS
No response
Additional context
Tail of the emitted dist-electron/main.cjs:
});
export {
MAIN_DIST,
RENDERER_DIST,
VITE_DEV_SERVER_URL
};
Relevant build log excerpt:
dist-electron/main.cjs 1,003.03 kB │ gzip: 205.18 kB
dist-electron/main.cjs 996.43 kB │ gzip: 204.00 kB
built in 1399ms.
Error: Electron main CJS smoke failed after Vite build.
Error: dist-electron/main.cjs does not parse as CommonJS:
(node:20341) Warning: Failed to load the ES module: .../dist-electron/main.cjs.
.../dist-electron/main.cjs:28499
export {
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1762:18)
at checkSyntax (node:internal/main/check_syntax:76:3)
plugin: 'recordly-electron-main-cjs-guard',
hook: 'closeBundle'
I'll be happy to contribute if this is a real bug. Currently, npm run dev is not working for any of the Node versions I've tried.
Search existing issues
Describe the bug
Running
npm run devon a fresh clone fails during the Vite build of the Electron main process. Therecordly-electron-main-cjs-guardplugin throws becausedist-electron/main.cjsis emitted with ESMexport { ... }syntax instead of CommonJS, sonode --checkrejects it.The build log shows
dist-electron/main.cjsbeing written twice in succession with different byte sizes, which suggests Rollup is producing both a CJS and an ESM output to the same[name].cjsfilename and the ESM one ends up overwriting the CJS one. The relevant config is invite.config.ts:36-48, wherelib.formats: ["cjs"]is combined with a single-objectrollupOptions.outputthat also setsformat: "cjs"andentryFileNames: "[name].cjs".Expected behavior
npm run devshould produce a valid CommonJSdist-electron/main.cjs, pass the smoke check, and launch the Electron app against the Vite dev server.To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/webadderall/Recordly.git recordlycd recordlynpm installnpm run devElectron main CJS smoke failed after Vite buildwithSyntaxError: Unexpected token 'export'fromdist-electron/main.cjs.Screenshots
Attaching terminal standard output.
OS
macOS
OS Version
MacOS Tahoe 26.4.1 (Darwin 25.4.0, Apple Silicon / arm64)
Other OS
No response
Additional context
Tail of the emitted
dist-electron/main.cjs:Relevant build log excerpt:
I'll be happy to contribute if this is a real bug. Currently,
npm run devis not working for any of the Node versions I've tried.