Skip to content

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

Open
benjavicente wants to merge 1 commit into
voidzero-dev:mainfrom
benjavicente:fix/dts-declaration-chunks
Open

benjavicente wants to merge 1 commit into
voidzero-dev:mainfrom
benjavicente:fix/dts-declaration-chunks

Conversation

@benjavicente

Copy link
Copy Markdown

🤖 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.

Tests

  • dts.test.ts: a .d.mts chunk gets the members, and JavaScript chunks are left alone.
  • 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

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
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)

1 participant