Loaders Team
Purpose
The Node.js Loaders Team maintains and actively develops the ECMAScript Modules Loaders implementation in Node.js core.
History
This team is spun off from the Modules team. We aim to implement the use cases that went unfulfilled by the initial ES modules implementation that can be achieved via loaders.
Project
Status
Milestone 1: Parity with CommonJS
Before extending into new frontiers, we need to improve the loaders API enough that users can do just about everything they could do in CommonJS with ESM + loaders. (Outside of loaders scope, but related to the goal of parity between CommonJS and ESM, is finishing and stabilizing --experimental-vm-modules.)
-
Finish nodejs/node#37468 / nodejs/node#35524, simplifying the hooks to
resolve,loadandglobalPreloadCode. -
Refactor the internal Node ESMLoader hooks into
resolveandload. Node’s internal loader already has no-ops fortransformSourceandgetGlobalPreloadCode, so all this really entails is wrapping the internalgetFormatandgetSourcewith one functionload(getFormatis used internally outside ESMLoader, so they cannot merely be merged). nodejs/node#37468 -
Refactor Node’s internal ESM loader to move its exception on unknown file types from within
resolve(on detection of unknown extensions) to withinload(if the resolved extension has no defined translator). nodejs/node#37468 -
Implement chaining as described in the design, where the
default<hookName>becomesnextand references the next registered hook in the chain. nodejs/node#42623 -
Have loaders apply to subsequent loaders. https://github.com/nodejs/loaders/blob/main/doc/design/proposal-ambient-loaders.md, nodejs/node#43772
-
Move loaders off thread. nodejs/node#43658
We hope that moving loaders off thread will allow us to preserve an async
resolvehook while supporting the syncimport.meta.resolveAPI. If that turns out to be unachievable, however, then:-
Convert
resolvefrom async to sync nodejs/node#43363
-
Milestone 2: Usability improvements
-
Provide a way to register loaders without a command-line flag, for example via a
"loaders"field inpackage.json(#98 or nodejs/node#43973). -
Support loading source when the return value of
loadhasformat: 'commonjs'. See nodejs/node#34753 (comment) and https://github.com/nodejs/loaders-test/blob/835506a638c6002c1b2d42ab7137db3e7eda53fa/coffeescript-loader/loader.js#L45-L50. -
First-class support for import maps that doesn’t require a custom loader.
-
Add helper/utility functions to reduce boilerplate in user-defined hooks.
-
Start with helpers for retrieving the closest parent
package.jsonassociated with a specifier string; and for retrieving thepackage.jsonfor a particular package by name (which is not necessarily the same result). -
Potentially include all the functions that make up the ESM resolution algorithm as defined in the spec. Create helper functions for each of the functions defined in that psuedocode:
esmResolve,packageImportsResolve,packageResolve,esmFileFormat,packageSelfResolve,readPackageJson,packageExportsResolve,lookupPackageScope,packageTargetResolve,packageImportsExportsResolve,patternKeyCompare. (Not necessarily all with these exact names, but corresponding to these functions from the spec.) -
Follow up with similar helper functions that make up what happens within Node’s internal
load. (Definitions to come.)
-
-
Helper/utility functions to allow access to the CommonJS named exports discovery algorithm (
cjs-module-lexer). -
Hooks for customizing the REPL, including transpilation and tab completion. Support users pasting TypeScript (or CoffeeScript or whatever) into the REPL and having just as good an experience as with plain JavaScript.
- Support top-level
awaitin the REPL API, if possible.
- Support top-level
-
Hooks for customizing the stack trace (in other words, a hook version of
Error.prepareStackTrace). This would allow transpiled languages to improve the output. -
Hooks for customizing filesystem calls, for allowing things like virtual filesystems or archives treated as volumes.
-
Inherit configuration blob to worker threads and child processes.
-
Provide a way for application code to communicate with loaders code.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
