Skip to content

loader, docs, test: named exports from commonjs modules

I know a lot of discussion went into the original decision on how mjs would handle cjs modules but after using the system for a while, and talking with a lot of other people in the community, it just seems like the expected behavior and the wanted behavior is to export named based on the keys. This PR implements that in what is hopefully a performant enough solution, although that shouldn't be too much of a problem since this code only runs during initial module loading.

This implementation remains safe with regard to named exports that are also reserved keywords such as class or delete.

EDIT: many changes to original impl, definitely read comments and file diff

Refs: https://github.com/nodejs/node-eps/issues/57 Refs: https://github.com/nodejs/abi-stable-node/issues/256#issuecomment-325138872

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

loader

Merge request reports

Loading