Closed lutzroeder closed 9 months ago
Released in 24.10.0
@lutzroeder HELLO DID YOU MANAGE TO FIND A SOLUTION?
Running into this issue now as well using 24.13.3
So the current code detects if the package.json is of type module
, but it automatically has a fallback of require
from the try-catch
logic
https://github.com/electron-userland/electron-builder/blob/29f6504e181cef2c43ac070a80f24ee79dc52481/packages/app-builder-lib/src/platformPackager.ts#L775-L787
It should be fully functional for handling both ES and CJS modules in the next
alpha version, would you mind giving it a try?
Running into this issue now as well using 24.13.3
added some debug logs to platformPackager.js today, and turns out that the try part failed not because it's not an es module, but because there's bugs in my notarize.js
's code, so it threw exceptions on import. for me it was because i gave bad arguments to the notarize
function. @mmaietta perhaps the catch block could be tweaked a bit to check the error cause so the error message is more accurate?
Here's my working afterSign
script:
import { notarize } from '@electron/notarize';
export default async function afterSign(context) {
const { appOutDir, electronPlatformName } = context;
if (electronPlatformName !== 'darwin') {
return;
}
const appName = context.packager.appInfo.productFilename;
await notarize({
appPath: `${appOutDir}/${appName}.app`,
appleApiKey: '~/private_keys/notarize.p8', // Path to your .p8 file
appleApiKeyId: process.env.API_KEY_ID,
appleApiIssuer: process.env.API_KEY_ISSUER_ID,
});
}
@leo4life2 that's a great callout and something I'll implement.
Do you recall what the error message you were receiving? Was it Unable to dynamically import hook, falling back to "require"
or an error being thrown during the fallback require
statement?
Added better logging in https://github.com/electron-userland/electron-builder/pull/8356
package.json
totype: module
.afterSign: notarize.js
using ESM imports.npx electron-builder --mac --universal --publish never
.