Skip to content

Commit

Permalink
fix: copy dts files (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin authored Oct 8, 2024
1 parent c3241e0 commit da67a21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"lint:css": "stylelint demo/**/*.html",
"build": "npm-run-all --parallel build:*",
"build:esbuild": "tsx scripts/build.ts",
"build:copy-dts": "tsx scripts/copy-dts.ts",
"build:tsc": "tsc --emitDeclarationOnly --isolatedModules -p tsconfig.build.json",
"start": "vite",
"test": "karma start karma.config.cjs",
Expand Down
17 changes: 17 additions & 0 deletions scripts/copy-dts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { constants, copyFile, mkdir } from 'node:fs/promises';
import { glob } from 'glob';

const root = new URL('../', import.meta.url);
const src = new URL('./src/', root);
const dist = new URL('./dist/', root);

await mkdir(dist, { recursive: true });

const files = await glob(['**/*.d.ts'], { cwd: src });
await Promise.all(
files.map(async (f) => {
const file = new URL(f, dist);
await mkdir(new URL('./', file), { recursive: true });
return await copyFile(new URL(f, src), file, constants.COPYFILE_FICLONE);
}),
);

0 comments on commit da67a21

Please sign in to comment.