Browse Source

added import tracing in register.js for diagnostic runs

master
Rob Colbert 3 months ago
parent
commit
7c3f4977de
  1. 9
      docs/import-trace.md
  2. 10
      es-import-trace.js
  3. 1
      register.js

9
docs/import-trace.md

@ -0,0 +1,9 @@
# DTP Import Trace
As a useful tool for diagnosing circular dependencies, you can enable log tracing of imports at runtime by editing [register.js](../register.js) and un-commenting:
```js
// register("./es-import-trace.js", pathToFileURL("./"));
```
This will load the [es-import-trace.js](../es-import-trace.js) "loader" which prints the URL of the module being imported, then returns the result of the default loader.

10
es-import-trace.js

@ -0,0 +1,10 @@
// es-import-trace.js
// Copyright (C) 2025 DTP Technologies, LLC
// All Rights Reserved
"use strict";
export const load = async (url, context, defaultLoad) => {
console.log("import: " + url);
return await defaultLoad(url, context);
};

1
register.js

@ -17,4 +17,5 @@
import { register } from "node:module"; import { register } from "node:module";
import { pathToFileURL } from "node:url"; import { pathToFileURL } from "node:url";
// register("./es-import-trace.js", pathToFileURL("./"));
register("ts-node/esm", pathToFileURL("./")); register("ts-node/esm", pathToFileURL("./"));
Loading…
Cancel
Save