nodejs / nodejs/node

Add async alternative to import.meta.resolve() with additional options

Aperta
#54,051 16 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature request loaders
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

What is the problem this feature will solve?

Tools often need to resolve imports of files they are analyzing, which requires a resolve API that import.meta.resolve() isn't suited for.

  • The resolve() call needs a referrer path, which is only available with a flag and is non standard
  • The tool might want to specify import conditions, which are non-standard
  • The call should be async, so that file system access isn't blocking. This is especially important for online resolution in servers.

Node might be able to add non-standard options via a second argument, though I'm a bit dubious of this approach because it might preclude import.meta.resolve() from adding a standard second argument.

So currently, we have complex user land resolvers that try to emulate what Node does, like Rollup's.

What is the feature you are proposing to solve the problem?

I think node:module should provide a function to perform built-in resolution, given a referrer path and import conditions.

This API would be free from having to conform to the import.meta.resolve() standard. import.meta.resolve() would still exist for cross-platform needs of resolving from within the referrer only.

What alternatives have you considered?

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando il comportamento esistente di Node per import.meta.resolve() e la superficie dell’API node:module descritta nell’issue. Definisci un resolver integrato asincrono che accetti un percorso del referrer e condizioni di importazione, mantenendo import.meta.resolve() per l’uso multipiattaforma standard; il lavoro è completato quando l’API proposta e le sue implicazioni di compatibilità sono state definite.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
api, backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.