nodejs / nodejs/node

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

Offen
#54,051 16 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature request loaders
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das bestehende Verhalten von Node bei import.meta.resolve() und die in der Issue beschriebene node:module-API-Oberfläche zu prüfen. Definiere einen asynchronen integrierten Resolver, der einen Referrer-Pfad und Importbedingungen akzeptiert, während import.meta.resolve() für die standardmäßige plattformübergreifende Verwendung erhalten bleibt; abgeschlossen ist die Aufgabe, wenn die vorgeschlagene API und ihre Kompatibilitätsauswirkungen geklärt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

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