-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(client): add clientMode option #1977
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1977 +/- ##
==========================================
+ Coverage 92.71% 92.75% +0.03%
==========================================
Files 31 32 +1
Lines 1181 1201 +20
Branches 329 335 +6
==========================================
+ Hits 1095 1114 +19
- Misses 82 83 +1
Partials 4 4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, one note.
/cc @hiroppy
lib/options.json
Outdated
@@ -390,6 +393,7 @@ | |||
"ca": "should be {String|Buffer}", | |||
"cert": "should be {String|Buffer}", | |||
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)", | |||
"clientMode": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserverclientmode-)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra -
at end of line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to modify this? L437 was fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to modify this? L437 was fixed it.
Yes, I mistakenly did not remove that -
, but they should be removed in both places.
CI fails. options validation clientMode
|
|
I'm now wondering why this empty string is passing this test: https://github.com/webpack/webpack-dev-server/blob/master/test/options.test.js#L350. Because that should not be throwing a |
/cc @Loonride need rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note
); | ||
} | ||
|
||
updateCompiler(this.compiler, this.options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we move this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evilebottnawi I reorganized it to have the default setting for serverMode
and clientMode
together above that. updateCompiler
uses this.options.clientMode
, so the default setting for it must be set before updateCompiler
is called. It can be switched back, I just thought it would be nice to have default setting for serverMode
and clientMode
right next to one another
db1067c
to
ee8a4b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @hiroppy
test/e2e/ClientMode.test.js
Outdated
describe('sockjs', () => { | ||
beforeAll((done) => { | ||
const options = { | ||
port: 9000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hiroppy done
ee8a4b2
to
a80df52
Compare
"liveReload", | ||
"[WDS] Live Reloading enabled.", | ||
"hash", | ||
"ok", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't onClose
called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hiroppy testServer.close
happens after the snapshot is tested, so the client is not closed before that. I could maybe rearrange that to test onClose
as well.
/cc @Loonride need rebase, great job! |
ab19944
302b26a
to
bdbe023
Compare
bdbe023
to
5745e7d
Compare
@evilebottnawi @hiroppy Can I get a final review for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @hiroppy
/cc @evilebottnawi |
For Bugs and Features; did you add new tests?
Yes
Motivation / Use-Case
This option makes it possible to provide a custom client socket implementation.
This mimics the
serverMode
implementation with one exception:clientMode
does not accept a function (specifically, a class, asserverMode
does). The reason for this is that it is not possible (or just pointlessly complex and impractical) to make a class within an executing server-side script, then pass it along to the client. There must be a path to the file thatmodule.exports
the client implementation.Since the only thing we really need to pass to the client is the path to the implementation, I made the helper
getSocketClientPath
. There is no reason for a helper to be returning the wholeClientImplementation
class, since it is not actually used server-side.Breaking Changes
None
Additional Info
One consideration:
Should more error handling be added to confirm that the
serverMode/clientMode
are implemented correctly? For example, there could be some functionality in the Dev Server that tests the contents ofClientImplementation.protoype
, to see if all the required functions are implemented.