Skip to content

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

Closed
EslamHiko wants to merge 16 commits into
webpack:masterfrom
EslamHiko:add-live-reload-option
Closed

add liveReload option to enable/disable refreshing the page#1812
EslamHiko wants to merge 16 commits into
webpack:masterfrom
EslamHiko:add-live-reload-option

Conversation

@EslamHiko

@EslamHiko EslamHiko commented Apr 22, 2019

Copy link
Copy Markdown
Contributor
  • 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

codecov Bot commented Apr 22, 2019

Copy link
Copy Markdown

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.

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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

hiroppy commented May 12, 2019

Copy link
Copy Markdown
Contributor

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

@EslamHiko EslamHiko force-pushed the add-live-reload-option branch from 4d7afe0 to 0285f1d Compare May 12, 2019 16:30
@EslamHiko

Copy link
Copy Markdown
Contributor 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

hiroppy commented May 12, 2019

Copy link
Copy Markdown
Contributor

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

Comment thread lib/options.json Outdated
"after": {
"instanceof": "Function"
},
"serveIndex": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

Comment thread lib/options.json Outdated
"liveReload": {
"type": "boolean"
},
"hot": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good job, small fixes

Comment thread 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
Copy Markdown
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

Comment thread lib/Server.js Outdated
this.sockWrite([connection], 'progress', this.progress);
}

if (this.liveReload !== false) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this.options.liveReload

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this.options.liveReload

Comment thread lib/Server.js Outdated
// 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
Copy Markdown
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

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One note

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

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

EslamHiko commented May 13, 2019

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor Author

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

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread lib/utils/createConfig.js

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

Copy link
Copy Markdown
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

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One note

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

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

proof

@alexander-akait

Copy link
Copy Markdown
Member

Awesome thanks!

@EslamHiko

EslamHiko commented May 14, 2019

Copy link
Copy Markdown
Contributor Author

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

@alexander-akait

Copy link
Copy Markdown
Member

@EslamHiko Awesome === Great/Good

@alexander-akait

Copy link
Copy Markdown
Member

Need update snapshot to fix CI problem

@EslamHiko

EslamHiko commented May 14, 2019

Copy link
Copy Markdown
Contributor Author

@evilebottnawi I updated my snapshot.

@hiroppy

This comment has been minimized.

@EslamHiko

This comment has been minimized.

@hiroppy hiroppy force-pushed the add-live-reload-option branch from 46b1f70 to cadee8b Compare May 15, 2019 19:43
@hiroppy

hiroppy commented May 15, 2019

Copy link
Copy Markdown
Contributor

@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

hiroppy commented May 15, 2019

Copy link
Copy Markdown
Contributor

yay, CI is green 🍏

@EslamHiko

EslamHiko commented May 15, 2019

Copy link
Copy Markdown
Contributor Author

@hiroppy 🎉 🎉 i hope everything is fine now 😄

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

/cc @EslamHiko need rebase again, sorry

@alexander-akait

Copy link
Copy Markdown
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