Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Webpack support - don't use require.resolve(), allow user to use it if necessary #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aguynamedben
Copy link

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: aguynamedben/electron-react-boilerplate#1

Before making this change, I would run into the problem documented here: electron-react-boilerplate/electron-react-boilerplate#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.

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.
@aguynamedben
Copy link
Author

Related issues in this repo:
#34
#26

@aguynamedben
Copy link
Author

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: webpack/webpack#1554 (comment)

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. :/

@aguynamedben
Copy link
Author

aguynamedben commented Jun 15, 2018

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).

@bitsmakerde
Copy link

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?

@Dolaned
Copy link

Dolaned commented Aug 9, 2018

i am also getting this issue.

@gen4sp
Copy link

gen4sp commented Sep 23, 2018

please, accept

@uholland
Copy link

Might this workaround the issue within the lib? Comment

@vherus
Copy link

vherus commented Mar 19, 2019

Please accept this PR

@vladejs
Copy link

vladejs commented Apr 9, 2019

What's left to accept this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants