I am using @mikro-orm/migrations in my Electron app, I created migration files and want to run the database migrations in production mode, while at the same time, I also want to enable asar packaging in Electron to improve the app launch speed.
If I don't enable asar packaging, the folder structure is as below, and everything is working fine:
app/node_modules/@mikro-orm
app/node_modules/...
app/migrations/Migration20220224172334.js
While with asar packaging enabled, the folder structure becomes:
app.asar // this is a package with all node modules
app.asar.unpacked/migrations/Migration20220224172334.js
As a result, I am getting error like Cannot find module '@mikro-orm/migrations'
while load Migration20220224172334.js
, here is the content of the migration script:
const { Migration } = require('@mikro-orm/migrations');
class Migration20220224172334 extends Migration {
...
I think this question is to either Electron developers or Mikro ORM developers.
Is there a way to programmatically load node modules inside asar package from an external JS file?
Is it possible to bundle migration scripts into asar and at the same time having Mikro ORM to search them inside asar package?