Expose `importMetaResolve(url, baseURL)` from `node:module`, and stabilize it
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
What is the problem this feature will solve?
In Node.js based tools it's common to need to "resolve url X as if it were imported from module Y".
Node.js does not expose this as an API, even though it implements it. It only exposes "resolve url X as if it were imported from this current module", through import.meta.resolve.
https://github.com/wooorm/import-meta-resolve is, for example, a library that is basically code copy&pasted from this repository and published on npm. The annoying part is that, as Node.js resolution rules change, libraries need to change too, and you need to basically check which version of Node.js you are on to know which rules to apply.
What is the feature you are proposing to solve the problem?
Node.js does have a solution to this: the version of import.meta.resolve that takes two arguments, gated behind a flag (--experimental-import-meta-resolve). The reason it's behind a flag is because it would be different from the import.meta.resolve implementation of browsers, that takes only one argument.
It'd be great if Node.js could expose the two-args version as an export of node:module, something like
import { resolveModuleURL } from "node:module"`;
resolveModuleURL(url, parent);
with resolveModuleURL(url, import.meta.url) being equivalent to import.meta.resolve(url).
What alternatives have you considered?
This is related to https://github.com/nodejs/node/pull/55756, which implements a more complex/comprehensive API.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza leyendo la implementación existente de import.meta.resolve en Node.js y el comportamiento detrás de --experimental-import-meta-resolve. Compara la exportación propuesta de node:module con la API más completa del pull request #55756. Se considera terminado cuando el resolver de dos argumentos está expuesto como una API estable con un comportamiento equivalente al caso de uso solicitado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, nodejs
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100