From ab06d28a4f70577c577b0f7b976473b70676df77 Mon Sep 17 00:00:00 2001 From: czy Date: Sun, 22 Nov 2026 15:38:49 -0600 Subject: [PATCH 1/2] W2: package entry points work in CommonJS, ESM and bundlers Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 +++ package.json | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc33294..9d42960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ 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. + ## [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", From 2a486dd7079934f94d2d2cd5c2ad7e3cd0817935 Mon Sep 17 00:00:00 2001 From: czy Date: Sun, 22 Nov 2026 15:43:48 -0600 Subject: [PATCH 2/2] Changelog: the two narrow cases the exports map changes; ship as a minor Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d42960..381f35f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### 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