Update pdfjs-viewer docs for v4.6.0: the Vite plugin

Merged
AL
11h ago
+42-11

Summary

Docs for @missing-elements/pdfjs-viewer 4.6.0, which adds a Vite plugin that copies the PDF.js data folders into the build (pdfjs-viewer#84).

  • Bump the pinned package to 4.6.0. The CDN examples now show @4.6.0.
  • Hosting splits the old "Bundlers and assets-base" section into three, all in the sidebar:
    • Bundlers: what bundlers copy and what they leave out, and that vite dev hides the problem.
    • Vite plugin: the config, where the data goes, the size, supported Vite versions, the framework configs, and the caching caveat below.
    • Other bundlers and assets-base: the copy route, unchanged. A <span id="bundlers-and-assets-base"> keeps old links landing here.
  • Smaller edits: the assets-base attribute row, the resources section, a fourth "things to remember" bullet under Frameworks, and a "From 4.5.0 or earlier" bullet under Migrating.

The caching caveat

The plugin's data files keep fixed names. SvelteKit (_app/immutable/), Nuxt (_nuxt/) and Astro (_astro/) serve their asset folders as immutable, so a returning visitor can keep an older version's files after an upgrade. I checked that this breaks something: the openjpeg.wasm published in 4.4.2 needs 17 imports, and the 4.6.0 worker provides 8, so it can't load. The section says so and points to a short cache or assets-base.

Validation

  • pnpm build passes.
  • In _site/pdfjs-viewer/index.html, every href="#…" matches an id on the page, the three new headings are in the table of contents, and #bundlers-and-assets-base still exists.
  • Not checked: what each framework's config looks like with the plugin in it. Plain Vite was tested with a client build and an SSR build.

šŸ¤– Generated with Claude Code


Summary by cubic

Documents @missing-elements/pdfjs-viewer 4.6.0, which adds a Vite plugin that copies the PDF.js data folders into the build. The pinned package bumps to 4.6.0, so the CDN examples now show @4.6.0.

Docs

  • Splits the old "Bundlers and assets-base" section into Bundlers, Vite plugin, and Other bundlers and assets-base; the old anchor still lands on the copy route.
  • The Vite plugin section covers the config, where the data goes, the 286-file / 3.4 MB build output, supported Vite versions, and the framework configs.
  • Notes that the plugin's copy goes unused when assets-base or a resource attribute is set.
  • Warns that the plugin's fixed file names can outlive an upgrade in an immutable cache, since PDF.js can't mix data from different versions; recommends a short cache or the assets-base route.
  • Adds a fourth bullet under Frameworks, a migration note for 4.5.0 and earlier, and updates the assets-base attribute row and the resources section.