From eab47fc8c955e2a14bca5f354e062a3418fae7b8 Mon Sep 17 00:00:00 2001 From: JC Louis Date: Mon, 16 Mar 2026 18:24:13 +0100 Subject: [PATCH] fix: add ESM exports for Vite 8 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vite 8 changed CJS interop behavior — without `__esModule: true` or an `exports` field, the default import resolves to the whole module.exports object instead of `.default`. Add an ESM wrapper (`index.mjs`) and conditional `exports` field in package.json so bundlers correctly resolve the default import. Closes #141 Co-Authored-By: Claude Opus 4.6 --- index.mjs | 2 ++ package.json | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 index.mjs diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db84199 --- /dev/null +++ b/index.mjs @@ -0,0 +1,2 @@ +import ReactJsonView from './dist/main.js' +export default ReactJsonView.default || ReactJsonView diff --git a/package.json b/package.json index e861277..f32eafc 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,15 @@ "version": "1.31.8", "types": "index.d.ts", "main": "dist/main.js", + "module": "index.mjs", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./dist/main.js", + "default": "./dist/main.js" + }, + "./package.json": "./package.json" + }, "author": { "name": "Mac Gainor" }, @@ -324,7 +333,8 @@ }, "files": [ "dist", - "index.d.ts" + "index.d.ts", + "index.mjs" ], "scripts": { "build": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=production webpack --config webpack/webpack.config.js --progress",