[RFC] Drop websockets in favor of HTTP chunk streaming
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 重構
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, node.js
研究方向
先檢視 issue 中連結的 Pundle HMR client 和 server 提議 entry point,然後將它們與 webpack-dev-server 目前的 HMR 和 WebSocket 流程進行比較。確定以 HTTP chunk streaming 取代雙向連線對設計和相容性的影響;完成的條件是需要有一份取得共識的實作計畫和一條經過驗證的遷移路徑。
由索引模型根據 Issue 內容生成。
描述
- 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.
- 主要語言
- JavaScript
- 星號
- 7.9k
- 分支
- 1.5k
- 平均合併
- 2 天 12 小時
- 30 天內合併 PR
- 8
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
webpack/webpack-dev-server 的其他 Issue
-
Add support for Chrome DevTools Workspaces可能重新可做 @AnumanyaJaiswal 於 35 天前認領,目前沒有進行中的 PR。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
webpack/webpack-dev-server#5716 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
webpack/webpack-dev-server#5679 · 3 則留言 ·
維護者通常 1 天內回覆
-
CORS localhost requests are considered invalid host and get blocked可能重新可做 @Jeston10 於 310 天前認領,目前沒有進行中的 PR。 未關閉
難度 3/5 1-2 天 新手友好度 52/100
webpack/webpack-dev-server#5603 · 5 則留言 ·
維護者通常 1 天內回覆
-
Webpack dev server URL should be displayed more prominently可能已有人在做 @snitin315 於 805 天前認領。 未關閉
webpack/webpack-dev-server#4907 · 7 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 35/100
webpack/webpack-dev-server#4540 · 9 則留言 ·
維護者通常 1 天內回覆
查看 webpack/webpack-dev-server 的全部 Issue
相似的 Issue
-
Mend: dependency security vulnerability
難度 2/5 1-3 小時 新手友好度 65/100
ManageIQ/manageiq-ui-service#2259 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 73/100
electerious/Ackee#411 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 64/100
babalae/bettergi-scripts-list#3905 · 1 則留言 ·
維護者通常 1 天內回覆
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"未關閉
難度 1/5 1-3 小時 新手友好度 87/100
dedicatedcode/reitti#1445 ·
維護者通常 1 天內回覆