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 check for webpack/hot/log when setting HMR log level #1096

Merged
merged 2 commits into from Sep 20, 2017

Conversation

lbogdan
Copy link
Contributor

@lbogdan lbogdan commented Sep 16, 2017

What kind of change does this PR introduce?
Bugfix.

Did you add or update the examples/?
Not needed.

Summary
Some time ago I authored PR #926. Which, strangely enough, caused issue #1049.

The original code was

  var hotCtx = require.context("webpack/hot", false, /^\.\/log$/);
  if(hotCtx.keys().length > 0) {
    hotCtx("./log").setLogLevel(level);
  }

Somehow I was under the impression that hotCtx.keys() can only return [] or ["./log"], and with this assumption, the check hotCtx.keys().length > 0 is correct. For some strange reason, as per issue #1049, it returned ["../package.json", "./console", "./formatters"], which doesn't match the regex at all, so I don't really know what happened there. In this case, of course, the check becomes wrong.

Now, this is the fix for #1049 in PR #1050

  if(hotCtx.keys().length > 0) {
    var contextKeys = hotCtx.keys();
    if(contextKeys.length && contextKeys["./log"]) {
      ...

which doesn't work, because contextKeys is an array, so contextKeys["./log"] will always be false.

So the correct check would be if (hotCtx.keys().indexOf('./log') !== -1) { ....

Does this PR introduce a breaking change?
No.

@lbogdan
Copy link
Contributor Author

lbogdan commented Sep 16, 2017

Cc @johan-lejdung.

@johan-lejdung
Copy link
Contributor

Ah damn, of course it's an array.. Don't know what I was thinking :) If I could, I would approve this change!

The build seems to fail, but not related to this file. There seem to be a linting error in Server.js:

/home/travis/build/webpack/webpack-dev-server/lib/Server.js
  142:17  error  Strings must use singlequote  quotes
✖ 1 problem (1 error, 0 warnings)
  1 error, 0 warnings potentially fixable with the `--fix` option.

@lbogdan
Copy link
Contributor Author

lbogdan commented Sep 16, 2017

What's even stranger is that it fails only on node 6 and 4, 8 is ok. 😄

@johan-lejdung
Copy link
Contributor

Quickly looked through the changelog for node 8 and there were a lot of Array changes, maybe they allow such access now.

@lbogdan
Copy link
Contributor Author

lbogdan commented Sep 16, 2017

That's an eslint error, so I don't see any reason why it would work differently in node 8 vs. node 4 or 6. Anyway, fixed it in #1098.

@lbogdan lbogdan mentioned this pull request Sep 16, 2017
@codecov
Copy link

codecov bot commented Sep 18, 2017

Codecov Report

Merging #1096 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1096   +/-   ##
=======================================
  Coverage   71.92%   71.92%           
=======================================
  Files           5        5           
  Lines         463      463           
  Branches      148      148           
=======================================
  Hits          333      333           
  Misses        130      130

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bad7ed5...0cd7039. Read the comment docs.

@lbogdan
Copy link
Contributor Author

lbogdan commented Sep 20, 2017

Any news on this?

@shellscape
Copy link
Contributor

@lbogdan you're a rock star for getting these fixes in. very much appreciated! but I beg of you some additional patience please 😄 we're all human on this side, and to say the last two weeks have been personally trying would be an understatement. please note that it may take a week or so to get a patch release out. I'll be out of town and I don't like to release unless I'm around to put out any fires that pop up.

@shellscape shellscape merged commit 114e67c into webpack:master Sep 20, 2017
@lbogdan
Copy link
Contributor Author

lbogdan commented Sep 21, 2017

@shellscape Thank you for your kind words, they might not necessarily reflect the reality! 😄
That was just a follow up, sorry if I came off as impatient, I was just curious about an update. I know OSS is made out of people's personal time, and I really appreciate these people and their hard work!

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.

None yet

3 participants