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

Offen
#691 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
43/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv

Rechercherichtung

Start in vite-plugin/index.ts, in generateBundle and the byClassName lookup described in the issue. Trace how declaration classes are collected and matched to bundled .d.ts files, especially when names collide or gain $N suffixes. Reproduce the two cases with rolldown-plugin-dts or tsdown; done means each declaration receives only its own component metadata, and a plain class is not given another module's metadata.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Rust
Sterne
245
Forks
26
Ø Merge
1 T. 42 Min.
Gemergte PRs (30 T.)
83

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/oxc-angular-compiler

Alle Issues in voidzero-dev/oxc-angular-compiler

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.