next.js
56c9ad8d - Turbopack: Implement HMR in next-api (#54772)

Commit
2 years ago
Turbopack: Implement HMR in next-api (#54772) by @jridgewell: ### What? This integrates Turbopack's HRM protocol within the existing HMR WebSocket, and implements the server-side of the Next's and Turbopack's protocols for use in next-api. ### Why? HMR makes the development experience. ### How? The (new) Turbopack HMR protocol allows reusing the existing `sendMessage` and `addMessageListener` API's already used by our HMR singleton in Pages. (App apparently doesn't have a per-chunk HMR, only per-page, so it's HMR signals are describe below.) For the next-api server-side, I implemented the following events: - `reloadPage`, for Pages when `_document` changes - `middlewareChanges` when middleware is added/deleted, or modified - `serverOnlyChanges` for Pages when a loaded page's server graph changes - `serverComponentChanges` for App when a loaded app page's server graph changes We reuse the already implemented `addedPage`, `removedPage`, and `devPagesManifestUpdate` (done via webpack, so we should eventually port that over to the Turbopack listeners). I don't know exactly where `built`, `building`, and `sync` should be integrated, so they're just not sent currently. Additionally, the client-sent events aren't implemented in the new HMR server. Depends on https://github.com/vercel/turbo/pull/5814 Closes WEB-1453 --------- Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Author
Parents
Loading