Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not import a js file from asar #276

Closed
i-xiao-zi opened this issue Aug 1, 2023 · 1 comment
Closed

Can not import a js file from asar #276

i-xiao-zi opened this issue Aug 1, 2023 · 1 comment

Comments

@i-xiao-zi
Copy link

i-xiao-zi commented Aug 1, 2023

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'
}

@erikian
Copy link
Member

erikian commented Oct 15, 2023

Duplicate of #249

@erikian erikian marked this as a duplicate of #249 Oct 15, 2023
@erikian erikian closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants