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..5dcddfa --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,23 @@ +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} + * Author: ${pkg.author} + */ + `, + }, +})); \ No newline at end of file