microsoft / microsoft/TypeScript
[Compiler API] Reuse default compiler host when customizing module resolution
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Suggestion
A very similar question already has been asked here four years ago by @vivin:
Implementing custom module-resolution logic using Compiler API - StackOverflow
I need the same right now, and it is a pity that apparently, you still need to rewrite the entire compiler host configuration just in order to customize one aspect. What I would prefer to do would be something like:
const host = ts.createCompilerHost(options);
host.resolveModuleNames = myResolver;
const program = ts.createProgram(sourceFiles, options, host);
But this still seems to be impossible right now?
🔍 Search Terms
customize module resolution, configure compiler host, resolveModuleNames
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
💻 Use Cases
- customize compiler more easily without reinventing the wheel
- if you need to reinvent the wheel, the code will get harder to maintain against future changes to the default compiler host
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, die im Issue genannten Einstiegspunkte der Compiler API nachzuverfolgen: ts.createCompilerHost, resolveModuleNames und ts.createProgram. Ermitteln Sie, wie der standardmäßige Compiler-Host die Modulauflösung handhabt und wie ein benutzerdefinierter Resolver darauf aufgesetzt werden könnte; als erledigt gilt die Aufgabe, wenn die angeforderte Anpassung funktioniert, ohne die gesamte Host-Konfiguration neu zu erstellen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100