# Emit type declarations with tsc. The source has a few type-check errors that
# only appear with the older TypeScript in Debian (upstream uses TS >= 5.4's
# native NoInfer), so tolerate a non-zero exit: the .d.ts files are still
# emitted and the generated JavaScript is unaffected.
tsc -p tsconfig.json --noEmit false --emitDeclarationOnly --declaration \
    --noEmitOnError false --outDir dist || true

# Build the dual CJS+ESM bundles (and bundle the declarations into types.d.ts).
rollup -c debian/rollup.config.mjs

# Remove the intermediate declaration tree left behind (upstream used
# rollup-plugin-delete for this); only the bundled dist/types.d.ts should ship.
rm -rf dist/lib dist/index.d.ts
