Repository navigation
Tracking Issue: Syncify the ESM Loader #55782
Description
Activity
- addedesmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.
on Nov 8, 2024 Maybe moving it in the loaders repo would be more appropriate since its a effort that is gonna require different iterations?
This task is better handled by a large group of people, and this repo is more visible. Once the first few steps are done, it can easily be tagged as "good first issue"
- addedloadersIssues and PRs related to ES module loaders.Issues and PRs related to ES module loaders.
on Nov 8, 2024 I would like to mention my issue here.
Please check if it's worth fixing.Hi @mcollina and @marco-ippolito,
Is anyone currently working on any of these issues? I’d love to help resolve a few. Could you recommend a good starting point? I’d like to begin with something low-risk—what would be the best issue to pick?Also what is the best method to test if my code is improving performance?
This may be necessary to prevent a race condition like prettier/prettier#17139 (comment)
@cu8code Sorry to not notice your comment earlier. If you'd like to help with this effort, you can pick any of the functions listed in the top issue and try to refactor them to be synchronous. The lowest hanging fruit are the ones that are async functions but never actually
awaitanything (perhaps because they used to contain async logic but no longer do, for example). Besides prioritizing the easiest parts, I would also prioritize the hottest code paths: the functions involved in initial load of the most common use case likenode app.jswhereapp.jsis an ES module. I would make the PRs as small as possible so that any resulting issues can be isolated as narrowly as possible, along the lines of #57390.Reacted by ExE Boss and 0hm☘️-
esm/fetch_module.js: fetchWithRedirects
-
esm/fetch_module.js: isLocalAddress
Can be removed since we removed http imports
Reacted by ExE Boss-
JakobJingleheimer commented
on Apr 2, 2025 on Apr 2, 2025 · Hidden as resolvedshow commentMore actions#57749 adds everysync as decided in the collab summit.
- added a commit that references this issue
on Aug 14, 2025 - added a commit that references this issue
on Aug 21, 2025 - added a commit that references this issue
on Sep 20, 2025 github-actions commented
on Apr 26, 2026 on Apr 26, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Apr 26, 2026 - removedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Apr 26, 2026 WIP: #62530
github-actions commented
on Jul 26, 2026 on Jul 26, 2026 – with GitHub ActionsContributorMore actionsThis issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.- addedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jul 26, 2026 - addednever-staleIssues and PRs exempt from automated stale handling.Issues and PRs exempt from automated stale handling.and removedstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
on Jul 27, 2026
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: #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 under
lib/internal/modules:run_main.js:asyncRunEntryPointWithESMLoaderesm/fetch_module.js:fetchWithRedirectsesm/fetch_module.js:isLocalAddressesm/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:nextHookFactoryesm/load.js:getSourceesm: syncify default path ofModuleLoader.load#57419esm/load.js:defaultLoadesm: syncify default path ofModuleLoader.load#57419esm/loader.js:ModuleLoader.evalesm/loader.js:ModuleLoader.getModuleJobForImportesm/loader.js:ModuleLoader.loadAndTranslateesm/loader.js:ModuleLoader.importesm/loader.js:ModuleLoader.loadesm/module_job.js:ModuleJob._linkesm/module_job.js:ModuleJob._instantiateesm/module_job.js:ModuleJob.runesm/module_job.js:ModuleJobSync.runesm/translators.js:wasmhandler, viatranslators.set('wasm', ...esm/utils.js:importModuleDynamicallyCallbackesm/utils.js:initializeHooks(might not need updating as we will remove this once the synchronous customization hooks landesm/worker.js:customizedModuleWorker(might not need updating as we will remove this once the synchronous customization hooks landesm/worker.js:handleMessage(might not need updating as we will remove this once the synchronous customization hooks land@nodejs/loaders @mcollina @JakobJingleheimer @joyeecheung