Skip to content

fix(vite): add Ivy members to .d.ts chunks - #683

Merged
Brooooooklyn merged 2 commits into
voidzero-dev:mainfrom
benjavicente:fix/dts-declaration-chunks
Nov 9, 2026
Merged

Brooooooklyn merged 2 commits into
voidzero-dev:mainfrom
benjavicente:fix/dts-declaration-chunks

Conversation

@benjavicente

@benjavicente benjavicente commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Made by agents
🙋‍♂️ reviewed by human: this escentially adds the "augments .d.ts assets in partial mode" branch for chunk files (see the test above of the one added)

Fixes #681

Summary: the dts plugin only added the Ivy members (ɵfac, ɵcmp, …) to .d.ts outputs of type asset. rolldown-plugin-dts (and so tsdown) emits declarations as chunks, so libraries built with it published plain classes and consumers failed with NG2012. This PR also augments .d.ts chunks.

Changes

  • vite-plugin/index.ts: .d.ts chunks are augmented through code, and assets through source as before.
  • README.md: lists the declaration outputs that get the members (rolldown-plugin-dts, tsdown ESM) and those that don't: vite-plugin-dts and tsc write their files outside the bundle, and tsdown builds the .d.cts of format: 'cjs' in a pass without user plugins. Fixes the rolldown-plugin-dts import ({ dts }). Support for those generators: dts: declarations from vite-plugin-dts, tsc and tsdown's .d.cts are not augmented #694.

Tests

  • dts.test.ts: a .d.mts chunk gets the members, and JavaScript chunks are left alone.
  • dts.test.ts: a shared chunk in rolldown-plugin-dts's shape (declare class X {} + export { X as t }) gets the members.
  • Checked end to end with the reproduction below: the declaration gets ɵcmp and the consumer app compiles.

Reproduction: https://github.com/benjavicente/oxc-angular-repro-dts-chunks

Known limits (older than this PR, now reachable through chunks; tracked separately)

benjavicente and others added 2 commits November 8, 2026 20:04
The dts plugin only augmented declaration outputs of type `asset`, but
rolldown-plugin-dts (and so tsdown) emits declarations as chunks. The
published `.d.ts` then had no `ɵfac` / `ɵcmp` members, and Angular
rejected the library's standalone components (NG2012: "Component imports
must be standalone components, directives, pipes, or must be NgModules").

Augment `.d.ts` chunks through their `code`, and assets through their
`source` as before.

Fixes voidzero-dev#681
The README listed vite-plugin-dts and tsc as generators whose `.d.ts` get
augmented, but both write their files outside the bundle, after
`generateBundle`. tsdown's `.d.cts` for a `cjs` format is built in a
separate pass without user plugins. Say so, and fix the
rolldown-plugin-dts import (`{ dts }`).

Also read and write the chunk / asset text in one path, and test the
shared-chunk shape rolldown-plugin-dts emits (`declare class X` +
`export { X as t }`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T04:20:30.866184Z ffa622a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: ffa622a22d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn
Brooooooklyn merged commit e63af59 into voidzero-dev:main Nov 9, 2026
9 checks passed
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.

Ivy members are not added to .d.ts files generated by rolldown-plugin-dts (emitted as chunks, not assets)

2 participants