Skip to content

Commit 19c6c1e

Browse files
Fix ESM module format extension in squircle-js/react package (#31)
* Refactor build scripts and add tsup configuration for better module handling * chore: add changeset for ESM module format fix
1 parent 1e37a0d commit 19c6c1e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.changeset/plenty-colts-take.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squircle-js/react": patch
3+
---
4+
5+
Fix ESM module format in build output to resolve Vite import errors. Ensures .mjs files are generated correctly by tsup for ESM modules.

packages/squircle-element-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"module": "dist/index.mjs",
88
"types": "dist/index.d.ts",
99
"scripts": {
10-
"build": "tsup src/index.tsx --format cjs,esm --dts --external react",
11-
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
10+
"build": "tsup",
11+
"dev": "tsup --watch",
1212
"clean": "rm -rf .turbo dist node_modules",
1313
"format": "prettier --check . --ignore-path ../../.gitignore",
1414
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
@@ -46,4 +46,4 @@
4646
"name": "Antoni Silvestrovic",
4747
"email": "[email protected]"
4848
}
49-
}
49+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.tsx"],
5+
format: ["cjs", "esm"],
6+
dts: true,
7+
external: ["react"],
8+
outExtension({ format }) {
9+
return {
10+
js: format === "esm" ? ".mjs" : ".js",
11+
}
12+
},
13+
})

0 commit comments

Comments
 (0)