@ 261027.7

261026.1 · b6bf196ae1e954da44a0f35532cd30b2e0969202

feat: use module.registerHooks for amaro/strip and amaro/transform

Use synchronous module.registerHooks() when available, so the loaders also apply to require() of TypeScript and avoid the loader thread. Fall back to module.register() on Node.js versions without it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

reading declarations

Changes to test/fixtures/. All files

test/fixtures/bootstrap-strip.mjs

new file mode 100644@@ -0,0 +1,3 @@+import "../../dist/register-strip.mjs";++await import("./esm/esm.ts");

test/fixtures/other-hook.mjs

new file mode 100644@@ -0,0 +1,11 @@+import { registerHooks } from "node:module";++registerHooks({+	load(url, context, nextLoad) {+		const result = nextLoad(url, context);+		if (url.endsWith("/hello.js")) {+			console.log("other hook saw hello.js");+		}+		return result;+	},+});

test/fixtures/require-ts.js

new file mode 100644@@ -0,0 +1,3 @@+const { greet } = require("./commonjs.ts");++greet("required");