Skip to content

chore!: ship ESM only, require node 22.12 - #39

Open
rexxars wants to merge 1 commit into
mainfrom
chore/esm-only-node-22
Open

chore!: ship ESM only, require node 22.12#39
rexxars wants to merge 1 commit into
mainfrom
chore/esm-only-node-22

Conversation

@rexxars

@rexxars rexxars commented Aug 11, 2026

Copy link
Copy Markdown
Member

Brings this package in line with the rest of the Portable Text packages, which are already ESM only on Node.js 22.12 or later. It was the one that got missed.

Changes

  • Dropped the CommonJS build. The require condition is gone from exports, main now points at the ESM entry, and module is removed as redundant under "type": "module". pkg-utils no longer emits dist/index.cjs.
  • Added engines.node: ">=22.12". There was no engines range at all before, so nothing was enforced.

pkg-utils build --strict requires main to be declared, which is why it points at dist/index.js here rather than being removed the way it was in @portabletext/toolkit.

Breaking

require("@portabletext/react-pdf") no longer resolves. Use import, or a dynamic await import() from a CommonJS file.

Verification

47 tests pass, lint and type-check clean, and the build output is a single ESM entry with no .cjs.

Unrelated, but worth knowing

While checking whether the nestLists() fix in @portabletext/toolkit@6.0.0 affects this package, I rendered lists that start deeper than level 1 and lists that skip levels, which the fixtures here do not currently cover. No code changes are needed. The output is correct: a level 3 opener gets its roman numeral, indentation follows the item's own level, and the generated intermediate levels draw no markers because direct mode fills them with item-less lists and listDeep carries no margin.

Two things did come up:

  • The dependencies here are a long way behind. @portabletext/react is on ^3.2.4 against a current 7.0.1, with an 8.0.0 pending in fix!: nest lists as deeply as their level says react-portabletext#340, and the type-only @portabletext/toolkit dep is on ^3.0.0 against 6.0.0. Worth planning separately.
  • No fixture covers a list that starts deeper than level 1. Since CI runs macOS only, a fixture plus a darwin snapshot would work here if you want the coverage.

Brings the package in line with the rest of the Portable Text packages, which
are already ESM only on Node.js 22.12 or later. `main` now points at the ESM
entry rather than a CommonJS build, and the `require` condition is gone, so
`pkg-utils` no longer emits `dist/index.cjs`.

There was no `engines` range before, so nothing was enforced.

BREAKING CHANGE: `require("@portabletext/react-pdf")` no longer resolves, since
the CommonJS build is gone. Use `import`, or a dynamic `await import()` from a
CommonJS file. Node.js 22.12 or later is required.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 50190f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@portabletext/react-pdf Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant