/loaders

ECMAScript Modules Loaders

MIT LicenseMIT

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

Complete

  1. Finish nodejs/node#37468 / nodejs/node#35524, simplifying the hooks to resolve, load and globalPreloadCode.

  2. Refactor the internal Node ESMLoader hooks into resolve and load. Node’s internal loader already has no-ops for transformSource and getGlobalPreloadCode, so all this really entails is wrapping the internal getFormat and getSource with one function load (getFormat is used internally outside ESMLoader, so they cannot merely be merged).

  3. Refactor Node’s internal ESM loader to move its exception on unknown file types from within resolve (on detection of unknown extensions) to within load (if the resolved extension has no defined translator).

In Progress

Upcoming

  1. Implement chaining as described in the design, where the default<hookName> becomes next and references the next registered hook in the chain.

  2. Get a load return value of format: 'commonjs' to work, or at least error informatively. See nodejs/node#34753 (comment).

After this, we should get user feedback regarding the developer experience; for example, is too much boilerplate required? Should we have a separate transform hook? And so on. We should also investigate and potentially implement the technical improvements on our to-do list, such as the loaders-application communication channel and moving loaders into a thread.