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

add liveReload option to enable/disable refreshing the page #1812

Closed
wants to merge 16 commits into from

Conversation

EslamHiko
Copy link
Member

@EslamHiko EslamHiko commented Apr 22, 2019

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

I'm not sure how i would test this feature except using the browser

Motivation / Use-Case

fixes #1744

Breaking Changes

No

Additional Info

live reloading is enabled by default

@codecov
Copy link

codecov bot commented Apr 22, 2019

Codecov Report

Merging #1812 into master will decrease coverage by 0.07%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1812      +/-   ##
==========================================
- Coverage   88.34%   88.26%   -0.08%     
==========================================
  Files          14       14              
  Lines         815      818       +3     
  Branches      258      260       +2     
==========================================
+ Hits          720      722       +2     
- Misses         82       83       +1     
  Partials       13       13
Impacted Files Coverage Δ
lib/Server.js 86.36% <100%> (+0.02%) ⬆️
lib/utils/createConfig.js 92.59% <50%> (-0.81%) ⬇️

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 2f56b18...22d5c98. Read the comment docs.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Need tests, thanks for PR, looks good

@EslamHiko
Copy link
Member Author

@evilebottnawi I couldn't find any way to test the actual code except using the browser and testing it manually, so I had to create a simple simulation it does exactly like what the actual code does. if you have any idea or examples to write a test to check if the page reloads or not it'll be very helpful to write a better test.

@EslamHiko
Copy link
Member Author

@evilebottnawi AppVeyor has a connection problem Could not resolve host: github.com Command exited with code 128 i think rerunning the test will solve it.

@hiroppy
Copy link
Member

hiroppy commented May 12, 2019

@EladBezalel We dropped travis and appveyor. Could you rebase?

@EslamHiko
Copy link
Member Author

@hiroppy I did a mistake in rebasing, can you please tell me the right way to rebase? and is everything ok or should I fix something?

@hiroppy
Copy link
Member

hiroppy commented May 12, 2019

The rebasing seems to be successful. However, CI fails.

FAIL test/options.test.js (39.888s)
  ● options › should match properties and errorMessage

    expect(received).toEqual(expected) // deep equality

    Expected: 57
    Received: 58

      14 |     const messages = Object.keys(options.errorMessage.properties);
      15 | 
    > 16 |     expect(properties.length).toEqual(messages.length);
         |                               ^
      17 | 
      18 |     const res = properties.every((name) => messages.includes(name));
      19 | 

      at Object.toEqual (test/options.test.js:16:31)

Please update test/options.test.js

lib/options.json Outdated
@@ -4,6 +4,15 @@
"after": {
"instanceof": "Function"
},
"serveIndex": {
Copy link
Member

Choose a reason for hiding this comment

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

Please delete here(master has already had serverIndex)

https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json#L282

Copy link
Member Author

Choose a reason for hiding this comment

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

Done :)

lib/options.json Outdated
"liveReload": {
"type": "boolean"
},
"hot": {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done :)

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Good job, small fixes

lib/Server.js Outdated
this.headers = this.options.headers;
this.progress = this.options.progress;
this.hot = options.hot || options.hotOnly;
this.liveReload = options.liveReload;
Copy link
Member

Choose a reason for hiding this comment

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

Don't use this.liveReload (this variables will be removed in next major release), please use this.options.liveReload in code

lib/Server.js Outdated
@@ -790,6 +791,10 @@ class Server {
this.sockWrite([connection], 'progress', this.progress);
}

if (this.liveReload !== false) {
Copy link
Member

Choose a reason for hiding this comment

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

this.options.liveReload

lib/Server.js Outdated
this.sockWrite(this.sockets, 'content-changed');
});
// disabling refreshing on changing the content
if (this.liveReload !== false) {
Copy link
Member

Choose a reason for hiding this comment

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

this.options.liveReload

lib/Server.js Outdated
@@ -95,7 +95,7 @@ class Server {

// TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property>
this.hot = options.hot || options.hotOnly;
this.liveReload = options.liveReload;
this.options.liveReload = options.liveReload;
Copy link
Member

Choose a reason for hiding this comment

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

No need this line after refactor, we already have this.options.liveReload

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

One note

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Good, let's wait CI green

@EslamHiko
Copy link
Member Author

EslamHiko commented May 13, 2019

@evilebottnawi coverage tests didn't pass so I did a small fix maybe using options instead of this.options caused the coverage tests to fail

@EslamHiko
Copy link
Member Author

@evilebottnawi anything i can modify or fix to pass the tests ?

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Need add test for https://github.com/webpack/webpack-dev-server/blob/master/test/CreateConfig.test.js, becase use should support --no-live-reload using CLI (no need tests for CLI)

@@ -88,6 +88,10 @@ function createConfig(config, argv, { port }) {
options.hotOnly = argv.hotOnly;
}

if (!options.liveReload) {
options.liveReload = argv.liveReload;
}
Copy link
Member

Choose a reason for hiding this comment

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

else if (argv.contentBase === false) {
we should test --no-live-reload because be default liveReload should be true

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

One note

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks good, due we don't have CLI tests, can you manually testing?

@EslamHiko
Copy link
Member Author

@evilebottnawi I tested it and it's working with me.

proof

@alexander-akait
Copy link
Member

Awesome thanks!

@EslamHiko
Copy link
Member Author

EslamHiko commented May 14, 2019

@evilebottnawi what went wrong? I think I missed to add a test to test false case in createConfig.test

@alexander-akait
Copy link
Member

@EslamHiko Awesome === Great/Good

@alexander-akait
Copy link
Member

Need update snapshot to fix CI problem

@EslamHiko
Copy link
Member Author

EslamHiko commented May 14, 2019

@evilebottnawi I updated my snapshot.

@hiroppy

This comment has been minimized.

@EslamHiko

This comment has been minimized.

@hiroppy
Copy link
Member

hiroppy commented May 15, 2019

@EslamHiko I did the following things

  • rebase and squash your commits (because we are going to squash commits before merging to master, and we have commitlint on CI)
  • delete updating snapshots commit
    • I forgot that the client code has changed in this PR, so I updated snapshots

thanks

@hiroppy
Copy link
Member

hiroppy commented May 15, 2019

yay, CI is green 🍏

@EslamHiko
Copy link
Member Author

EslamHiko commented May 15, 2019

@hiroppy 🎉 🎉 i hope everything is fine now 😄

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

/cc @hiroppy approve?

@alexander-akait
Copy link
Member

/cc @EslamHiko need rebase again, sorry

@alexander-akait
Copy link
Member

Close in favor #1889

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.

Nothing seems to disable file watching / hot reloading
4 participants