From 70ed8c723c713109da2c53523dafada8f15ca633 Mon Sep 17 00:00:00 2001 From: Rafael Bardini Date: Tue, 15 Sep 2026 01:42:34 +0200 Subject: [PATCH] fix(package): use ESM build for browser entry The `browser` field pointed to the CommonJS build, so browser-targeting bundlers resolved `dist/cjs/index.js` and could mis-handle its default export interop (e.g. Rolldown's `import_cjs.default is not a function`). Point `browser` at the ESM build and add an `exports` map so modern resolvers use the ESM build for `import`/browser and the CJS build for `require`. Note: adding `exports` encapsulates the package, so deep imports such as `react-element-to-jsx-string/dist/cjs/index.js` are no longer available. --- package.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 31c1fa5e6..ae5f024b6 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,18 @@ "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", - "browser": "dist/cjs/index.js", + "browser": "dist/esm/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "browser": "./dist/esm/index.js", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "default": "./dist/esm/index.js" + }, + "./package.json": "./package.json" + }, "scripts": { "build": "rollup -c", "build:flow": "flow-copy-source -v --ignore=*.spec.js src/ dist/cjs",