Support executing ESM schematics
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- angular, typescript
- Bereich
- cli
Rechercherichtung
Beginne damit, den Angular CLI-Pfad nachzuverfolgen, der benutzerdefinierte Schematics kompiliert und ausführt, und vergleiche ihn anschließend mit dem referenzierten Angular-Workaround loadEsmModule() und den verlinkten Schematics-Beispielen. Als erledigt gilt, dass ESM-Schematics ohne den gemeldeten CommonJS-Fehler require() ausgeführt werden können und dieses Verhalten durch Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🚀 Feature request
Support schematics written in ES Modules. Currently only CommonJS schematics are supported.
Command (mark with an x)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
- other: compiling custom schematics
Description
Currently custom (and official) schematics can execute only CommonJS code, but not ES Modules. This is problematic when you want to import an ES Module in your custom schematics, for example HtmlParser from @angular/compiler (which since ng13 is shipped only as ESM).
Problems with not supporting ESM:
The following error started to occur for our custom schematics in runtime, since we upgraded from ng12 to 13:
require() of ES Module <path-to-the-repo>/node_modules/@angular/compiler/fesm2015/compiler.mjs not supported. Instead change the require of <path-to-the-repo>/node_modules/@angular/compiler/fesm2015/compiler.mjs to a dynamic import() which is available in all CommonJS modules.
But the advised change of the static @angular/compiler to a dynamic import is cumbersome due to various reasons:
- it unnecessarily changes the our synchronous code to asynchronous code
- it induces passing down the
compilerModule(result ofawait import(@angular/compiler)) as an argument down to all helper functions (example in angular repo) - it requires a hacky workaround ticking the Typescript compiler so to avoid compiling the dynamic
import()into therequire()call - for more see the workaround functionloadEsmModule()in angular repo . Btw. this function is not exported in public API, so we need to copy-paste it to our repo.
Describe the solution you'd like
Support executing ESM schematics .
Describe alternatives you've considered
Change the import of ESM to dynamic imports in our schematics code and deal with all its cumbersome consequences (described above).
- Vorherrschende Sprache
- TypeScript
- Sterne
- 27k
- Forks
- 11.8k
- Ø Merge
- 17 Std. 25 Min.
- Gemergte PRs (30 T.)
- 183
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus angular/angular-cli
-
area: @angular/build gemini-triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
angular/angular-cli#33055 · 1 Kommentar · 3 Reaktionen ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 zugewiesene Person ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 zugewiesene Person ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34128 · 1 zugewiesene Person ·
Alle Issues in angular/angular-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
fil-donadoni/tolaria#4409 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
corsairdev/corsair#1764 ·