@react-pdf/font started to depend on [email protected] and triggers a TypeError: Invalid URL

Open
#3,532 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active

Research direction

Start by inspecting @react-pdf/font 4.1.x dependency resolution and the referenced pdfkit/lib/mixins/pdfa.js at v0.20.1; then run Node against the transpiled bundle in the reported Linux, TypeScript, pnpm, and ESBuild setup. Done means the @react-pdf/font upgrade no longer throws TypeError: Invalid URL.

Written by the indexing model from the issue text.

Description

Describe the bug
Upgrading @react-pdf/font from 4.0.9 to 4.1.0 or 4.1.1 caused a TypeError: Invalid URL

To Reproduce
It is difficult for me to share a reproducible code snippet / example.

In our project, @react-pdf/font is a dependency of @react-pdf/[email protected]([email protected]) and @react-pdf/[email protected].
We use TypeScript, pnpm, and our code is transpiled using ESBuild.
When invoking Node on the transpiled JS bundle, we get this stracktrace:

TypeError: Invalid URL
    at new URL (node:internal/url:840:25)
    at Object.<anonymous> (/app/node_modules/.pnpm/[email protected]/node_modules/pdfkit/lib/mixins/pdfa.js:3:33)
    at Module._compile (node:internal/modules/cjs/loader:1871:14)
    at Object..js (node:internal/modules/cjs/loader:2002:10)
    at Module.load (node:internal/modules/cjs/loader:1594:32)
    at Module._load (node:internal/modules/cjs/loader:1396:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47

It seems that @react-pdf/[email protected] started to depend on [email protected], and TypeError: Invalid URL is raised from there:
https://github.com/foliojs/pdfkit/blob/v0.20.1/lib/mixins/pdfa.js#L3

export const ICC_PROFILE_PATH = new URL(
  './data/sRGB_IEC61966_2_1.icc',
  import.meta.url,
).href;

Expected behavior
No exception raised

Desktop (please complete the following information):

Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
11m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diegomura/react-pdf

All issues in diegomura/react-pdf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.