diff options
author | guybedford <guybedford@gmail.com> | 2017-10-22 14:42:50 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-10-28 13:22:55 +0200 |
commit | d853758a227066ce4cf58d3d7577b9c513ff8c7c (patch) | |
tree | 98a1426530e23e2469cc232765b181276e147032 /test/fixtures | |
parent | edd78f86acc6f7ad90cac18b57b81cbb647daeea (diff) | |
download | android-node-v8-d853758a227066ce4cf58d3d7577b9c513ff8c7c.tar.gz android-node-v8-d853758a227066ce4cf58d3d7577b9c513ff8c7c.tar.bz2 android-node-v8-d853758a227066ce4cf58d3d7577b9c513ff8c7c.zip |
module: fix hook module CJS dependency loading
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 meant that the
CJS module wasn't being injected into the correct loader instance,
which is corrected here with a test.
PR-URL: https://github.com/nodejs/node/pull/16381
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/es-module-loaders/loader-dep.js | 1 | ||||
-rw-r--r-- | test/fixtures/es-module-loaders/loader-with-dep.mjs | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/test/fixtures/es-module-loaders/loader-dep.js b/test/fixtures/es-module-loaders/loader-dep.js new file mode 100644 index 0000000000..cf821afec1 --- /dev/null +++ b/test/fixtures/es-module-loaders/loader-dep.js @@ -0,0 +1 @@ +exports.format = 'esm'; diff --git a/test/fixtures/es-module-loaders/loader-with-dep.mjs b/test/fixtures/es-module-loaders/loader-with-dep.mjs new file mode 100644 index 0000000000..944e6e438c --- /dev/null +++ b/test/fixtures/es-module-loaders/loader-with-dep.mjs @@ -0,0 +1,7 @@ +import dep from './loader-dep.js'; +export function resolve (specifier, base, defaultResolve) { + return { + url: defaultResolve(specifier, base).url, + format: dep.format + }; +} |