Skip to content

build: generate types/ at build and pack time instead of committing it - #215

Merged
Shinrai merged 1 commit into
nextfrom
chore/generated-types
Nov 27, 2026
Merged

Shinrai merged 1 commit into
nextfrom
chore/generated-types

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

types/ is gitignored and built by types:build (tsc, then the headers are stamped) in build:ci and prepack. "types" points at the generated types/src/index.d.mts, and the config drops rewriteDeclarationCopies: false.

Resolves #211

@cldmv-bot cldmv-bot Bot added ! chore → next v4 flow: chore contributor PR targeting the next integration branch area: tests Touches test files, fixtures, or test infrastructure type: config Changes to repository or project configuration files type: dependencies Relates to dependency updates, version bumps, or package management labels Nov 27, 2026
Shinrai
Shinrai previously approved these changes Nov 27, 2026
types/ is gitignored and the 40 tracked declarations are removed.
types:build runs tsc and then stamps the declarations' headers with the
package's own CLI, and prepack runs types:build before the build.
"types" points at the generated types/src/index.d.mts (the hand-written
types/index.d.mts re-export and the stale devcheck.d.mts are gone), and
the config drops rewriteDeclarationCopies: false. The integration test
checks a types entry against the source tsc emits it from.

Resolves #211
@Shinrai
Shinrai merged commit 17e7682 into next Nov 27, 2026
34 checks passed
@cldmv-bot
cldmv-bot Bot deleted the chore/generated-types branch November 27, 2026 21:20
cldmv-bot Bot added a commit that referenced this pull request Nov 27, 2026
# `@cldmv/fix-headers` v2.6.0 Changelog

**Release Date**: November 2026
**Release Type**: Minor
**Branch**: `release/2.6.0`

---

## Overview

A declaration `tsc` emitted without a header now takes its source file's header dates and author, found through the tsconfig the declarations were built with. `src/index.cjs` is now the generic CLDMV CommonJS shim, and this package's own TypeScript declarations are generated at build and pack time instead of being committed. `require("@cldmv/fix-headers")` still returns the `fixHeaders` function, and the only new option is `tsconfig`.

---

## ✨ Features

### Headerless declarations take their source's header (#214)

`tsc` copies a source's header into its declaration only when no `import` lines follow the header; otherwise it drops it. Those declarations were stamped as new files on every build, with the build time as `@Last modified time`. fix-headers now finds the declaration's source through the tsconfig the declarations were built with: the declaration's path inside `declarationDir` (else `outDir`), under `rootDir` (else the tsconfig's folder), with the first matching source extension, following `extends`. The declaration's header then takes `@Date`, `@Author`, `@Last modified by` and `@Last modified time` from the source's header, so rebuilding the declarations no longer changes them. `@Filename` and `@Project` still name the declaration that ships, such as `types/src/x.d.mts`.

The tsconfig is the new `tsconfig` option (CLI `--tsconfig <path>`), relative to `cwd`, defaulting to `.configs/tsconfig.json` and then `tsconfig.json`. A default that is missing or can't be read is ignored. With no tsconfig, no source, a source without a header, or `rewriteDeclarationCopies: false`, the declaration is stamped like any new file, as before.

Fixes [#214](#214).

### Generic CommonJS shim ([#212](#212))

`src/index.cjs`, copied verbatim to `dist/index.cjs`, is the drop-in shim from the CLDMV package-layout convention instead of a hand-written `.default` unwrap. It returns the single distinct value the ESM entry exports, or the module object when there is more than one. fix-headers exports one function (`fixHeaders`, which is also the default export), so `require()` returns that function as before.

Fixes [#209](#209).

## 🔧 CI & tooling

### Declarations are generated, not committed ([#215](#215))

`types/` is gitignored. `npm run types:build` runs `tsc` and then stamps headers on its output with the package's own CLI, so each declaration names the file it ships as. `build:ci` and `prepack` both run it, so a published package always carries freshly built declarations. The package's `types` entry points at the generated `types/src/index.d.mts`; the hand-written `types/index.d.mts` re-export and the leftover `types/devcheck.d.mts` are gone. The repo's fix-headers config no longer sets `rewriteDeclarationCopies: false`.

Fixes [#211](#211).

### Superseded CI runs cancel outside the release branch ([#213](#213))

`ci.yml` takes the CLDMV/.github v4.46.0 concurrency block: only the release base branch keeps a unique group per run, so a newer push cancels the older run on `next`, `hotfixes` and feature branches.

Fixes [#210](#210).

## 📚 Documentation

- **NEW:** [docs/changelog/v2/v2.6.0.md](https://github.com/CLDMV/fix-headers/blob/v2.6.0/docs/changelog/v2/v2.6.0.md): this changelog.
- README: the `tsconfig` option and `--tsconfig` flag, and the rule for declarations `tsc` emitted without a header (#214).
- README What's New promoted to v2.6.0.

## 🔧 Dependencies

_No dependency updates._

---

## Upgrade notes

- `require()` and `import` return what they did in 2.5.1. The one new option is `tsconfig` (`--tsconfig`); without it, fix-headers looks for `.configs/tsconfig.json` and then `tsconfig.json`.
- TypeScript consumers resolve the declarations through `exports` as before; only the file's path inside the package changed, from `types/index.d.mts` to `types/src/index.d.mts`.



<details>
<summary>👥 Contributors</summary>

- @Shinrai

</details>

---

<!-- coverage-start -->

![coverage](https://img.shields.io/badge/coverage-99.6%25-brightgreen?style=for-the-badge&logo=vitest&logoColor=white)

| Metric | Coverage |
|--------|----------|
| Statements | 99.9% |
| Branches   | 98.9% |
| Functions  | 100.0% |
| Lines      | 99.9% |

*Avg: **99.6%** · `a76b236` · Node lts/**

<!-- coverage-end -->

<!-- co-authors -->

Co-authored-by: Shinrai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Touches test files, fixtures, or test infrastructure ! chore → next v4 flow: chore contributor PR targeting the next integration branch type: config Changes to repository or project configuration files type: dependencies Relates to dependency updates, version bumps, or package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant