Skip to content

docs(api): show what this.getOptions does with a schema - #8403

Merged
alexander-akait merged 1 commit into
mainfrom
docs/getoptions-schema-validation
Sep 13, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
docs/getoptions-schema-validation

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

this.getOptions(schema) had a one-line mention and no example, which is why loader authors still validate by calling schema-utils themselves. Picks up that gap from #8215's sibling #8208 — credited in contributors — and documents it with the error webpack actually prints, plus the three things a bare example leaves out. Refs #8208.

Everything quoted was read off real builds against webpack main, not inferred:

  • The error is a module build failure raised where getOptions is called, while the first module the loader runs on is built — not at build start. A build that never reaches the loader never validates its options.
  • Validation runs only under compilation.options.validate. The same invalid config with validate: false compiled with zero errors, so the page now says a schema is a development-time guard rather than a guarantee, and links to validate, which already documents the futureDefaults + production exception.
  • title is split at its last space into the name and the data path: 'Prefix Loader options' is what produces Prefix Loader has been initialized… and options has an unknown property, where a schema without a title produces a bare Loader, which identifies nothing in a multi-loader chain. That is the one part of this API a loader author has to know, and it was undocumented.

What kind of change does this PR introduce?

docs

Did you add tests for your changes?

n/a — documentation only.

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?

n/a — this PR is the documentation.

Use of AI

AI was used. Claude Code read NormalModule#_createLoaderContext to find the validate gate and the title parsing, ran a loader with a deliberately misspelled option to capture the exact error text quoted in the page, and drafted the section; I reviewed and edited it before pushing.


Generated by Claude Code

The option schema argument had a one-line mention and no example, so loader
authors reach for schema-utils by hand instead. Adds a worked example with the
error webpack actually prints, says what additionalProperties and title each
contribute to that message, and notes the two things the example alone would
get wrong: the check runs while the module is built, and it does not run at all
when the validate option is off.
@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webpack-js-org Ready Ready Preview Sep 13, 2026 4:24pm UTC

Request Review

@alexander-akait
alexander-akait merged commit ee1b9ec into main Sep 13, 2026
12 checks passed
@alexander-akait
alexander-akait deleted the docs/getoptions-schema-validation branch September 13, 2026 16:43

This branch was successfully deployed

1 active deployment
Preview — 0570263d Deployed Sep 13, 2026 by vercel[bot]
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