-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
Not possible to disable nodeIntegration
when using webpack plugin
#1636
Comments
@b-zurg |
@malept Is this a bug? based on the webpack docs , the target
So if the nodeIntergration is false, it shoudn't add NodeTargetPlugin etc. But based on a quick sample project I generated from the latest webpack template. When nodeIntegration is false It breaks with showing errors like Uncaught ReferenceError: require is not defined
at Object.events (external "events":1)
at __webpack_require__ (bootstrap:789) that means the webpack is considering it as a node environment which actually is a non-node env. So is there something missing which sets the correct environment for the renderer based on the nodeIntegration ? |
I'm honestly not sure. Would have to check the webpack docs. |
Hi, I get Maybe we should use umd instead of cjs, |
I am getting Is there some workaround I can take to solve it currently? |
@linonetwo, @gyzerok, and @b-zurg Not sure if you ever got this working, but I just spent the last couple of days solving a similar issue, and here is what worked for me:
Hope that helps 🙂 Feel free to let me know if you run into any issues 🙂 |
This was implemented in #2330 |
Preflight Checklist
Issue Details
Expected Behavior
Problem Description
The ease of use of having a preload script with the webpack plugin is great and I was very hopeful it would allow me to set
nodeIntegration
to false so that I could follow electron's security recommendations, however this seems to be quite impossible. This is simply because the target is set in the plugin for the renderer to beelectron-renderer
which, according to [webpack's docs[(https://webpack.js.org/configuration/target/) is intended to target node for ease of bundling.This means that the bundled webpack code will expect node and not be able to run and load modules etc..
Proposed Solution
There should be a configuration for every renderer entry point called
nodeIntegration
that could be set to false that would then set the following webpack properties:As I understand this is basically bundling the code as if it were to run in the browser.
Alternatives Considered
I'm not totally clear what would be a better solution than this. Open to suggestions.
Additional Information
This is part of a larger question of this framework supporting the best security recommendations from electron. As I understand as of now this is to turn off
nodeIntegration
at the least but there are other recommendations that would be ideally easily supported by such an easy to use framework as this.In general this would encourage electron developers to follow best practices.
The text was updated successfully, but these errors were encountered: