From 50190f366cf9b9ed1517dce95550fc051dd00b6b Mon Sep 17 00:00:00 2001 From: Espen Hovlandsdal Date: Tue, 11 Aug 2026 16:02:05 -0700 Subject: [PATCH] chore!: ship ESM only, require node 22.12 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/nervous-pianos-repeat.md | 17 +++++++++++++++++ package.json | 7 ++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .changeset/nervous-pianos-repeat.md diff --git a/.changeset/nervous-pianos-repeat.md b/.changeset/nervous-pianos-repeat.md new file mode 100644 index 0000000..c939c11 --- /dev/null +++ b/.changeset/nervous-pianos-repeat.md @@ -0,0 +1,17 @@ +--- +"@portabletext/react-pdf": major +--- + +The package is now ESM only, and requires Node.js 22.12 or later + +#### When you will see a difference + +Only if you load this package with `require()`, or build on Node.js 20 or earlier. If you already `import` it, nothing changes. + +#### What changes + +The package no longer ships a CommonJS build. `require("@portabletext/react-pdf")` will fail, where before it resolved to `dist/index.cjs`. Use `import` instead, or a dynamic `await import()` from a CommonJS file. + +This brings the package in line with the rest of the Portable Text packages, which are already ESM only. + +Node.js 20 reached end of life in April 2026. The package previously declared no `engines` range at all, so nothing was enforced. diff --git a/package.json b/package.json index ac41ad5..408eada 100644 --- a/package.json +++ b/package.json @@ -25,13 +25,11 @@ ".": { "source": "./src/index.ts", "import": "./dist/index.js", - "require": "./dist/index.cjs", "default": "./dist/index.js" }, "./package.json": "./package.json" }, - "main": "./dist/index.cjs", - "module": "./dist/index.js", + "main": "./dist/index.js", "types": "./dist/index.d.ts", "files": [ "dist", @@ -97,6 +95,9 @@ "vite": "^7.1.3", "vitest": "^3.2.4" }, + "engines": { + "node": ">=22.12" + }, "packageManager": "pnpm@10.11.1", "publishConfig": { "access": "public"