-
Notifications
You must be signed in to change notification settings - Fork 27
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
"unable to load preload script" error when changing contextIsolation to true and nodeIntegration to false #30
Comments
Hi @jjeff ! In this repo: https://github.com/raphael10-collab/bytenode-contextIsolationTrue-electron-forge-typescript-webpack As you explained here: #29 (comment) Bytenode always require Node to work. If I want to keep for good electron safety practice - https://www.electronjs.org/docs/latest/tutorial/security - I've set up my preload.ts script as follows:
What should I practically add to the above |
You might want to play with https://github.com/spaceagetv/electron-bytenode-example and try different configurations in a simplified environment. I have yet to implement Electron security best practices in that repo, but I think it can be done. In most of my applications, I'm not loading untrusted web pages into my renderers, so I'm okay without context isolation enabled.
I don't know if there's anything you need to add to the preload script to compile it with Bytenode. You just need to configure webpack to compile preload scripts. If you're asking if it's possible to move your renderer script code into your preload script so that it will be compiled, the answer is usually "yes". The main trick is to use the |
I've set And I've configured But it does not work I've updated the repo in github: https://github.com/raphael10-collab/bytenode-contextIsolationTrue-electron-forge-typescript-webpack.git to contain all these aforementioned trials So, I guess there is something missing, in order to make |
setting :
yields this error : I've updated the repo in github: https://github.com/raphael10-collab/bytenode-contextIsolationTrue-electron-forge-typescript-webpack.git to contain all these aforementioned trials The best would be to be able to set
while being able to use |
Just my two cents; I've spent a few weeks this year (yes... full time 😅) trying to get bytenode to work with What did work was to make a fork of bytenode that strips the 'encoding' bits from the library, and only leave the decoding bits. This is done in electron-vite as well, and in the end I migrated from webpack to vite so as to not manage all this myself. |
Duplicate of #28 |
I git cloned and started https://github.com/herberttn/bytenode-webpack-plugin/tree/main/examples/electron-forge-typescript-webpack
I tried to change the
contextIsolation
and thenodeIntegration
settings respectively totrue
andfalse
:with
preload.ts
:But, after this change, I get this error:
unable to load preload script
what am I missing ? How to make it work?
The text was updated successfully, but these errors were encountered: