Skip to content

build: drop --dts, which emitted declarations nothing can import - #166

Closed
dawsontoth wants to merge 1 commit into
mainfrom
build/drop-unused-dts
Closed

build: drop --dts, which emitted declarations nothing can import#166
dawsontoth wants to merge 1 commit into
mainfrom
build/drop-unused-dts

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

One of two alternatives. This is the minimal unblock for TypeScript 7 — it stays on tsup and drops declaration emit. The other is the tsdown migration, which keeps types and gets us off unmaintained tooling. Pick one, not both.

The blocker

tsup 8.5.1 inlines its own rollup-plugin-dts@6.1.1, compiled against typescript@5.7.3. That copy throws on TS 7:

TypeError: Cannot read properties of undefined (reading 'useCaseSensitiveFileNames')
    at node_modules/.pnpm/rollup-plugin-dts@6.1.1_rollup@4.53.2_typescript@5.7.3/node_modules/rollup-plugin-dts/...
       (node_modules/tsup/dist/rollup.js:4857:37)

Note the vendored path — nothing in our lockfile reaches that copy, so no overrides on our side can fix it. tsup hasn't published since 2025-11-12 (8.5.1 is the only dist-tag), so waiting isn't a strategy.

The part that makes this easy

The crash is confined to the DTS step. The ESM bundle completes first — you can see ESM ⚡️ Build success in the log immediately before the stack trace.

And the declarations that step produces are unreachable:

// package.json — as it stands today
"exports": { ".": "./dist/index.js" }   // no "types" condition
// no "types" field, no "typings"

No TypeScript consumer can resolve them. Nothing in the org imports @harperfast/agent as a library either — it's consumed as a CLI through bin. So we've been paying for declaration emit no one could use, and it is the only thing standing between us and TS 7.

Verification

typescript 6.0.3 typescript 7.0.2
npm run build exit 0 exit 0

dist/ still contains cli.js, index.js, chunk-*.js, schema.graphql; node ./dist/cli.js --help runs. Lint, format, and 53 files / 345 tests pass.

What you give up

The .d.ts files. Concretely: nothing, until someone adds a types condition to exports — at which point the tsdown branch is the better answer anyway.

🤖 Generated with Claude Code

This is what blocks the TypeScript 7 upgrade (#145). tsup 8.5.1 inlines its
own `rollup-plugin-dts@6.1.1` compiled against `typescript@5.7.3`, and that
copy throws on TS 7:

  TypeError: Cannot read properties of undefined (reading 'useCaseSensitiveFileNames')
      at node_modules/.pnpm/rollup-plugin-dts@6.1.1_rollup@4.53.2_typescript@5.7.3/...

Nothing in our lockfile reaches that vendored copy, so no `overrides` can
fix it, and tsup has not published since 2025-11-12 (8.5.1 is the only
dist-tag).

The crash is confined to the DTS step - the ESM bundle completes before it.
And the declarations that step produces are unreachable anyway: package.json
has no `types` field, no `typings`, and no `types` condition in `exports`
(just `{".": "./dist/index.js"}`), so no TypeScript consumer can resolve
them. Nothing in the org imports @harperfast/agent as a library either; it
is consumed as a CLI through `bin`.

So we have been paying for declaration emit that no consumer could use, and
it is the only thing standing between us and TS 7.

Verified: build succeeds on both typescript 6.0.3 and 7.0.2, dist still
contains cli.js / index.js / schema.graphql, and `node ./dist/cli.js --help`
runs. Lint, format, and 345 tests pass.

Note this is the minimal unblock. If we would rather keep publishing types,
the tsdown migration does that and gets us off unmaintained tooling - the
two are alternatives, not a sequence.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the --dts flag from the dev and build scripts in package.json. The reviewer suggests further optimization by removing the unused index.ts entry point from both scripts, since the package is only used as a CLI and no longer needs to compile the library entry point.

Comment thread package.json
"homepage": "https://github.com/harperfast",
"scripts": {
"dev": "tsup index.ts cli.ts --format esm --clean --dts --watch --external puppeteer",
"dev": "tsup index.ts cli.ts --format esm --clean --watch --external puppeteer",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In sync with the build script changes, consider removing index.ts from the dev script entry points to avoid compiling the unused library entry point.

Suggested change
"dev": "tsup index.ts cli.ts --format esm --clean --watch --external puppeteer",
"dev": "tsup cli.ts --format esm --clean --watch --external puppeteer",

Comment thread package.json
"dev": "tsup index.ts cli.ts --format esm --clean --watch --external puppeteer",
"link": "npm run build && npm link",
"build": "tsup index.ts cli.ts --format esm --clean --dts --external puppeteer && cp node_modules/harper/schema.graphql dist/",
"build": "tsup index.ts cli.ts --format esm --clean --external puppeteer && cp node_modules/harper/schema.graphql dist/",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since --dts is being dropped because this package is only consumed as a CLI and not as a library, index.ts and its compiled output dist/index.js are now dead code.

To clean this up and avoid exposing an untyped entry point, consider removing index.ts from the tsup entry points.

Note: If you apply this suggestion, please also remember to:

  1. Remove the . export from the exports field in package.json (lines 33-35).
  2. Delete the unused index.ts file.
Suggested change
"build": "tsup index.ts cli.ts --format esm --clean --external puppeteer && cp node_modules/harper/schema.graphql dist/",
"build": "tsup cli.ts --format esm --clean --external puppeteer && cp node_modules/harper/schema.graphql dist/",

@dawsontoth

Copy link
Copy Markdown
Contributor Author

Closing in favor of #167 — the team is going with the tsdown migration, which unblocks TypeScript 7 the same way but also keeps declaration emit and moves off tsup (unpublished since 2025-11-12).

No cleanup needed here; the branch is independent of #167.

🤖 Closed via Claude Code

@dawsontoth dawsontoth closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant