microsoft / microsoft/TypeScript
[Compiler API] Reuse default compiler host when customizing module resolution
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando i punti di ingresso della Compiler API indicati nell’issue: ts.createCompilerHost, resolveModuleNames e ts.createProgram. Determina in che modo l’host del compilatore predefinito gestisce la risoluzione dei moduli e come si potrebbe sovrapporre a esso un resolver personalizzato; il lavoro è completato quando la personalizzazione richiesta funziona senza ricreare l’intera configurazione dell’host.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100