Skip to content

module: add import map support

Rodrigo Muino Tomonari requested to merge github/fork/wesleytodd/import-maps into main

This PR adds experimental support for import maps behind the --experimental-import-map=<path> flag. This is a draft as I believe there are still quite a few things to discuss and add:

  • Docs
  • More test coverage
    • Test on the module tree from some of the bundled deps
    • Use web platform tests
  • Benchmarks (specifically to see how much adding an import map hits startup)
  • Bare specifier remapping: Should we have the ability to remap one bare specifier to another? foo to bar and then have default resolution on bar, for example? This might be against spec, but also seems really helpful.
  • Does it make sense to resolve the import map via esm? Or should we do a more basic file read?
  • In the future should we plan to automatically load an import map based on a well known location? (ex node_modules/importmap.json)
  • What types of values do we want for --experimental-import-map? Right now any module specifier is allowed, but do we want that? This was done to enable http import of import maps, but that is not explicitly a goal, just a starting point for discussion.
  • CommonJS support? What do we want to do about that?
    • Decided we should hold off on that and deal with it in a follow up PR if we think we should do it.
  • https://github.com/nodejs/node/pull/50590#discussion_r1384627793 Do we need to pass the import map reference to loaders? If not, can we remove it from context first to avoid the non-transferable problem?

Helpful links:

Merge request reports

Loading