Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changeset/client-live-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Added a `reload` action, for a change no compilation knows about: publish
used to have you write by hand.

Added `urlPrefix` (default `"webpack-dev-middleware"`), which names the page-url
parameters that turn `hot` and `liveReload` off for a single page —
`?webpack-dev-middleware-liveReload=false`.
parameter that overrides what a build does to a single page —
`?webpack-dev-middleware-apply=nothing`.

`live-reload` used to be accepted as another spelling of `reload`. The two are
different — `reload` is the fallback for an update that was tried and could not
Expand Down
8 changes: 4 additions & 4 deletions .changeset/client-options-both-ways.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ A `hot.transport` of your own now gets a client too, when `hot.client.transport`
says which of the two built-in protocols yours carries. Without it the client is
still yours to add, as before.

Every option has one name and no aliases, in `hot.client`, in the entry query
and in the page-url parameters alike. The two second spellings the query had
Every option is spelled one way in `hot.client`, in the entry query and in the
page-url parameters alike, apart from the six names kept working for a release
after `apply` and `connect` replaced them. The two second spellings the query had
picked up from webpack-dev-server — `webSocketURL` for `path` and `live-reload`
for `liveReload` — are gone, and so is the `-live-reload` page parameter, which
is now `-liveReload`. Neither alias was ever released.
for `liveReload` — are gone. Neither alias was ever released.
5 changes: 5 additions & 0 deletions .changeset/connect-object-from-node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": patch
---

Fixed `hot.client.connect` set as an object on the middleware being dropped. The browser options travel to the runtime as its entry's query, where every value but `overlay` went through `String(value)` — so `{ retries: 3, timeout: 5000 }` arrived as the text `"[object Object]"`, which the client failed to parse and then read as the boolean `true`. Both fields were lost without a warning, and the connection used the defaults. Any value that is an object is now serialized as JSON, which is the shape the client parses it out of, so an option that grows an object form later needs no change here.
26 changes: 26 additions & 0 deletions .changeset/hot-client-apply-and-connect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"webpack-dev-middleware": minor
---

Two unions on the browser options, replacing six with two.

`hot.client.apply` replaces `hot`, `liveReload` and `reload`. Only four of their eight combinations ever differed — `liveReload` was read only when HMR was off, `reload` only when it was on — so the three booleans were one decision written three ways:

| before | now |
| ------------------------------- | ------------------- |
| `hot: true, reload: true` | `apply: "hmr"` |
| `hot: true, reload: false` | `apply: "hmr-only"` |
| `hot: false, liveReload: true` | `apply: "reload"` |
| `hot: false, liveReload: false` | `apply: "nothing"` |

The page-url parameter follows it: `?webpack-dev-middleware-apply=nothing` in place of `-hot=false` and `-liveReload=false`, with `=false` still accepted as `nothing`. It is more expressive than before, since a page can now ask for a mode rather than only turn something off.

`hot.client.connect` replaces `autoConnect`, `reconnect` and `timeout`. `false` does not connect on load; an object carries `retries` and `timeout`:

```js
middleware(compiler, {
hot: { client: { connect: { retries: 3, timeout: 5000 } } },
});
```

All six old names keep working. Each warns, in node when it is set on `hot.client` and in the browser when it arrives on the query — a hand-written entry has only the second channel — and the option that replaced it wins when both are given, so a migration that sets the new name and leaves the old one behind is not silently ignored. They are removed in the next major release.
6 changes: 3 additions & 3 deletions .changeset/reconnect-and-timeout-per-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"webpack-dev-middleware": patch
---

`hot.client.reconnect` now applies to Server-Sent Events as well. It was overridden to `Infinity` there, so asking for a bounded number of attempts over the default transport did nothing. Unset still means "keep trying for as long as the page is open", since a dev server is expected to come back and a tab left open across a restart has to find it again.
`hot.client.connect.retries` (`hot.client.reconnect` before it was replaced, still accepted) now applies to Server-Sent Events as well. It was overridden to `Infinity` there, so asking for a bounded number of attempts over the default transport did nothing. Unset still means "keep trying for as long as the page is open", since a dev server is expected to come back and a tab left open across a restart has to find it again.

`hot.client.timeout` is documented as Server-Sent Events only, which is what it always was: that transport sends its heartbeat as data the client can see, while a WebSocket sends a protocol ping the browser answers without telling JavaScript — a silence watchdog there would fire on a healthy idle connection, and the half-open case it would catch is handled by the server, which terminates a socket that stops answering. It is no longer handed to a WebSocket client whose constructor takes no options.
`hot.client.connect.timeout` (`hot.client.timeout` before it was replaced, still accepted) is documented as Server-Sent Events only, which is what it always was: that transport sends its heartbeat as data the client can see, while a WebSocket sends a protocol ping the browser answers without telling JavaScript — a silence watchdog there would fire on a healthy idle connection, and the half-open case it would catch is handled by the server, which terminates a socket that stops answering. It is no longer handed to a WebSocket client whose constructor takes no options.

Both decisions now live in one place, `client-src/utils/socket-options.js`, with tests for each transport. The documented default for `reconnect` was wrong for the default transport while it was being ignored there: unset, Server-Sent Events keep trying for as long as the page is open and a WebSocket gives up after 10.
Both decisions now live in one place, `client-src/utils/socket-options.js`, with tests for each transport. The documented default for the retry count was wrong for the default transport while it was being ignored there: unset, Server-Sent Events keep trying for as long as the page is open and a WebSocket gives up after 10.
Loading
Loading