Skip to content

Commit

Permalink
build: use vite plugin to remove redundant dts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcaidev committed Feb 5, 2023
1 parent 0768c38 commit d706845
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
3 changes: 2 additions & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"directory": "packages/hooks"
},
"scripts": {
"build": "vite build && node scripts/remove-redundant-dts.js",
"build": "vite build",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
Expand All @@ -45,6 +45,7 @@
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitest/coverage-c8": "^0.28.4",
"fast-glob": "^3.2.12",
"jsdom": "^21.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/hooks/plugins/remove-redundant-dts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import glob from "fast-glob";
import { rm } from "fs/promises";
import { normalizePath } from "vite";

export async function removeRedundantDts() {
const files = await glob("*.d.ts", {
cwd: "dist",
ignore: ["!index.d.ts"],
});
files.forEach((file) => rm(normalizePath(`dist/${file}`)));
}
16 changes: 0 additions & 16 deletions packages/hooks/scripts/remove-redundant-dts.js

This file was deleted.

2 changes: 2 additions & 0 deletions packages/hooks/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import tsconfigPaths from "vite-tsconfig-paths";
import { removeRedundantDts } from "./plugins/remove-redundant-dts";

export default defineConfig({
plugins: [
tsconfigPaths(),
dts({
rollupTypes: true,
afterBuild: removeRedundantDts,
}),
],
build: {
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d706845

Please sign in to comment.