Publish `exports` and `imports` implementations as separate module(s)
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?
Projects implementing support for module resolution have to add support for the quite advanced exports and imports fields in package.json.
https://nodejs.org/api/packages.html#exports
https://nodejs.org/api/packages.html#imports
Examples of projects that have done this are Webpack, TypeScript, Jest (only exports, not imports), Yarn and probably more. AFAIK neither Rollup, Parcel or Metro (to name some bundlers) have support.
What is the feature you are proposing to solve the problem?
If the algorithm Node uses internally was published as a separate module, I hope (and believe) more projects would be able to add support more readily, and that ecosystem compatibility would improve as a result.
I think part of the reason is the complexity in supporting the algorithm needed, particularly with subpath exports, wildcards and conditionals. E.g. https://github.com/browserify/resolve/issues/222 is stuck, and https://github.com/facebook/jest/issues/9771 took a long time.
Prior art for externalizing parts of Node publishing cjs-module-lexer separately, which means Jest could implement the same feature as node itself when importing CJS from ESM (via vm API).
Note that this is not a request for the full require or ESM resolution algorithm. This is solely a request for "given this exports/imports, this specifier and these conditions, what path does it map to" - no FS access/lookups at all. API similar to https://github.com/lukeed/resolve.exports makes sense to me.
What alternatives have you considered?
Jest (and Yarn) currently use https://github.com/lukeed/resolve.exports to avoid having to implement all the resolution. It currently does not support imports (https://github.com/lukeed/resolve.exports/issues/14).
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
Comienza con la documentación enlazada de Node.js sobre package exports e imports y, después, compara el módulo resolve.exports citado y los ejemplos relacionados. Define el alcance de una implementación independiente que asigne un specifier y condiciones sin acceso al sistema de archivos; el trabajo estará terminado cuando el módulo propuesto cubra exports e imports y siga siendo independiente de la resolución completa de require o ESM.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, node.js
- Área
- developer-experience, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100