Tracking Issue: Syncify the ESM Loader
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den nicht abgehakten Einträgen in lib/internal/modules, insbesondere mit den genannten Funktionen unter esm/loader.js und esm/module_job.js, und lies den verlinkten Vorschlag zu synchronen Hooks zur Anpassung von Modulen. Bestimme, welche asynchronen Funktionen noch im Umfang liegen und wie ihre Aufrufer von ihnen abhängen. Als abgeschlossen gilt die Umwandlung einer geeigneten Gruppe der aufgeführten Funktionen in einen synchronen Betrieb unter Beibehaltung des ESM-Loader-Verhaltens.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- backend, devtools
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100