`vm.Script`'s `importModuleDynamically` should get a reference to the `context` used to run 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
Is your feature request related to a problem? Please describe.
When implementing importModuleDynamically you don't have access to what context the script is executed with, meaning you can't pass the correct context when constructing a Module. We're also missing the filename of the Script, so resolving to the specifier passed is also not straightforward since it can be changed by .runIn*Context() calls from what I passed in to the constructor.
Describe the solution you'd like
I think adding context and filename as accessible properties on the Script instance passed to the function should work fine - it would mirror what you get when using SourceTextModule where I have access to context and identifier. It could also be passed as a third argument to the function passed in importModuleDynamically if you don't wanna change the Script instance itself.
Describe alternatives you've considered
The implementation I've gone with in the absence of such an API is to get the context again and re-use the filename passed in the constructor. This works since I also have control over how the script is executed, but that might not always be the case. Mirroring the capability of SourceTextModule would be nice, though - where in the context of the callback in importModuleDynamically there's enough information to know how to resolve the specifier being requested and in what context it should run.
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 comparando el callback importModuleDynamically de vm.Script con las API de contexto e identificador de SourceTextModule descritas en el issue. Sigue cómo se ejecuta vm.Script mediante runIn*Context() y determina dónde podrían exponerse context y filename; se considera terminado cuando el callback pueda identificar ambos de forma fiable para resolver y ejecutar el módulo solicitado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, node.js
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100