Browse Source

feat(persist): add 'exports' field for proper ESM/CJS resolution (#4611)

* feat(persist): add 'exports' field for proper ESM/CJS resolution

What: add "exports" field to package.json, mapping ESM to ./dist/module.esm.js and CJS to ./dist/module.cjs.js
Why: tools like Vite default to main when exports is absent, causing CJS to be used in dev server and breaking default export detection.
How: update package.json, built & tested locally with Vite and Node (import/require).
Backward compatibility: keeps existing main & module fields.

* Format package.json
TANIGUCHI Masaya 3 weeks ago
parent
commit
2dd15560a1
1 changed files with 4 additions and 0 deletions
  1. 4 0
      packages/persist/package.json

+ 4 - 0
packages/persist/package.json

@@ -13,5 +13,9 @@
     "main": "dist/module.cjs.js",
     "module": "dist/module.esm.js",
     "unpkg": "dist/cdn.min.js",
+    "exports": {
+        "import": "./dist/module.esm.js",
+        "require": "./dist/module.cjs.js"
+    },
     "dependencies": {}
 }