From 8566b8ca84ede34c901ea28da639aa8b047b07df Mon Sep 17 00:00:00 2001 From: Valentyn Blaha Date: Wed, 22 Apr 2026 20:43:39 +0200 Subject: [PATCH 1/2] fix: typescript declaration files in dist --- bunchee.config.js | 23 +++++++++++++++++++++++ package.json | 12 +++++++++--- tsconfig.json | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 bunchee.config.js diff --git a/bunchee.config.js b/bunchee.config.js new file mode 100644 index 0000000..9789205 --- /dev/null +++ b/bunchee.config.js @@ -0,0 +1,23 @@ +module.exports = { + dts: true, +}; +module.exports = { + entries: [ + { + input: 'src/index.tsx', + output: [ + { + format: 'esm', + file: 'dist/react-toggle-dark-mode.esm.js', + }, + { + format: 'cjs', + file: 'dist/index.js', + }, + ], + }, + ], + dts: { + resolve: true, + }, +}; diff --git a/package.json b/package.json index c72d1e6..0098605 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,11 @@ "node": ">=20" }, "scripts": { - "start": "tsdx watch", - "build": "tsdx build", + "start": "bunchee --watch", + "build": "bunchee", "test": "tsdx test", "lint": "tsdx lint", - "prepare": "husky && tsdx build" + "prepare": "husky && bunchee" }, "peerDependencies": { "react": ">=16" @@ -32,6 +32,12 @@ "description": "Animated dark mode toggle as seen in blogs!", "author": "Jose R. Felix (https://jfelix.info)", "module": "dist/react-toggle-dark-mode.esm.js", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.js" + } + }, "repository": { "type": "git", "url": "https://github.com/JoseRFelix/react-toggle-dark-mode" diff --git a/tsconfig.json b/tsconfig.json index 1e79b51..857a5f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "baseUrl": "./", "paths": { "*": ["src/*", "node_modules/*"] From 14ca36e3be099f4a3c6bdfe5dd71d6412a134553 Mon Sep 17 00:00:00 2001 From: valentynblaha <45700252+valentynblaha@users.noreply.github.com> Date: Fri, 24 Apr 2026 11:04:19 +0200 Subject: [PATCH 2/2] Add import entry to package.json exports --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0098605..2a8452a 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "exports": { ".": { "types": "./dist/index.d.ts", + "import": "./dist/react-toggle-dark-mode.esm.js", "require": "./dist/index.js" } },