docs(config): say what each output.library.type generates - #8405
Merged
Merged
Conversation
The type list named nineteen values and the sections below explained them at uneven depth: 'self' and 'umd2' had no section at all, 'module' pointed at a 2021 progress thread instead of showing its output, 'modern-module' had one sentence, and 'global' showed a globalThis assignment that no default target emits. Adds a table summarizing every type in one line, the two missing sections, real input/output for the module types, and the three assignments 'global' actually emits per target. Every example was read off a build rather than written by hand.
|
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
Picks up #8224's point — that
output.libraryandoutput.library.typedescribe themselves too thinly to act on — and carries it through to the per-type sections, which are where a reader actually chooses. Refs #8224.The type list names nineteen values; the sections below covered them unevenly:
'self'and'umd2'are valid types with no section at all. Both added.'module'said "Output ES Module" and linked a 2021 progress thread, with no example. Now shows the input and theexport { hello }it produces, and states that it requiresoutput.module.'modern-module'had one sentence. Now says what it is for and how it relates to'module'.'global'showedglobalThis.MyLibrary = _entry_return_, which no default target emits. Building it givesselfonwebandwebworker,globalonnode, andglobalThisonly on the neutral['web', 'node']target. All three are now shown, pointing atoutput.globalObjectas the thing that decides.Also adds a table summarizing all nineteen types in one line each, so the choice can be made without reading 500 lines of sections.
Every example came off a real build against webpack
main— one two-line library built once per type, wrapper read from the emitted file. Two claims in the new text are byte-diffed rather than assumed:'umd2'output is identical to'umd'unless the bundle has optional AMD externals (which matchesEnableLibraryPluginpassingoptionalAmdExternalAsGlobalas the only difference), and'commonjs-module'really is'commonjs2'— both reachAssignLibraryPluginwith the same options, which is what the page already claimed and is now confirmed.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 built a minimal library under each of the nineteen types and read the generated wrapper out of each bundle, checked the near-duplicate types against
lib/library/EnableLibraryPlugin.jsand byte-diffed their output, and drafted the table and sections; I reviewed the result before pushing.Generated by Claude Code