Currently, we are using electron-builder@23.5.1 which is using @electron/universal. Recent versions of electron-builder enable mergeASARs which cause issues with native dependencies: @electron/universal does not contruct app.asar.unpacked correctly after processing.
Details
To support native dependencies (e.g. better-sqlite3), we unpack the executable binaries from app.asar, thus we have a structure like this for each package (arm64 and x64).
The unpack value is incorrect as asar does not unpack any files. app.asar.unpacked remains the pre-processed directory of x64.
After debugging, this is what I've found:
The path of better-sqlite3 is '/var/folders/9q/565lwvz54k7529bzvbyqpz040000gn/T/x64-0QZm6y/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
The value of unpack is '{/var/folders/9q/565lwvz54k7529bzvbyqpz040000gn/T/x64-0QZm6y/node_modules/better-sqlite3/build/Release/better_sqlite3.node}' (with the curly brackets).
Currently, we are using
electron-builder@23.5.1
which is using@electron/universal
. Recent versions ofelectron-builder
enablemergeASARs
which cause issues with native dependencies:@electron/universal
does not contructapp.asar.unpacked
correctly after processing.Details
To support native dependencies (e.g.
better-sqlite3
), we unpack the executable binaries fromapp.asar
, thus we have a structure like this for each package (arm64 and x64).@electron/universal
will then runlipo
to mergebetter-sqlite3.node
in arm64 and x64 together to generate universalbetter-sqlite3.node
. This step works correctly. https://github.com/electron/universal/blob/3a30fe989bee57d93b3da7beb9e9bf8ca29639fc/src/asar-utils.ts#L186Nevertheless, when it generates the ASAR file with universal bindings,
The
unpack
value is incorrect asasar
does not unpack any files.app.asar.unpacked
remains the pre-processed directory of x64.After debugging, this is what I've found:
better-sqlite3
is'/var/folders/9q/565lwvz54k7529bzvbyqpz040000gn/T/x64-0QZm6y/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
unpack
is'{/var/folders/9q/565lwvz54k7529bzvbyqpz040000gn/T/x64-0QZm6y/node_modules/better-sqlite3/build/Release/better_sqlite3.node}'
(with the curly brackets).=>
minimatch(filename, options.unpack, { matchBase: true })
(https://github.com/electron/asar/blob/db6d1541be05f67933f07c6f30d2425a05f13182/lib/asar.js#L123) returnsfalse
, causing the file not to be unpacked.Debugging Logs
Binding in tmp destination (used during ASAR merging process) => universal
Binding in final destination =>
x64
onlyminimatch
outputfalse
@mmaietta