Skip to content

fix(types): load dev server configuration types (AI-assisted) - #12935

Open
haranishi wants to merge 1 commit into
meta:mainfrom
haranishi:fix/plugin-devserver-types
Open

haranishi wants to merge 1 commit into
meta:mainfrom
haranishi:fix/plugin-devserver-types

Conversation

@haranishi

@haranishi haranishi commented Nov 10, 2026 •

Copy link
Copy Markdown

Pre-flight checklist

  • The Contributing Guidelines on pull requests were checked during preparation.
  • If this is a code change: I have written unit tests to verify the behavior.
  • New API or substantial change: not applicable; this fixes typing for an existing documented option.

Motivation

A plugin returning the documented devServer: {open: '/docs'} configuration fails type checking when the consumer imports only Plugin from @docusaurus/types. The same configuration works at runtime. Importing webpack-dev-server elsewhere happens to hide the problem because it augments webpack.Configuration.

Load that augmentation from the public plugin declarations and declare the existing catalog dependency in @docusaurus/types. No runtime implementation or dependency versions change.

The regression test compiles an isolated TypeScript program, so imports in the monorepo cannot accidentally supply the missing augmentation. It checks returning and reading devServer, retaining Webpack and mergeStrategy options, and rejecting open: 42.

Test Plan

Tested on macOS with Node.js 26.13.0 and pnpm 12.3.4, against upstream c00f04e2376e057090d65d6bfb6a82d49ea3eca6.

  • pnpm test __tests__/plugin-types.test.ts: passes. Before the declaration fix, the same test fails with missing devServer properties and an unused @ts-expect-error directive.
  • pnpm build:packages: passes (36 packages), after clearing generated incremental build information.
  • pnpm typecheck:tests: passes.
  • pnpm --filter website typecheck: passes.
  • pnpm lint: passes, including ESLint, Stylelint, spelling, catalogs, deduplication, Knip and formatting. ESLint reports existing warnings and no errors.
  • pnpm test: 3,223 passed and 6 failed (205 test files passed, 1 failed).
Existing full-suite failures on the HFS+ checkout

All six failures are blog feed directory-tree snapshots in packages/docusaurus-plugin-content-blog/src/__tests__/feed.test.ts: the filesystem returns the decomposed spelling of héllô, while the snapshots contain its composed spelling.

Reverting the declaration fix and running pnpm test packages/docusaurus-plugin-content-blog/src/__tests__/feed.test.ts reproduces the same six failures (16 other tests pass). The original declaration was restored for that check and the fix restored afterwards. No blog files or snapshots are changed in this patch. The directory-tree normalization is addressed separately in #12937.

Test links

Deploy preview: https://deploy-preview-12935--docusaurus-2.netlify.app/.

The existing documented contract is Configuring dev server. This is a type-only fix; no UI changes.

Related issues/PRs

Fixes #9654.

AI assistance: this patch, regression test and draft description were prepared with Codex. Validation was run locally with Codex (AI-assisted); no independent human review is claimed.

Summary by CodeRabbit

  • Improvements
    • Improved TypeScript support for webpack configuration, including development-server options, so invalid setting types can be flagged during development.

@meta-cla

meta-cla Bot commented Nov 10, 2026

Copy link
Copy Markdown

Hi @haranishi!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The @docusaurus/types package now loads webpack-dev-server’s augmentation of webpack.Configuration. A fixture and strict TypeScript test check configureWebpack typing, including an expected error for a numeric devServer.open value.

Changes: configureWebpack type support

Layer / File(s) Summary
Load the devServer augmentation
packages/docusaurus-types/package.json, packages/docusaurus-types/src/plugin.d.ts
The types package adds webpack-dev-server as a dependency and imports it to load its webpack.Configuration augmentation.
Exercise configureWebpack types
__tests__/__fixtures__/configureWebpack/index.ts, __tests__/plugin-types.test.ts
The fixture defines a configureWebpack callback with devServer settings and marks a numeric devServer.open value as an expected type error. The test checks the fixture with strict TypeScript compilation and expects no diagnostics.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested labels: pr: bug fix

Merge Risk: Minimal · up to 0db25

No actionable merge-blocking risk is identified for the devServer typing change; it is mergeable after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: loading webpack-dev-server configuration types for consumers of @docusaurus/types.
Linked Issues check Passed Issue #9654 requires configureWebpack to accept the documented devServer option. The PR loads webpack-dev-server's type augmentation from the public plugin declarations and adds its catalog depe…
Out of Scope Changes check Passed The declaration change, dependency declaration, fixture, and type-checking test all support the #9654 typing fix. The PR summary reports no runtime changes. The excluded pnpm-lock.yaml does not prov…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #9654 requires configureWebpack to accept the documented devServer option. The PR loads webpack-dev-server's type augmentation from the public plugin declarations and adds its catalog dependency. The isolated type test checks valid devServer settings and rejects open: 42, while retaining Webpack and mergeStrategy options.

Full details: Out of Scope Changes check

Explanation

The declaration change, dependency declaration, fixture, and type-checking test all support the #9654 typing fix. The PR summary reports no runtime changes. The excluded pnpm-lock.yaml does not provide evidence of an unrelated change.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72144f94-61d2-4a18-9166-637301d39546
Commits

Reviewing files that changed from the base of the PR and between c00f04e and 0db258b.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 4

  • __tests__/__fixtures__/configureWebpack/index.ts
  • __tests__/plugin-types.test.ts
  • packages/docusaurus-types/package.json
  • packages/docusaurus-types/src/plugin.d.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@netlify

netlify Bot commented Nov 10, 2026

Copy link
Copy Markdown

✅ [V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 0db258b
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6af291c330545cba0365063a
😎 Deploy Preview https://deploy-preview-12935--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@haranishi
haranishi marked this pull request as ready for review November 10, 2026 03:40
Copilot AI balanced review requested due to automatic review settings November 10, 2026 03:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Nov 10, 2026
@meta-cla

meta-cla Bot commented Nov 10, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

This branch has not been deployed

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

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin API: Type definition of configureWebpack does allow all possible keys

2 participants