Commit cd4b658
feat(client): bring the error overlay to parity with webpack-dev-server (#2353)
* feat(client): bring the error overlay to parity with webpack-dev-server
- Render inside an about:blank iframe and style exclusively through
the CSSOM so the overlay works under a strict style-src CSP; inline
styles from ansi-html are re-applied via style.cssText.
- Support Trusted Types: innerHTML writes go through a policy
(configurable via overlayTrustedTypesPolicyName).
- Capture uncaught runtime errors and unhandled rejections in the
overlay (overlayRuntimeErrors, default true), with the same React
error boundary heuristic as dev-server.
- Inline the HTML entity encoder and drop the html-entities dependency.
- Expose the overlay as a standalone subpath export
(webpack-dev-middleware/client/overlay) so webpack-dev-server can
reuse it.
Ref webpack/webpack-hot-middleware#457
* feat(client): support opening file references in the editor
When `overlayOpenEditorEndpoint` is set, file chips in the overlay
become clickable and issue GET <endpoint>?fileName=<file:line:column>
— the same contract as webpack-dev-server's open-editor route. The
endpoint implementation is left to the server integration, so no
launch-editor dependency is added.
* feat(client): bring the error overlay to parity with webpack-dev-server
- Render inside an about:blank iframe and style exclusively through
the CSSOM so the overlay works under a strict style-src CSP; inline
styles from ansi-html are re-applied via style.cssText.
- Support Trusted Types: innerHTML writes go through a policy
(configurable via the overlay's trustedTypesPolicyName).
- Capture uncaught runtime errors and unhandled rejections in the
overlay, with the same React error boundary heuristic as dev-server.
- Adopt dev-server's client.overlay option shape: a boolean or a JSON
object with errors/warnings/runtimeErrors (booleans or filter
functions) and trustedTypesPolicyName, so dev-server configs migrate
as-is. Warnings are shown by default and no longer block updates,
matching dev-server.
- Support opening file references in the editor: when
overlayOpenEditorEndpoint is set, file chips issue
GET <endpoint>?fileName=<file:line:column> (same contract as
dev-server's open-editor route); the endpoint implementation is left
to the server integration.
- Inline the HTML entity encoder and drop the html-entities dependency.
- Expose the overlay as a standalone subpath export
(webpack-dev-middleware/client/overlay) so webpack-dev-server can
reuse it.
Ref webpack/webpack-hot-middleware#457
Ref webpack/webpack-hot-middleware#184
* fix(client): track overlay problems per compilation
With a MultiCompiler the client receives one event per bundle, and a
successful build from one bundle used to wipe another bundle's
still-valid errors from the overlay. Keep the live problems keyed by
compilation name, render the union, and only clear the overlay when
every compilation is clean. The console de-duplication cache is also
keyed per bundle so interleaved payloads do not defeat it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs(examples): add a MultiCompiler hot example
Keep examples/hot as the minimal single-compiler setup (now with
runtime-error buttons and an opt-in DEMO_WARNING build warning), and
add examples/hot-multi-compiler: two compilers ("app" and "admin")
sharing one middleware instance and a single SSE connection, with
per-bundle `?name=` client scoping and recipes for the overlay's
per-compilation error tracking.
Each multi config sets a distinct output.uniqueName (and prefixed
hot-update filenames): with both bundles on one page, a shared
webpackHotUpdate global would make each bundle's updates land in the
wrong runtime.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(client): nest overlay extensions inside the overlay option
Move styles, ansiColors and openEditorEndpoint into the overlay object
as webpack-dev-middleware extensions of dev-server's client.overlay
shape, replacing the flat overlayStyles/ansiColors/
overlayOpenEditorEndpoint options.
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 5de4c98 commit cd4b658
21 files changed
Lines changed: 1073 additions & 167 deletions
File tree
- client-src
- examples
- hot-multi-compiler
- public
- src
- hot
- src
- test
- __snapshots__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
391 | 388 | | |
392 | 389 | | |
393 | 390 | | |
| |||
426 | 423 | | |
427 | 424 | | |
428 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
429 | 444 | | |
430 | 445 | | |
431 | 446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
29 | 39 | | |
0 commit comments