[eric] build: import the notarize esm module lazily so electron-builder stops choking on every non-mac build

This commit is contained in:
Eric
2026-05-27 12:28:40 -07:00
parent 7dcb99cdec
commit e2f1e89cb8
+7 -2
View File
@@ -1,5 +1,8 @@
const { notarize } = require('@electron/notarize');
// @electron/notarize 3.x is ESM-only, so a top-level require() throws
// ERR_REQUIRE_ESM the moment electron-builder loads this afterSign hook — which
// it does for EVERY platform/build, breaking even unsigned Windows packaging.
// Import it lazily, after the skip checks, so it's only loaded when we actually
// notarize (signed macOS). Dynamic import() works from CommonJS.
exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== 'darwin') return;
@@ -14,6 +17,8 @@ exports.default = async function notarizing(context) {
return;
}
const { notarize } = await import('@electron/notarize');
const appName = context.packager.appInfo.productFilename;
const appPath = `${appOutDir}/${appName}.app`;