From 4ed3733a0e0fb2845cbcacbc2907bce57f6a38bf Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Thu, 6 Feb 2025 00:40:58 +0100 Subject: [PATCH] Drop CJS support, make it ESM-only --- CHANGELOG.md | 10 ++++++++++ package.json | 11 ++--------- tsup.config.ts | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c28d4c7..9a09ce11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ ## [Unreleased] +- Drops CJS support in favor of ESM only + +```tsx +// ❌ No longer supported +const { string } = require('decoders'); + +// ✅ Use import instead +import { string } from 'decoders'; +``` + ## [2.6.0] - 2025-02-04 - Implement the [Standard Schema](https://standardschema.dev/) specification. diff --git a/package.json b/package.json index f98dee14..a29052a8 100644 --- a/package.json +++ b/package.json @@ -13,19 +13,12 @@ "url": "https://github.com/nvie/decoders/issues" }, "type": "module", - "main": "./dist/index.cjs", - "module": "./dist/index.js", - "types": "./dist/index.d.cts", + "main": "./dist/index.js", "exports": { ".": { "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" - }, - "require": { - "types": "./dist/index.d.cts", - "module": "./dist/index.js", - "default": "./dist/index.cjs" } } }, @@ -40,7 +33,7 @@ "docs": "cog -cr docs/*.md", "lint": "eslint --color --report-unused-disable-directives src/ test/ && prettier --list-different src/ test/ test-d/", "lint:docs": "cog -c --check docs/*.md || (npm run docs; git diff; echo 'Error: docs not up-to-date, please re-run \"npm docs\" to update them.' && exit 1)", - "lint:package": "publint --strict && attw --pack", + "lint:package": "publint --strict && attw --pack --profile esm-only", "format": "eslint --color --report-unused-disable-directives --fix src/ test/ ; prettier --write src/ test/ test-d/", "test": "vitest run --coverage", "test:completeness": "./bin/check.sh", diff --git a/tsup.config.ts b/tsup.config.ts index 22f735b6..13477bd2 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -6,5 +6,5 @@ export default defineConfig({ splitting: true, clean: true, // target: /* what tsconfig specifies */, - format: ['esm', 'cjs'], + format: ['esm'], });