electron-remote
electron-remote copied to clipboard
Webpack support - don't use require.resolve(), allow user to use it if necessary
The README and in-code comment instructs users they may need to use require.resolve() to provide the correct path to requireTaskPool.
This is a problem for Webpack users because Webpack rewrites require.resolve().
Removing require.resolve() enables Webpack users to use electron-remote.
I'm not sure, but I think for some users who implicitly depend on the current behavior of electron-remote require.resolve()-ing for them, this may be a breaking change.
Here is an example that integrates electron-remote with electron-react-boilerplate project, which uses Webpack to produce the main process and renderer code: https://github.com/aguynamedben/electron-react-boilerplate/pull/1
Before making this change, I would run into the problem documented here: https://github.com/chentsulin/electron-react-boilerplate/issues/1587
Please let me know if there is a better way to fix this. From what I can tell, require.resolve()
(from Node) is overwritten by Webpack.
Related issues in this repo: https://github.com/electron-userland/electron-remote/pull/34 https://github.com/electron-userland/electron-remote/pull/26
The core of the issue here (from what I can tell) is that require.resolve()
behaves differently in Webpack than it does in Node.js. This comment nails it: https://github.com/webpack/webpack/issues/1554#issuecomment-158679844
This doesn't work.
require.resolve returns the module identifier according to CommonJS. In node.js this is the filename. In webpack this is a number.
I think this means any Node.js/Electron library that uses require.resolve()
isn't going to play nicely with Webpack. :/
Development note: when npm/yarn linking, be sure to ./build.sh the code after making changes. And with the electron-react-boilerplate project, electron-remote should be added to app/package.json, not package.json, and you should yarn link
against app/package.json! (it's easy to accidentally yarn link
to the wrong set of dependencies).
Hi,
i'm using web pack and i doesn't can use electron-remote. in which version is this feather?
How i can use it in beta?
i am also getting this issue.
please, accept
Might this workaround the issue within the lib? Comment
Please accept this PR
What's left to accept this?