Skip to content
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

fix: resolve custom commonSourceDir before setting up watch plugin #235

Closed
wants to merge 1 commit into from

Conversation

stristr
Copy link
Contributor

@stristr stristr commented Nov 20, 2018

This fixes at least one of the issues in #84 that was affecting my project—the WatchFilterPlugin is set up to rely on absolute paths in order to behave as expected, and this breaks HMR when commonSourceDirectory is specified at all.

Note: I have a setup that looks like this (common when using Lerna/Yarn workspaces in a monorepo):

project/
└── packages
    ├── common-lib-1
    ├── common-lib-2
    ├── electron-app-1
    └── electron-app-2

In this case, I actually want my commonSourceDirectory to be ".." (I'm running electron-webpack out of e.g. project/packages/electron-app1), which fully breaks HMR. I considered adding a new config option like watchDirectories: string[] and changing the logic to not overload the meaning of commonSourceDirectory, but I think this is clean enough for all the use cases I can think of. @develar, please LMK if you prefer something else!

@develar
Copy link
Member

develar commented Nov 20, 2018

Thanks for digging it! Hmm... the question is why here we have not resolved path. I think, our config resolver should resolve it, so, we can be sure that the same correct path is used in all functionality.

@stristr
Copy link
Contributor Author

stristr commented Nov 20, 2018

Ah, okay. I think this is because configurator.commonSourceDirectory is the pre-resolved thing we actually want to use if the option is provided at all. I updated and force pushed to do that instead 😄

@develar develar closed this Nov 22, 2018
@stristr
Copy link
Contributor Author

stristr commented Nov 22, 2018

Sorry if my last comment was unclear, @develar! This PR has been updated to reflect a change which is still necessary in order for HMR to work when configurator.commonSourceDirectory is set to a relative path. So it still should be reviewed/merged.

The problem is that the filter plugin is using configurator.electronWebpackConfiguration.commonSourceDirectory instead of configurator.commonSourceDirectory, which is the pre-resolved path we want.

@develar
Copy link
Member

develar commented Nov 22, 2018

@stristr PR merged with some my changes :) See ae2a2f1 and release https://github.com/electron-userland/electron-webpack/releases/tag/v2.6.1

@stristr
Copy link
Contributor Author

stristr commented Nov 22, 2018

Nice—this release works in my project!

Thank you very much for the quick release.

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

Successfully merging this pull request may close these issues.

2 participants