webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.
MIT License
7.76k stars 1.43k forks source link

[webpack-dev-server and webpack-dev-middleware] Enable use other than express #4741

Open anonrig opened 1 year ago

anonrig commented 1 year ago

Feature Proposal

I recommend migrating to Fastify rather than using Express. The performance impact will be 7x (according to fastify readme), and I think it would be a lot beneficial for everybody.

Feature Use Case

I didn't understand why I need to write my system information while proposing a feature, but...

  System:
    OS: macOS 13.2.1
  Binaries:
    Node: 19.6.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.4.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.3
ScriptedAlchemy commented 1 year ago

+1 on this, would improve startup times alot and the middleware apis are very similar if i recall.

@alexander-akait - thoughts?

snitin315 commented 1 year ago

We do have similar plans as mentioned in https://github.com/webpack/webpack-dev-server/issues/4303. However, this is not yet prioritized. We will gladly accept a PR.

alexander-akait commented 1 year ago

@ScriptedAlchemy Fully agree, but we should start with https://github.com/webpack/webpack-dev-middleware, now we have compatibility using fastify-express, but will be great to be more native here, I don't have deep experience, so I will be glad to get help here https://github.com/webpack/webpack-dev-middleware/issues/945#issuecomment-1157548145, do you want to help with dev middle and when we can do it here too :smile:

anonrig commented 1 year ago

@alexander-akait Is there a specific reason to keep support for Express? I don't see the point of supporting Express.js since it might create unnecessary abstraction and maintenance burdens.

alexander-akait commented 1 year ago

@anonrig for dev server we don't need it, but webpack-dev-middleware should, because it is used for custom dev servers and we should support as much as possible, otherwise some developers will be angry :smile:

silverwind commented 1 year ago

Personally, I prefer to just use node core http with router@2.0.0-beta.1 for the routing. Great performance, and supports express-compatible middleware.

alexander-akait commented 1 year ago

@silverwind And you're right too, I think the best solution would be an abstract API, it takes time, but allow to use very fast and any other solutions.

Somebody want to try it (I will help), I personally think this is the right direction.

alexander-akait commented 2 months ago

Fixed:

alexander-akait commented 2 months ago

Now we have tests only for express and connect I will add router and fastify and also add a http2 supports

alexander-akait commented 2 months ago

In the next major release we will migrate from express to connect or router