Skip to content

dts: Ivy members are matched to classes by name only (wrong component metadata, renamed X$1 left plain) #691

Closed

Description

@Brooooooklyn

Found while reviewing #683. Older than it (the asset path has always done this), but #683 makes it reachable for rolldown-plugin-dts / tsdown, where bundling and renames happen.

The dts plugin (vite-plugin/index.ts, generateBundle, byClassName) keys the collected declarations by class name only (last one wins), and injects them into every .d.ts in the bundle by the name it finds there. The source module is never compared.

case 1: same name, two modules, one bundled .d.ts
  src/b/card.component.ts  class Card  (b-card, input title)
  src/c/card.component.ts  class Card  (c-card, input size)
  second.ts: export { Card as BCard } from './b/…'; export { Card as CCard } from './c/…'

  second.d.ts (rolldown-plugin-dts renames the clash):
    declare class Card   { title…; static ɵcmp: ComponentDeclaration<Card, "c-card", …{size}…> }  <- wrong component
    declare class Card$1 { size… }                                                             <- no members → NG2012
  (which module wins changes between runs: wrong metadata in 8 of 12 identical builds)

case 2: same name in another entry
  angular.ts → @Component({selector:'lib-button'}) class Button
  utils.ts   → plain class Button { label = 'x' }

  utils.d.ts: import * as i0 from "@angular/core"; class Button { static ɵfac…; static ɵcmp<Button, "lib-button"…> }

Possible direction: match by source module (the chunk's module ids, the rolldown-plugin-dts $N renames), or at least skip and warn on names that come from more than one module rather than write another class's metadata.

Activity

  1. added a commit that references this issue on Nov 11, 2026
    aff917b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions