Skip to content

Fix the browser build failing to load without import.meta.url - #1874

Merged
blikblum merged 3 commits into
foliojs:masterfrom
ravitejas-tech:fix/browser-icc-profile-import-meta
Nov 26, 2026
Merged

blikblum merged 3 commits into
foliojs:masterfrom
ravitejas-tech:fix/browser-icc-profile-import-meta

Conversation

@ravitejas-tech

Copy link
Copy Markdown
Contributor

Fixes #1873

What kind of change does this PR introduce?

Bug fix. The browser build registered its embedded sRGB ICC profile at import time, under the path getIccProfilePath() resolves from import.meta.url. Bundles for runtimes such as Cloudflare Workers leave import.meta.url undefined, so importing pdfkit threw.

The browser build now registers the profile under a fixed name (sRGB_IEC61966_2_1.icc) and points the PDF/A output at it, so it never reads import.meta.url. The Node build is unchanged and still resolves the file on first use.

The new test bundles the browser entry the way the release build does, with import.meta.url resolved to undefined. It checks that the bundle loads and that PDF/A-1 output still contains the ICC output intent.

Checklist:

  • Unit Tests
  • Documentation N/A
  • Update CHANGELOG.md
  • Ready to be merged

The browser build registered its embedded sRGB ICC profile under the
path getIccProfilePath() resolves from import.meta.url, at import time.
Bundles for runtimes such as Cloudflare Workers leave import.meta.url
undefined, so importing pdfkit threw.

The profile is embedded, so register it under a fixed name and point
the PDF/A output at that name instead.

Fixes foliojs#1873
Comment thread lib/mixins/pdfa.js Resolved
@blikblum
blikblum merged commit ad00f9c into foliojs:master Nov 26, 2026
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.

browser build still reads import.meta.url at module load: registerFile(getIccProfilePath(), ...) runs at top level

2 participants