fix(test runner): esm loader in old Node versions

Arguments of the `register()` call have changed over time,
in particular the `parentURL` was not a part of options.

We do not need to pass it, because the first argument `specifier`
is already an absolute file url, so we do not need a base url.

Verified this fix works on Node versions 20.11, 20.6, 18.17 and 22.13.
This commit is contained in:
Dmitry Gozman 2025-01-15 09:42:56 +00:00
parent 275f334b58
commit 201b8fe9e1

View file

@ -30,7 +30,6 @@ export function registerESMLoader() {
const { port1, port2 } = new MessageChannel();
// register will wait until the loader is initialized.
require('node:module').register(url.pathToFileURL(require.resolve('../transform/esmLoader')), {
parentURL: url.pathToFileURL(__filename),
data: { port: port2 },
transferList: [port2],
});