Tracking Issue: Syncify the ESM Loader
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
The code under lib/internal/modules/esm, a.k.a. the ESM loader, contains many functions that are async. We should refactor as many of these as possible, ideally all of them, to be synchronous. This should improve the performance of evaluating ESM code, bringing it roughly on par with the speed of running CommonJS code.
Longer term, once the ESM loader is synchronous and we land the synchronous module customization hooks, we could deprecate monkey-patching the CommonJS loader and merge together the CommonJS and ESM loaders, eliminating duplication: https://github.com/nodejs/node/issues/50356.
This issue will track our progress syncifying the various files and functions of the ESM loader until we can get as much of it to be as synchronous as possible.
The files to be updated, all underlib/internal/modules:
-
run_main.js:asyncRunEntryPointWithESMLoader -
esm/fetch_module.js:fetchWithRedirects -
esm/fetch_module.js:isLocalAddress -
esm/hooks.js:Hooksclass (the async methods here probably don’t need updating as they will be removed once we migrate to the synchronous customization hooks) -
esm/hooks.js:nextHookFactory -
esm/load.js:getSourcehttps://github.com/nodejs/node/pull/57419 -
esm/load.js:defaultLoadhttps://github.com/nodejs/node/pull/57419 -
esm/loader.js:ModuleLoader.eval -
esm/loader.js:ModuleLoader.getModuleJobForImport -
esm/loader.js:ModuleLoader.loadAndTranslate -
esm/loader.js:ModuleLoader.import -
esm/loader.js:ModuleLoader.load -
esm/module_job.js:ModuleJob._link -
esm/module_job.js:ModuleJob._instantiate -
esm/module_job.js:ModuleJob.run -
esm/module_job.js:ModuleJobSync.run -
esm/translators.js:wasmhandler, viatranslators.set('wasm', ... -
esm/utils.js:importModuleDynamicallyCallback -
esm/utils.js:initializeHooks(might not need updating as we will remove this once the synchronous customization hooks land -
esm/worker.js:customizedModuleWorker(might not need updating as we will remove this once the synchronous customization hooks land -
esm/worker.js:handleMessage(might not need updating as we will remove this once the synchronous customization hooks land
@nodejs/loaders @mcollina @JakobJingleheimer @joyeecheung
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 las entradas no marcadas en lib/internal/modules, especialmente con las funciones nombradas bajo esm/loader.js y esm/module_job.js, y lee la propuesta enlazada sobre hooks síncronos de personalización de módulos. Determina qué funciones async siguen dentro del alcance y cómo dependen de ellas sus llamadores. Se considera terminado convertir un conjunto adecuado de las funciones listadas para que operen de forma síncrona, preservando el comportamiento del cargador ESM.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- backend, devtools
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100