diff --git a/CHANGELOG.md b/CHANGELOG.md index bc33294..381f35f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed +- **`import Datalyr from '@datalyr/api'` threw "Datalyr is not a constructor" in Node ESM.** With no `exports` map, Node loaded the CommonJS build for `import`, so the default import was the whole module object. An `exports` map now sends `import` to `dist/index.mjs` (types `dist/index.d.mts`) and `require` to `dist/index.js` (types `dist/index.d.ts`). `main`, `module` and `types` are unchanged, and deep imports under `dist/` still work. +- **Release as a minor version (1.4.0).** Two narrow cases change: an ESM workaround for the old bug (`new Datalyr.default()`, `Datalyr.Datalyr`, `(await import('@datalyr/api')).default.default`) no longer works, because the default import is now the class; use `import Datalyr from '@datalyr/api'` or `import { Datalyr } from '@datalyr/api'`. A deep import without a file extension (`@datalyr/api/dist/index`) no longer resolves; add `.js` or `.mjs`. + ## [1.3.4] - 2026-11-14 ### Fixed diff --git a/package.json b/package.json index 00a61f3..61e9016 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,20 @@ "main": "dist/index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, + "./package.json": "./package.json", + "./dist/*": "./dist/*" + }, "scripts": { "build": "tsup src/index.ts --format cjs,esm --dts --clean", "dev": "tsup src/index.ts --format cjs,esm --dts --watch",