Can not import a js file from asar
i-xiao-zi opened this issue · 1 comments
i-xiao-zi commented
code:
ipcMain.handle('plug:exec', async (_, cmd: string, ...args: any[]) => {
if (cmd && MainWindow.plug){
const ipcPlugPath = await getIpcPlugPath(MainWindow.plug);
console.log(MainWindow.plug, ipcPlugPath);
console.log(path.dirname(ipcPlugPath), fs.readdirSync(path.dirname(ipcPlugPath)))
if (ipcPlugPath) {
return import(ipcPlugPath).then( (imp:{[key: string]: (args:any[])=>{}}) => {
if(imp.hasOwnProperty(cmd)){
return imp[cmd](...args)
}
}).catch(e =>console.log({exec: e}));
}
}
});
log:
[2023-08-01 21:30:16.960] [info] desktop G:\yun\app_frame\release\build\win-unpacked\resources\plugs\desktop.asar\main.js
[2023-08-01 21:30:16.960] [info] G:\yun\app_frame\release\build\win-unpacked\resources\plugs\desktop.asar [
'bundle.js',
'bundle.js.LICENSE.txt',
'bundle.js.map',
'favicon.ico',
'index.html',
'logo.png',
'main.js',
'main.js.map',
'manifest.json',
'robots.txt',
'static'
]
[2023-08-01 21:30:16.961] [info] {
exec: "Error: Cannot find module 'G:\\yun\\app_frame\\release\\build\\win-unpacked\\resources\\plugs\\desktop.asar\\main.js'\n" +
' at G:\\yun\\app_frame\\release\\build\\win-unpacked\\resources\\app.asar\\dist\\main\\main.js:2:502273'
}