Skip to content

module: Fix bug for undefined CJS dependency loading from loader hook file

It can be useful to load dependencies as part of the loader hook definition file. This fixes a bug where import x from 'x' would always return x as undefined if the import was made in a loader hooks definition module.

A parallel change to the CJS loading injection process which happens in https://github.com/nodejs/node/blob/master/lib/module.js#L521 meant that the CJS module wasn't being injected into the correct loader instance, which is corrected here with a test.

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

esmodules

Merge request reports

Loading