Skip to content

docs(config): say what each output.library.type generates - #8405

Merged
alexander-akait merged 1 commit into
mainfrom
docs/library-type-examples
Sep 13, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
docs/library-type-examples

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

Picks up #8224's point — that output.library and output.library.type describe 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 the export { hello } it produces, and states that it requires output.module.
  • 'modern-module' had one sentence. Now says what it is for and how it relates to 'module'.
  • 'global' showed globalThis.MyLibrary = _entry_return_, which no default target emits. Building it gives self on web and webworker, global on node, and globalThis only on the neutral ['web', 'node'] target. All three are now shown, pointing at output.globalObject as 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 matches EnableLibraryPlugin passing optionalAmdExternalAsGlobal as the only difference), and 'commonjs-module' really is 'commonjs2' — both reach AssignLibraryPlugin with 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.js and byte-diffed their output, and drafted the table and sections; I reviewed the result before pushing.


Generated by Claude Code

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.
@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 5:09pm UTC

Request Review

@alexander-akait
alexander-akait merged commit ab7106e into main Sep 13, 2026
12 checks passed
@alexander-akait
alexander-akait deleted the docs/library-type-examples branch September 13, 2026 17:51

This branch was successfully deployed

1 active deployment
Preview — f2882006 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