Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop CJS support, make it ESM-only #1232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## [Unreleased]

- Drops CJS support in favor of
[ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)

```tsx
// ❌ No longer supported
const { string } = require('decoders');

// ✅ Use import instead
import { string } from 'decoders';
```

- Use `node16` module resolution setting (recommended setting for libraries that run in
both browsers and Node environments)

Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@
"url": "https://github.com/nvie/decoders/issues"
},
"type": "module",
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"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"
}
}
},
Expand All @@ -39,7 +32,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",
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default defineConfig({
splitting: true,
clean: true,
// target: /* what tsconfig specifies */,
format: ['esm', 'cjs'],
format: ['esm'],
});