diff --git a/.size-limit.ts b/.size-limit.ts index 6e08f51..831ac16 100644 --- a/.size-limit.ts +++ b/.size-limit.ts @@ -3,7 +3,7 @@ import { globbySync } from "globby"; import type { SizeLimitConfig } from "size-limit"; // Get all hooks from the `src/hooks` directory, and validate their size -const limits = globbySync("src/hooks/*.ts").map((file) => { +const limits = globbySync("src/hooks/use*.ts").map((file) => { const name = path.parse(file).name; return { diff --git a/package.json b/package.json index 19a7e75..355190a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,16 @@ "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } + }, + "./*": { + "import": { + "types": "./dist/hooks/*.d.ts", + "default": "./dist/hooks/*.js" + }, + "require": { + "types": "./dist/hooks/*.d.ts", + "default": "./dist/hooks/*.cjs" + } } }, "scripts": { diff --git a/tsup.config.ts b/tsup.config.ts index d08e0ae..3379d2a 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,14 +1,15 @@ +import { globbySync } from "globby"; import { defineConfig } from "tsup"; +const hooks = globbySync("src/hooks/use*.ts"); + export default defineConfig({ minify: false, - sourcemap: true, dts: true, clean: true, - target: "es2018", - external: ["react"], + external: ["react", "react-dom"], format: ["esm", "cjs"], - entry: ["src/index.ts"], + entry: ["src/index.ts", ...hooks], outDir: "dist", treeshake: true, });