diff --git a/.changeset/jolly-dingos-spend.md b/.changeset/jolly-dingos-spend.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/jolly-dingos-spend.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/package.json b/package.json index 0d85ec2..a8c7bc3 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,8 @@ "changeset:status": "changeset status", "release:version": "changeset version", "typecheck": "tsc --noEmit && tsc -p tsconfig.workers.json --noEmit && tsc -p tsconfig.viewer.json --noEmit", - "build": "tsc -p tsconfig.build.json && npm run build:viewer && npm run build:embed", + "clean:dist": "node scripts/clean-dist.ts", + "build": "npm run clean:dist && tsc -p tsconfig.build.json && npm run build:viewer && npm run build:embed", "deploy": "npm run build:viewer && wrangler deploy", "dev:cloud": "npm run build:viewer && wrangler dev", "prepack": "npm run build", diff --git a/scripts/clean-dist.ts b/scripts/clean-dist.ts new file mode 100644 index 0000000..06c7fa2 --- /dev/null +++ b/scripts/clean-dist.ts @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +// Removes the tsc output tree before a package build. TypeScript only writes +// files, it never deletes output for sources that were renamed or removed, so a +// long-lived checkout accumulates stale modules that `npm pack` happily ships +// (and the "./*" export makes importable). The vite builds already self-clean +// via emptyOutDir, so this is the one output tree that needed it. +// +// Anchored to the package root rather than the process CWD so it cannot delete +// a `dist` belonging to whatever directory the script was invoked from. + +import { rmSync } from "node:fs"; + +rmSync(new URL("../dist", import.meta.url), { recursive: true, force: true });