Skip to content

Commit

Permalink
fix: Revert package to default to CJS (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marabyte authored Aug 11, 2023
1 parent b097962 commit adfe49a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .changeset/cool-zebras-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@sardine/colour": patch
---

fix: Reverts default export to CJS

Some widely used tools like [Jest still don't support ESM](https://jestjs.io/docs/ecmascript-modules) just yet.
This reverts the package to CJS, so node based tools can use it without any issues and we rely on modern bundlers to pick the ESM version when possible.
1 change: 0 additions & 1 deletion .cjs.swcrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"exclude": [".*\\.spec|test\\.(j|t)s$", "mocks", "types"],
"sourceMaps": true,
"minify": true,
"module": {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
"version": "2.0.1",
"description": "It does things to colours",
"module": "./dist/index.js",
"main": "./dist/index.js",
"main": "./dist/cjs/index.js",
"types": "./dist/index.d.ts",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/cjs/index.js",
"default": "./dist/index.js"
"import": "./dist/index.js",
"default": "./dist/cjs/index.js"
}
},
"scripts": {
"build": "rm -rf ./dist && npm run build:esm && npm run build:cjs && npm run types:emit",
"build:esm": "npx swc --config-file .esm.swcrc ./src -d ./dist",
"build:cjs": "npx swc --config-file .cjs.swcrc ./src -d ./dist/cjs",
"test": "rm -rf ./dist && npm run build:esm && c8 ava",
"test": "rm -rf ./dist && npm run build:cjs && c8 ava",
"test:coverage": "c8 -r lcovonly report",
"types:emit": "npx tsc --declaration --emitDeclarationOnly",
"types:check": "npx tsc --noEmit",
Expand Down

0 comments on commit adfe49a

Please sign in to comment.