From 15f6f916b95ecc5b9440c6581956eec955196674 Mon Sep 17 00:00:00 2001 From: Taj Date: Tue, 5 Aug 2025 17:21:56 +0530 Subject: [PATCH 1/2] feat: Migrate tsup configuration to tsup.config.ts This commit migrates the tsup build and dev configurations from package.json scripts to a dedicated tsup.config.ts file. This centralizes the build configuration and improves maintainability. --- package.json | 4 ++-- tsconfig.json | 2 +- tsup.config.ts | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tsup.config.ts diff --git a/package.json b/package.json index c0df8a9..ed2485a 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "dist" ], "scripts": { - "build": "tsup src/index.tsx --format esm,cjs --dts", - "dev": "tsup src/index.tsx --watch --format esm,cjs", + "build": "tsup", + "dev": "tsup --watch", "test": "vitest run", "clean": "rm -rf dist", "prepare": "pnpm build", diff --git a/tsconfig.json b/tsconfig.json index c2908d6..89cb785 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "ES2020", "module": "ESNext", - "moduleResolution": "Node", + "moduleResolution": "bundler", "lib": ["DOM", "ES2020"], "types": ["vitest/globals"], "allowJs": true, diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..a2e4a71 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from 'tsup'; +import pkg from './package.json'; + +export default defineConfig((options) => ({ + entry: ['src/index.tsx'], + format: ['esm', 'cjs'], + dts: true, + watch: options.watch, + clean: true, + banner: { + js: `/** + * ${pkg.name} v${pkg.version} + * Author: ${pkg.author} + */ + `, + }, +})); \ No newline at end of file From 99fc6ba8c51bc7141d975c69560e323615c151c1 Mon Sep 17 00:00:00 2001 From: Taj <87968438+taj54@users.noreply.github.com> Date: Tue, 5 Aug 2025 17:33:50 +0530 Subject: [PATCH 2/2] Update tsup.config.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- tsup.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tsup.config.ts b/tsup.config.ts index a2e4a71..5dcddfa 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,12 +1,18 @@ import { defineConfig } from 'tsup'; import pkg from './package.json'; +export default defineConfig((options) => ({ export default defineConfig((options) => ({ entry: ['src/index.tsx'], format: ['esm', 'cjs'], + outExtension: ext => ({ + esm: '.mjs', + cjs: '.cjs', + }), dts: true, watch: options.watch, clean: true, +})); banner: { js: `/** * ${pkg.name} v${pkg.version}