Skip to content

fix: warn when hot or live reload cannot reach a page for a non-web target - #5801

Closed
alexander-akait wants to merge 1 commit into
mainfrom
fix/warn-non-web-target
Closed

alexander-akait wants to merge 1 commit into
mainfrom
fix/warn-non-web-target

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

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.

Before (target: "node", defaults):

<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8099/, http://[::1]:8099/
...

After:

<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.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • 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.

…arget

Co-authored-by: Nitin Kumar <snitin315@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ca3a59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-dev-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1

test/e2e/target.test.js: 1

273-273: Trivial · Maintainability & Code Quality · Quick win

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.

@alexander-akait
alexander-akait deleted the fix/warn-non-web-target branch November 12, 2026 16:48
@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ 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.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5801      +/-   ##
==========================================
+ Coverage   95.82%   95.84%   +0.02%     
==========================================
  Files           6        6              
  Lines        5586     5613      +27     
==========================================
+ Hits         5353     5380      +27     
  Misses        233      233              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant