You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow the code of conduct that this project follows, as appropriate.
I have searched the issue tracker for a bug that matches the one I want to file, without success.
Issue Details
Electron Forge Version:
6.0.0-beta.52
Electron Version:
v9.1.0
Operating System:
macOS 10.14.6
Last Known Working Electron Forge version::
--
Expected Behavior
preload script should use the target: 'electron-preload',
Actual Behavior
I am not sure if this is an expected behaviour or bug. I am porting my electron app to electron forge. In the app I have the nodeIntegration false and I expose some native features with a preload script. So basically the renderer will target will be similar to a modern browser.
When I tried the current default webpack configuration, the compiling fails with errors like
Uncaught ReferenceError: require is not defined
at Object.events (external "events":1)
at __webpack_require__ (bootstrap:789)
with which I came to a conclusion that the webpack is compiling the renderer code similar to a node environment, which actually is not a node environment as node integration is false (refer this comment)
then I tried setting target to web in webpack.renderer.config.js
Preflight Checklist
Issue Details
Expected Behavior
preload script should use the
target: 'electron-preload',
Actual Behavior
I am not sure if this is an expected behaviour or bug. I am porting my electron app to electron forge. In the app I have the nodeIntegration false and I expose some native features with a preload script. So basically the renderer will target will be similar to a modern browser.
When I tried the current default webpack configuration, the compiling fails with errors like
Uncaught ReferenceError: require is not defined at Object.events (external "events":1) at __webpack_require__ (bootstrap:789)
with which I came to a conclusion that the webpack is compiling the renderer code similar to a node environment, which actually is not a node environment as
node integration is false
(refer this comment)then I tried setting target to web in
webpack.renderer.config.js
that led me to this issue.
setting target in renderer config sets the same target for preload as well. when I dig into the codebase of Webpack plugin
this line 191 in this function is setting the same
web
target for preload as well.https://github.com/electron-userland/electron-forge/blob/d025878664a662a2c35cd1e140444b36a9f8dabb/packages/plugin/webpack/src/WebpackConfig.ts#L169-L191
Is this an expected behaviour? I think it's better to set
target: 'electron-preload',
for preload in this case as well.To Reproduce
Additional Information
N/A
The text was updated successfully, but these errors were encountered: