Skip to content

fix: export and type the custom server extension class - #5732

Open
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:codex/export-base-server
Open

fix: export and type the custom server extension class#5732
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:codex/export-base-server

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 28, 2026

Copy link
Copy Markdown

Fixes

  • Export the documented webpack-dev-server/lib/servers/BaseServer.js extension point for ESM, CommonJS and TypeScript consumers.
  • Unwrap the CommonJS class consistently with the main Server entrypoint, retaining .default interoperability.
  • Type webSocketServer.type as a constructor extending BaseServer instead of a zero-argument callable returning a configuration object.

Compatibility

Restores the documented extension path blocked by the v6 export map. No runtime/engine/dependency removal. The declaration now accepts the class actually instantiated at runtime; invalid callable factories may require correction to constructible classes.

Verification

Unchanged v6 export map reproduces ERR_PACKAGE_PATH_NOT_EXPORTED. Real ESM and CommonJS subclasses construct successfully; CommonJS default interop is retained. Strict NodeNext TypeScript consumer accepts a custom subclass in webSocketServer configuration. Build and full lint/types/spelling/formatting pass.

Audit scope

This is a focused, independently based change from a broader source review at f804962. The combined frozen-source run executed 1,002 tests: 951 passed, 43 failed, one cancelled, seven skipped. Failures were traced to the separately proposed overlay DOM snapshots, reconnect-disabled test expectation and IPv6 host-test assumptions; it is not represented as a green full suite. Relevant focused results are listed above. No checked-in tests/specs/snapshots were added or modified. Hosted CI and the full OS/Node matrix remain pending.

Summary by CodeRabbit

  • New Features
    • Exported the BaseServer class as a public package entry point.
    • WebSocket server configuration now accepts custom server class constructors.
    • Added TypeScript declarations for the new public export.
    • Improved CommonJS imports so server classes are returned directly.

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3e67866

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 Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16698ef9-66c1-4e92-b60c-1cc7fac4071a

📥 Commits

Reviewing files that changed from the base of the PR and between f804962 and 3e67866.

📒 Files selected for processing (5)
  • .changeset/export-base-server.md
  • lib/Server.js
  • package.json
  • scripts/finalize-cjs-build.mjs
  • types/lib/Server.d.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review.


Walkthrough

The change adds a package export for BaseServer with declaration, ESM, CommonJS, and default targets. The WebSocket server configuration type now accepts a BaseServer class constructor. The CommonJS finalization script unwraps both Server.js and servers/BaseServer.js so each entrypoint returns its class directly. A changeset documents these public API updates.

Merge Risk: ⚪ Minimal · up to 3e678

The PR restores the documented custom server extension path and aligns its TypeScript declaration with the existing runtime constructor behavior. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: exporting and typing the custom server extension class.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
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: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

lib/Server.js

ESLint failed to execute (timeout).

package.json

ESLint skipped: the matched ESLint configuration already failed (timeout).

scripts/finalize-cjs-build.mjs

ESLint skipped: the matched ESLint configuration already failed (timeout).

  • 1 others

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

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would be a minor, but honestly, I’m not sure it’s necessary. What’s your use case?

@OskarEichler

Copy link
Copy Markdown
Author

The use case targeted here is a TypeScript/ESM consumer providing webSocketServer.type as a custom class that extends the documented BaseServer. Today that requires a deep import of an unexported CommonJS file, and the public type models the extension as a zero-argument factory instead of a constructor. The export and type change make the documented extension point usable without a private-path import.

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.

2 participants