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

cli: fix watch options for array config #892

Merged
merged 1 commit into from May 27, 2019

Conversation

curiouslychase
Copy link
Contributor

@curiouslychase curiouslychase commented May 24, 2019

What kind of change does this PR introduce?
bugfix

Did you add tests for your changes?
nope! I didn't see any existing tests for processOptions.

If relevant, did you update the documentation?
I did not, but this should make the current docs on the watch options true for Webpack configs that are arrays.

Summary

webpack/webpack#4594 points out that watch options aren't being honored when the
Webpack config is an Array. In cases when it's an array, there may not
be a firstOptions.watchOptions, but there will be an options.watchOptions.

In the current implementation, when the Webpack compiler watch method is
called with watchOptions and the Webpack config is an array, watchOptions
will be true and not an object.

I should also note that I don't have a ton of context into the intentions behind using the watch (which is a boolean) in the case that the other options are absent, and an object if watch is false on both options and firstOptions, so at the very least my goal with this PR is to give someone who has better context the information I found so that they can make a good decision on what's best to do here.

webpack/webpack#4594 (not open, but still broken)

  • I also noticed that although the above issue was specific to docker + Windows 10, this isn't working as expected in any system I've tested (in a Docker container, locally on MacOS) when the Webpack config export is an array.

Does this PR introduce a breaking change?

It does not, this should be a seamless fallback in the case when the Webpack config is an array instead of an object that does the right thing when the CLI has watch-* flags.

Testing/Repro

yarn run webpack-watch-poll-cfg
yarn run v1.9.4
$ webpack --watch --config webpack-poll.config.js
watch options in compiler: { poll: 1000 }
  • Ran webpack-watch-poll-cli from the example repo to verify the watchOptions from a CLI flag (--watch-poll) was incorrect (with an Array config):
yarn webpack-watch-poll-cli
yarn run v1.9.4
$ webpack --watch --watch-poll=500 --config webpack-basic.config.js
watch options in compiler: true
watch options in compiler: true
yarn webpack-watch-poll-cli
yarn run v1.9.4
$ webpack --watch --watch-poll=500 --config webpack-basic.config.js
watch options in compiler: { poll: 500 }

@jsf-clabot
Copy link

jsf-clabot commented May 24, 2019

CLA assistant check
All committers have signed the CLA.

@webpack-bot
Copy link

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@anshumanv
Copy link
Member

Please sign the CLA :)

@curiouslychase
Copy link
Contributor Author

curiouslychase commented May 24, 2019

@anshumanv per the CLA assistant page I have signed it (I did so as soon as I opened the PR), here's a screenshot of what I see when I visit the link from here (with my email obfuscated):
image

Any tips on what I can do to reset and re-sign so that it shows correctly are appreciated!

Update: it looks like others have seen this too, I've opened an issue to see if I can figure out what happened and get it squared away here. I force pushed a rebase & that did the trick.

@anshumanv
Copy link
Member

Thanks @chaseadamsio, can you try closing and reopening this PR?
I think it will run a fresh check on doing so.

Issue #4594 points out that watch options aren't being honored when the
Webpack config is an Array. In cases when it's an array, there may not
be a firstOptions.watchOptions, but there will be an options.watchOptions.

In the current implementation, when the Webpack compiler watch method is
called with watchOptions and the Webpack config is an array, watchOptions
will be `true` and not an object.
@anshumanv
Copy link
Member

It worked! 💯

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you so much for the Pull Request. Well thorough Pull Request description and elaboration. ✅

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

Successfully merging this pull request may close these issues.

None yet

8 participants