Skip to content

Commit

Permalink
improve treeshaking
Browse files Browse the repository at this point in the history
  • Loading branch information
thebuilder committed Jul 24, 2024
1 parent a073b1b commit ee1ca36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .size-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 5 additions & 4 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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,
});

0 comments on commit ee1ca36

Please sign in to comment.