[RFC] Drop websockets in favor of HTTP chunk streaming
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, node.js
Rechercherichtung
Beginne damit, die im Issue verlinkten vorgeschlagenen Pundle-HMR-Client- und -Server-Einstiegspunkte zu prüfen, und vergleiche sie anschließend mit dem aktuellen HMR- und WebSocket-Ablauf von webpack-dev-server. Ermittle die Auswirkungen auf Design und Kompatibilität, die das Ersetzen der bidirektionalen Verbindung durch HTTP chunk streaming hätte; abgeschlossen wäre die Aufgabe, wenn ein abgestimmter Implementierungsplan und ein validierter Migrationspfad vorliegen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
- This is a bug
- This is a modification request
Context
A few years ago I started working on a Module bundler from scratch (Pundle / https://github.com/steelbrain/pundle), It worked well for most simple cases and had plugin support and everything, I couldn't focus on it because of my fulltime job. I am hoping to upstream some of the clever fixes to the limitations I found working with Browserify and Webpack.
Why drop websockets?
There are many reasons for why we would want to remove Websockets from the dev server. The simplest explanation through code is that, webpack dev server consumers do this:
const app = express()
app.use('/mycoolwebsite', webpackDevServer({...})
const server = app.listen(9123, ...)
To setup a websocket server on an http server, we require access to the http server instance in NodeJS, which is only available AFTER calling .listen(), we cannot have it when registering the webpackDevServer route. Currently this is handled by setting up the websocket server on a different port inside the middleware and connecting to it instead.
It is complicated to setup webpack dev server with HMR when working with proxies. All of this can be avoided if we do simple HTTP chunking as described below.
The proposed fix
For HMR, the client just needs to listen to the server for updates, so it's a one-way communication, not bi-directional. Using fetch() API with a TextDecoder, we can keep an HTTP connection open for as long as we want and continue to write onto it from the server.
Here's the Client / Server implementation of it in Pundle: https://github.com/steelbrain/pundle/blob/fee7d9dc055591bf002b5a66190d651a02dbdfa4/packages/pundle-dev-middleware/src/client/hmr-client.js#L137-L157 / https://github.com/steelbrain/pundle/blob/4152d29de8b28be69c3e21bd3589a6109726310a/packages/pundle-dev-middleware/src/index.js#L220-L229
As you can see, we no longer need to worry about HMR port or hostname, the client JS can do a request to the server with selfUrl.webpack.hmr, it'll be routed to webpack through the same proxy that loaded the JS in the first place, webpack can then continue to write chunks on it until the client disconnects.
Benefits of proposed approach
- Massively reduce complexity for embedded dev server setups
- Reduced codebase complexity and ease of maintenance
Please let me know if there's anything I can explain to make it more understandable. Happy to do a PR implementing this change.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 7.9k
- Forks
- 1.5k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus webpack/webpack-dev-server
-
Add support for Chrome DevTools WorkspacesEvtl. wieder frei @AnumanyaJaiswal hat das vor 35 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
webpack/webpack-dev-server#5716 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
webpack/webpack-dev-server#5679 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
CORS localhost requests are considered invalid host and get blockedEvtl. wieder frei @Jeston10 hat das vor 310 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
webpack/webpack-dev-server#5603 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Webpack dev server URL should be displayed more prominentlyEvtl. vergeben @snitin315 hat das vor 805 Tagen übernommen. Offen
webpack/webpack-dev-server#4907 · 7 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
webpack/webpack-dev-server#4540 · 9 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in webpack/webpack-dev-server
Ähnliche Issues
-
[bug] 提瓦特记事本原石检测框宽度较窄Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
babalae/bettergi-scripts-list#3905 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Offen
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 87/100
dedicatedcode/reitti#1445 ·
Maintainer antworten meist innerhalb von 1 Tag
-
New tool: Uncle DeskEvtl. vergeben @github-actions hat das heute übernommen. Offensubmission triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
kausalflow/tools#384 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
-
area: css
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag