From 8c051dbd1a075ad3c228f78b29b13f0e455972a7 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 27 Mar 2023 21:54:22 +0200 Subject: fix(ext/node): add missing _preloadModules hook (#18447) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This internal node hook is used by libraries such as `ts-node` when used as a require hook `node -r ts-node/register`. That combination is often used with test frameworks like `mocha` or `jasmine`. We had a reference to `Module._preloadModules` in our code, but the implementation was missing. While fixing this I also noticed that the `fakeParent` module that we create internally always threw because of the `pathDirname` check on the module id in the constructor of `Mdoule`. So this code path was probably broken for a while. ```txt ✖ ERROR: Error: Empty filepath. at pathDirname (ext:deno_node/01_require.js:245:11) at new Module (ext:deno_node/01_require.js:446:15) at Function.Module._resolveFilename (ext:deno_node/01_require.js:754:28) at Function.resolve (ext:deno_node/01_require.js:1015:19) ``` --- cli/tests/unit_node/testdata/add_global_property.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 cli/tests/unit_node/testdata/add_global_property.js (limited to 'cli/tests/unit_node/testdata') diff --git a/cli/tests/unit_node/testdata/add_global_property.js b/cli/tests/unit_node/testdata/add_global_property.js new file mode 100644 index 000000000..814d17d0d --- /dev/null +++ b/cli/tests/unit_node/testdata/add_global_property.js @@ -0,0 +1 @@ +globalThis.foo = "Hello"; -- cgit v1.2.3