diegomura / diegomura/react-pdf

@react-pdf/font started to depend on pdfkit@0.20.1 and triggers a TypeError: Invalid URL

Open
#3,532 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

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/renderer@4.6.0(react@19.2.8)` and `@react-pdf/types@2.13.1`.
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. (/app/node_modules/.pnpm/pdfkit@0.20.1/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/font@4.1.0` started to depend on `pdfkit@0.20.1`, and `TypeError: Invalid URL` is raised from there:
https://github.com/foliojs/pdfkit/blob/v0.20.1/lib/mixins/pdfa.js#L3
```javascript
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):**

- OS: Linux
- React-pdf version: `@react-pdf/renderer@4.6.0(react@19.2.8)`

Contributor guide

Open the contributing guide

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.

Assessment

Tech stack
node.js, react, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.