Skip to content

Commit 0616fc7

Browse files
committed
🐛 Fix build by emitting types and add package exports
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 7d36a67 commit 0616fc7

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed
File renamed without changes.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
"README.md",
2121
"CHANGELOG.md"
2222
],
23+
"type": "module",
24+
"main": "dist/index.cjs",
25+
"types": "./dist/index.d.ts",
2326
"exports": {
24-
"import": "./dist/index.mjs",
25-
"require": "./dist/index.js"
27+
".": {
28+
"import": "./dist/index.es.mjs",
29+
"require": "./dist/index.cjs",
30+
"types": "./dist/index.d.ts"
31+
}
2632
},
27-
"types": "./dist/index.d.ts",
2833
"scripts": {
29-
"build": "rollup -c rollup.config.mjs",
34+
"build": "rm -v dist/* && rollup -c rollup.config.js",
3035
"check-types": "tsc --noEmit",
3136
"format": "prettier --write src '*.{js,mjs,cjs}'",
3237
"lint": "prettier --check src '*.{js,mjs,cjs}'",

rollup.config.mjs renamed to rollup.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ const external = [
1818
const config = (input, output) => ({
1919
input,
2020
external,
21-
plugins: [typescript()],
21+
plugins: [typescript({ declaration: output.format === "esm" })],
2222
output: [output],
2323
})
2424

2525
export default [
2626
config("./src/index.ts", {
27-
file: "dist/index.mjs",
27+
file: "dist/index.es.mjs",
2828
format: "esm",
2929
}),
3030
config("./src/index.ts", {
31-
file: "dist/index.js",
31+
file: "dist/index.cjs",
3232
format: "cjs",
3333
}),
3434
]

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"compilerOptions": {
44
"outDir": "./dist",
5+
"declaration": true,
56
"esModuleInterop": true,
67
"moduleResolution": "node",
78
// Node 16

0 commit comments

Comments
 (0)