Skip to content

Commit

Permalink
Publish dual ESM and CJS modules
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzing committed Sep 11, 2024
1 parent 8c1bf37 commit 44f0250
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Binary file modified bun.lockb
Binary file not shown.
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
"dist"
],
"main": "dist/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/index.js",
"default": "./dist/index.cjs"
}
},
"scripts": {
"build": "tsc",
"build": "tsup",
"check-format": "prettier --check .",
"format": "prettier --write .",
"check-types": "tsc --noEmit",
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
"ci": "bun run build && bun run check-format && bun run check-exports"
"check-exports": "attw --pack .",
"ci": "bun run check-types && bun run check-format && bun run build && bun run check-exports"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.15.4",
"@types/bun": "latest",
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"tsup": "^8.2.4"
},
"peerDependencies": {
"typescript": "^5.0.0",
Expand Down
8 changes: 2 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"jsx": "react-jsx",
"allowJs": true,
"outDir": "dist",
"noEmit": false,

// Bundler mode
"moduleResolution": "NodeNext",
Expand All @@ -22,11 +23,6 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true,

// If building with Typescript
"rootDir": "src",
"sourceMap": true,
"declaration": true
"noPropertyAccessFromIndexSignature": true
}
}
9 changes: 9 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "tsup";

export default defineConfig({
entryPoints: ["src/index.ts"],
format: ["cjs", "esm"],
dts: true,
outDir: "dist",
clean: true,
});

0 comments on commit 44f0250

Please sign in to comment.