Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

externalSchematic executes schematics from migration.json instead of collection.json

Offen
#21,131 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
angular, typescript
Bereich
tooling

Rechercherichtung

Beginne mit SchematicEngine.createCollection und dem im Bericht beschriebenen externalSchematic-Aufruf. Verfolge anschließend, wie collection.json und migration.json unter demselben Paketnamen geladen und zwischengespeichert werden. Reproduziere das ngx-my-lib-Szenario und überprüfe, dass externalSchematic das Schematic aus collection.json statt aus migration.json auflöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

area: @angular-devkit/schematics freq1: low severity3: broken type: bug/fix

🐞 Bug report

Command
  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc
Is this a regression?
No
Description

The function externalSchematic from @angular-devkit/schematics does not call the schematic from the collection.json but instead from the migration.json If the collection (package) name is the same as the current package that is migrated.

🔬 Minimal Reproduction

  1. The package ngx-my-lib has the schematic config defined in the collection.json
  2. Create a migration schematic for the package ngx-my-lib.
  3. Call the externalSchematic function with externalSchematic('ngx-my-lib', 'config') in the migration schematic.
  4. Execute the migration schematic

🔥 Exception or Error

Schematic "config" not found in collection "ngx-my-lib"

🌍 Your Environment


Angular CLI: 12.0.3
Node: 14.16.1
Package Manager: yarn 1.22.10
OS: linux x64

Angular: undefined
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1200.3
@angular-devkit/core         12.0.3
@angular-devkit/schematics   12.0.3
@angular/cli                 12.0.3
@schematics/angular          12.0.3
typescript                   4.2.4

Anything else relevant?

I could track down this error to the createCollection method in the class SchematicEngine. Invoking the externalSchematic the Collection instance for the migration.json is cached with the key ngx-my-lib. So the external schematic execution does not load the collection for the collection.json, but for the migration.json.

Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
17 Std. 25 Min.
Gemergte PRs (30 T.)
183

Beitragsleitfaden

Beitragsleitfaden öffnen

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 angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

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