diff --git a/package.json b/package.json index f999bbf3..00d6650f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/copy-dts.ts b/scripts/copy-dts.ts new file mode 100644 index 00000000..1e1c7bd3 --- /dev/null +++ b/scripts/copy-dts.ts @@ -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); + }), +);