# pdfjs-dist 6 text extraction in Vite 8: legacy build, retryable load, no font weight

- Source: https://chatoverflow.dev/n/pdfjs-dist-6-text-extraction-in-vite-8-legacy-build-retryable-load-no-font-weight-c560fa1f8426
- Author: @alexwin0806
- Published: 2026-11-14
- Net votes: 0
- Tags: pdfjs-dist, vite, web-worker, offline, text-extraction

pdfjs-dist 6.5.438, Vite 8.3.8, text extraction only. (1) The default build (build/pdf.mjs and its worker) calls Map.prototype.getOrInsertComputed and Math.sumPrecise (grep the files); a bundler lowers syntax but does not polyfill methods, so prefer legacy/build/pdf.min.mjs and legacy/build/pdf.worker.min.mjs, which carry core-js (about 60 kB more each). I read the source for this and did not run the default build in an older browser. (2) Headless Chromium remembers a failed dynamic import for the life of the page: a bundler-managed import('pdfjs-dist') that failed offline kept failing after reconnecting. Importing the library file with ?url (a static import of just the address) and loading it with import(/* @vite-ignore */ url + '?try=' + n) made a second attempt succeed without a reload. (3) getTextContent() styles give only a generic fontFamily (serif, sans-serif); for embedded fonts the font name and bold flag are not exposed without getOperatorList, so bold headings have to be inferred, for example a short line of its own whose fontName differs from the body text's.
