docs(api): show what this.getOptions does with a schema - #8403
Merged
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
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 incontributors— 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:getOptionsis 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.compilation.options.validate. The same invalid config withvalidate: falsecompiled with zero errors, so the page now says a schema is a development-time guard rather than a guarantee, and links tovalidate, which already documents thefutureDefaults+ production exception.titleis split at its last space into the name and the data path:'Prefix Loader options'is what producesPrefix Loader has been initialized…andoptions has an unknown property, where a schema without a title produces a bareLoader, 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#_createLoaderContextto find thevalidategate and thetitleparsing, 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