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
feat: deprecate setup in favor of before and after hooks #1108
feat: deprecate setup in favor of before and after hooks #1108
Conversation
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.
looks like there's some test failures to address as well
lib/Server.js
Outdated
@@ -323,7 +323,9 @@ function Server(compiler, options) { | |||
|
|||
middleware: () => { | |||
// include our middleware to ensure it is able to handle '/index.html' request after redirect | |||
if (typeof options.before === 'function') { options.before(app, 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.
preferably we'd follow the same pattern established on line 342 with the setup
middleware. 'before'
would be inserted into that array before setup
and after
would be added to the array before line 355
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.
Fixed!
I've changed the example for middleware as well, saw that one was using the setup
hook which is now the before
hook.
fd842ed
to
89ae007
Compare
Codecov Report
@@ Coverage Diff @@
## master #1108 +/- ##
=========================================
+ Coverage 71.92% 72% +0.08%
=========================================
Files 5 5
Lines 463 468 +5
Branches 148 151 +3
=========================================
+ Hits 333 337 +4
- Misses 130 131 +1
Continue to review full report at Codecov.
|
89ae007
to
546adaa
Compare
lib/Server.js
Outdated
if (typeof options.setup === 'function') { options.setup(app, this); } | ||
} | ||
}; | ||
|
||
const defaultFeatures = ['setup', 'headers', 'middleware']; | ||
if (options.proxy) { defaultFeatures.push('proxy', 'middleware'); } | ||
const defaultFeatures = ['before', 'setup', 'headers', 'middleware', 'after']; |
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.
after
shouldn't be here. same goes for the changes on lines 353, 357. rather, it should be pushed to defaultFeatures
before line 365 - just before the forEach
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.
Fixed.
546adaa
to
febf76f
Compare
if (typeof options.setup === 'function') { options.setup(app, this); } | ||
} | ||
}; | ||
|
||
const defaultFeatures = ['setup', 'headers', 'middleware']; | ||
const defaultFeatures = ['before', 'setup', 'headers', 'middleware']; |
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.
@shellscape @mrtnbroder doesn't setup being in this array mean that everyone will see the deprecation warning no matter what? Shouldn't it not be in there but one of the things below this say if(options.setup) defaultFeatures.push('setup')
or something? (or maybe keep it in but if options.setup is absent then remove it).
It seems that the loop on line 367 will always run the deprecation warning.
I'm asking because when i upgraded to 2.9 i noticed the deprecation warning even though I don't use this hook at all (though it may just be that a dependency of mine needs upgrading. I'm not totally sure)
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.
either that or putting the logs on lines 346-347 inside the if on line 348
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.
I made #1120 for this
It took me a while to track down where this error was coming from. Please add a link to the changelog in the error message (or at least include the text |
@cletusw double posting the same comment in multiple places is generally frowned upon, please avoid that in the future (referencing your copied comment on 8de5d0a). logging in the module will be getting an overhaul in v3. the message being shown isn't an error message; it's a vanilla log message. Deprecation warnings are never error messages. |
@shellscape Sorry, I didn't realize that you were also on this issue. Sorry for the double post. |
As for error vs. log, I guess my original message wasn't entirely clear. What I meant was, I saw the log text, but I had no idea how to fix it since it wasn't at all clear which |
|
Not sure what you mean. Are you saying the deprecation warning will be ambiguous until v3 at which time it will change to say |
agreed about the log prefix. most log messages I've seen from webpack dev server start with [WDS]. I spent about 20 minutes this morning googling and searching to see where the warning came from because it's just a random error in the console. It seems like a simple enough change that it shouldn't have to wait until V3's log overhaul. People are going to start seeing the deprecation warning soon and have no idea where it's coming from. @shellscape Would a PR to add [WDS] be approved? |
@bdwain very much appreciate the initiative, but we're about to announce a new feature freeze to focus on v3.0.0, and logging throughout the entire module needs improvement as it has the same/similar shortcomings. you can follow progress on v3 here. I won't comment yet on what that will entail because we haven't had time to vet all of the available options. in the meantime we ask for patience. |
I would suggest removing this message then. As it is it is unactionable and
will generate lots of confusion.
…On Wed, Sep 27, 2017, 5:47 PM Andrew Powell ***@***.***> wrote:
@bdwain <https://github.com/bdwain> very much appreciate the initiative,
but we're about to announce a new feature freeze to focus on v3.0.0, and
logging throughout the entire module needs improvement as it has the
same/similar shortcomings. you can follow progress on v3 here
<https://github.com/webpack/webpack-dev-server/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22Version+3%22>.
I won't comment yet on what that will entail because we haven't had time to
vet all of the available options. in the meantime we ask for patience.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1108 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA0prrc7xRfusLcDp3jN6o26N8_E0NDLks5smt6ngaJpZM4Pdcue>
.
|
@cletusw I think you've made your position abundantly clear 😄 The change will stand as-is for the moment. I'll likely abstain from commenting on this PR moving forward, but please feel free to continue the discussion. |
`setup` was deprecated in webpack/webpack-dev-server#1108
What kind of change does this PR introduce?
feature
Did you add or update the
examples/
?yes,
examples/node-api-middleware
Summary
fixes #869
Does this PR introduce a breaking change?
Not a breaking change, but a deprecation.
Other information
see #869