Electron preload w/ Bytenode encoded renderer
See original GitHub issueRunning into issues using a preload
script in Electron with Bytenode encoded renderer files.
Contextisolation is enabled, hence require
is not available in index.html in renderer, so the renderer jsc
files can’t be decoded there (which is what I did before using preload).
Moved this to my preload
script:
contextBridge.exposeInMainWorld(
'api',
{
view: () => {
const bytenode = require('bytenode');
return require('./path/to/my.jsc');
}
}
);
I can then trigger this via IPC from the renderer:
<script defer>
window.api.view();
</script>
This does work (I see some of the app’s console logs), but the problem is that the jsc
file is now being executed in the context of the preload
script and NOT in the browser window, hence all other calls to the preload’s api
object (from the app) do NOT work, which is what my app needs.
Any solution for this ?
I also tried using bytenode.runBytecodeFile()
and bytenode.runBytecode()
, could not get this to work.
Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:22
Top GitHub Comments
I’m still leaning towards NW.js. If I have to choose between them I would go with NW.js for sure.
But before taking this decision, I would also study the security vulnerabilities (an example here) in Electron and figure out their counterparts in NW.js and how to deal with them.
I have not. I have no experience with Electron so far other than trying to solve bytenode’s issues.
@OsamaAbbas
btw, I happened to stumble across your NW.js vs. Electron comparison on hackermoon from 2018 (appreciate the write up and comparison). I know this is off topic here, but since this is closed, maybe I can ask a couple of q’s: 😉
(1) is there an updated version of this comparison ? is your opinion the same today ? (2) have you ever written a blog post about migrating from Electron to NW.js or have you ever have to migrate one to the other ?
Looking into other options again re our latest discussions. Appreciate the feedback and advise shared.