-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Update webpack peerDependency in v1-stable branch to v4.x #265
Conversation
travis is failing here because node 4 is no longer supported by webpack. however I don't think this is an issue because those using webpack-dev-middleware can still use older versions of webpack that support older node versions. this isn't actually a breaking change, just an internally breaking change since the tests now target webpack v4. |
@@ -1,7 +1,6 @@ | |||
sudo: false | |||
language: node_js | |||
node_js: | |||
- "4" |
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.
unfortunately we can't remove the Node v4 tests for v1.x of the module.
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.
Webpack v4 does not support node 4. We could continue to keep the devDependency
at webpack v3.x for the sake of these tests though.
All I really wanted to do is update the peerDependency
to allow for v4.x.
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.
Well in fairness, you can't remove a node dependency in a patch for major version that previously supported it. That's a massive semver violation, and that's why v2.x dropped support for it. Node 4 will have to stay and you'll have to find a way to not run webpack v4 tests on that node version. These are the things that bite you when trying to update an old version instead of upgrading.
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.
We aren’t actually removing support for node 4 with this change. We just wouldn’t be running tests against it (because that is not possible with webpack v4). If we kept webpack v3 as the devDependency
version we could keep running tests against node v4.
Really this situation isn’t dissimilar from what you’re already practicing. Webpack-dev-middleware technically supports webpack v1 and v2 but no tests are run for these versions... ¯_(ツ)_/¯
@@ -45,7 +45,7 @@ describe("Server", function() { | |||
it("GET request to bundle file", function(done) { | |||
request(app).get("/public/bundle.js") | |||
.expect("Content-Type", "application/javascript; charset=UTF-8") | |||
.expect("Content-Length", "2823") |
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.
is this change specific to webpack@4?
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.
Yes, the Content-Length
changed because webpack v4’s runtime code has changed between versions and now takes up a bit more space.
@@ -138,7 +138,7 @@ describe("Server", function() { | |||
|
|||
it("GET request to bundle file", function(done) { | |||
request(app).get("/bundle.js") | |||
.expect("Content-Length", "2823") |
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.
is this change specific to webpack@4?
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.
same as above 👆🏻
context: __dirname, | ||
entry: "./foo.js", | ||
output: { | ||
filename: "bundle.js", | ||
path: "/" | ||
}, | ||
module: { | ||
loaders: [ | ||
rules: [ |
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.
is this change specific to webpack@4?
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.
Actually this schema name change started in webpack v2 (loaders
was deprecated in favor of rules
), but it wasn’t removed until v4.
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.
OK this change can stick around
@shellscape here’s my thoughts. Unfortunately while webpack-dev-middleware appears to be compatible with webpack v2 through v4, we can only run our tests against one version of webpack at a time because we can only specify a single version in our However there is no reason we cannot add v4.x as a valid Let me know how you’d like me to proceed. |
You're going to have to do a few things here to get this pushed through:
To get the webpack version: const webpackPackage = require('webpack/package.json');
const webpackVersion = parseInt(webpackPackage.version, 10); I've never setup a complex travis config like what's needed here, but I do have several modules running against webpack v3 and v4. Since webpack@3 is the default devDep, script:
- npm run ci # run linting and testing, generate coverage
- npm install webpack@latest # install webpack@4
- npm run mocha # run mocha tests against webpack@3, without coverage
It's a lot, but we can't just shoehorn support in without being absolutely sure that we're not breaking a (past) major version. The one thing not covered here is why you haven't upgraded to v2 and called it a day. |
I can do this if it is what you require, however as I mentioned earlier it doesn’t look like this approach was taken for support of webpack v1 and v2. Both of these are supported as |
I wasn't a maintainer for the versions that covered webpack v1 an v2 😄 and no version has been as disruptive as webpack v4 to date. Releasing new major versions is how we support the new majors of the primary dependencies. Is it worth the time to do all of this, or simply upgrade to webpack-dev-middleware v2.x? If you cannot (or are unwilling) to upgrade your version of webpack-dev-middleware, you may want to consider forking, which won't require the same hoops to jump through. I'd be happy to link to your fork for people who can't/won't move past 1.x and need that peerDep setting changed. |
I suppose it probably would have been faster to upgrade Since I’ve already done half the work, I’ll see if I can just finish the job here and add support for v3 and v4 in the travis config. I presume this change would also be welcome in the v2 branch since it appears you wish to continue supporting webpack v3 there as well. |
I would like to note also that the current version of webpack-dev-middleware v2 you’ve released supports webpack v4 as a |
I don't know how much you followed the webpack v4 alpha/beta/release cycle, but it was impossible to keep up with. Hence no formal suite of tests covering it, yet. I'm presently going through that pain on webpack-serve and webpack-hot-client so I'm also not sure if that was a dig at me about dev-middleware not being up to par yet... but I'm only one human, cranking out free code in the free time that I can manage. If I have my way, every new major will have tests running in CI to cover the last two versions of webpack. That is until we just start mandating that new major versions of companion modules only support the current version. Be glad that someone is making this push so folks a version back on webpack don't get left in the dust. |
That was not meant as a dig at you personally. I appreciate you taking the time to be thorough. 😅 I was just pointing out what appeared to me to be a slight double standard – one that you may not have been conscious of. I’ll update this PR as soon as I can find the time, assuming you’re still ok with merging it. I’ll update #266 as well. |
Yessir, I'm still OK to merge it as long as we have our bases covered. FWIW in this ecosystem (webpack) it's not so much a double standard as it is misalignment or inconsistency. Much of the time it's just simply a lack of time to do all the things needed to maintain that alignment. |
@mikegreiling is this still a need for your team? |
@shellscape I had intended to return to this but got I busy with other things. In the mean time it looks like I’m going to close this now as it is no longer needed for me. Thanks for being willing to work with me on it 👍 |
What kind of change does this PR introduce?
This adds webpack v4 as a devDependency, updates the file-loader dependency to fix tests, updates the config schema used in the server-tests, and adds webpack ^4.0.0 to supported
peerDependencies
.Did you add tests for your changes?
No, but I fixed broken tests resulting from this change.
Summary
This pull request aims to add webpack v4 support to the 1.x versions of webpack-dev-middleware for projects which have not yet updated to 2.x.
See issue: #263
Does this PR introduce a breaking change?
No.
Other information
I have updated the webpack
devDependency
and thepeerDependency
config, and ensured that all tests pass. I have not, however, changed the version number in package.json for a v1.13 release.Closes: #263
/cc @shellscape