You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: warn when hot or live reload cannot reach a page for a non-web target - #5801
Supersedes #3094. Co-authored with @snitin315, who wrote the original change.
lib/utils/DevServerPlugin.js is gone. Since dc9a72c, webpack-dev-middleware adds the client entry, and it skips every compiler that is not a web target. webpack-dev-server runs the same Server.isWebTarget check in its own per-compiler loop in initialize(), which is also where a subclass's own client entry is added. The warning goes in that loop: once per compiler, through this.logger.warn, when hot or liveReload is on and client is not false.
Multi compiler: #3094's discussion only asked for a warning (not info) and for the logic to live where the entries are added. It did not cover multi compilers, so I made a call. A node compiler next to a web one is the usual SSR setup: the page gets its client from the web compiler and the node one is meant to have none. Warning there would be noise, so the warning fires only when no compiler (ignoring devServer: false ones) is a web target. In that case each compiler gets its own warning, named by name when it has one.
<w> [webpack-dev-server] The compiler has a non-web target ("node"), so no client is injected into it and 'hot' and 'liveReload' will not reach a page built from it.
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8099/, http://[::1]:8099/
...
With hot: false the warning names only 'liveReload'. In a multi compiler it reads Compiler "<name>" has a non-web target (...).
What kind of change does this PR introduce?
Fix (a new warning). Behaviour is otherwise unchanged.
Did you add tests for your changes?
Yes. There is a new non-web target warning suite in test/e2e/target.test.js, which collects warnings through infrastructureLogging.stream. It covers:
a node target
hot: false
hot and liveReload both off
client: false
a web target
a web + node multi compiler (no warning)
two non-web compilers (one warning each)
The three warning cases fail on main. All seven pass with the fix.
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Nothing. A changeset is included.
Use of AI
Claude Code wrote the change and the tests. Checks run: the new tests (they fail on main and pass with the fix), test/e2e/target.test.js, test/is-web-target.test.js, multi-compiler, universal-target, logging and entry e2e tests, npm run lint (clean), and npm run build:types (no change to types/). I could not run the full suite locally because other processes held the test ports. Some test/cli/basic.test.js, compatibility and hot-and-live-reload manual-client tests also fail in my environment, and they fail the same way on unmodified main.
Added a warning when hot updates or live reload are enabled but no compiler targets the web. The warning identifies affected non-web compilers and notes that the client is not injected, so these features will not reach pages they build.
Warnings are suppressed when the client is disabled, the features are inactive, or a web-target compiler is present.
Server.initialize() now warns when the client is enabled, hot or liveReload is active, and no enabled compiler targets the web. The warning identifies each active non-web compiler and the features that will not reach its pages. End-to-end tests cover warning text and suppression conditions. A changeset declares a patch release.
Merge Risk: Minimal · up to 0ca3a
This adds a warning when hot or live reload is enabled and no compiler targets the web. Other behavior is unchanged and no merge-blocking risk is evident.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: a warning when hot or live reload is enabled but no page can receive the client because the compiler target is non-web. The title uses the fix: prefix, which fits a wa…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a warning when hot or live reload is enabled but no page can receive the client because the compiler target is non-web. The title uses the fix: prefix, which fits a warning addition that the changeset describes as a patch release. The title is specific and matches the summaries and objectives, so it passes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Assert warning semantics instead of complete log lines.
These assertions fail if warning wording or logger formatting changes without changing behavior. Check the warning count and key substrings for the target, compiler name, and enabled features instead. For the liveReload-only case, also check that the warning excludes 'hot'.
Based on learnings: prefer key substrings over exact user-facing copy unless the complete copy is the requirement.
Also applies to: 283-283, 328-329
Source: Learnings
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 30821a19-37d1-42ae-9147-7b4ba341b541
Commits
Reviewing files that changed from the base of the PR and between 6421747 and 0ca3a59.
Files selected for processing: 3
.changeset/warn-non-web-target.md
lib/Server.js
test/e2e/target.test.js
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.84%. Comparing base (6421747) to head (0ca3a59). ⚠️ Report is 2 commits behind head on main.
❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #3094. Co-authored with @snitin315, who wrote the original change.
lib/utils/DevServerPlugin.jsis gone. Since dc9a72c, webpack-dev-middleware adds the client entry, and it skips every compiler that is not a web target. webpack-dev-server runs the sameServer.isWebTargetcheck in its own per-compiler loop ininitialize(), which is also where a subclass's own client entry is added. The warning goes in that loop: once per compiler, throughthis.logger.warn, whenhotorliveReloadis on andclientis notfalse.Multi compiler: #3094's discussion only asked for a warning (not info) and for the logic to live where the entries are added. It did not cover multi compilers, so I made a call. A
nodecompiler next to awebone is the usual SSR setup: the page gets its client from thewebcompiler and thenodeone is meant to have none. Warning there would be noise, so the warning fires only when no compiler (ignoringdevServer: falseones) is a web target. In that case each compiler gets its own warning, named bynamewhen it has one.Before (
target: "node", defaults):After:
With
hot: falsethe warning names only'liveReload'. In a multi compiler it readsCompiler "<name>" has a non-web target (...).What kind of change does this PR introduce?
Fix (a new warning). Behaviour is otherwise unchanged.
Did you add tests for your changes?
Yes. There is a new
non-web target warningsuite intest/e2e/target.test.js, which collects warnings throughinfrastructureLogging.stream. It covers:nodetargethot: falsehotandliveReloadboth offclient: falsewebtargetweb+nodemulti compiler (no warning)The three warning cases fail on
main. All seven pass with the fix.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Nothing. A changeset is included.
Use of AI
Claude Code wrote the change and the tests. Checks run: the new tests (they fail on
mainand pass with the fix),test/e2e/target.test.js,test/is-web-target.test.js, multi-compiler, universal-target, logging and entry e2e tests,npm run lint(clean), andnpm run build:types(no change totypes/). I could not run the full suite locally because other processes held the test ports. Sometest/cli/basic.test.js,compatibilityandhot-and-live-reloadmanual-client tests also fail in my environment, and they fail the same way on unmodifiedmain.Generated by Claude Code
Summary by CodeRabbit