Previously, createRequire() does not preserve the URL it gets passed in the mock parent module created, which can be observable if it's used together with module.registerHooks(). This patch adds preservation of the URL if createRequire() is invoked with one. PR-URL: https://github.com/nodejs/node/pull/60974 Fixes: https://github.com/nodejs/node/issues/60973 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
3 lines
116 B
JavaScript
3 lines
116 B
JavaScript
import { createRequire } from 'node:module'
|
|
const require = createRequire(import.meta.url);
|
|
require('./empty.mjs');
|