From 7737c4076358fe7da7d9a19ec9a40bfcdf794e15 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 26 May 2026 12:43:31 +0100 Subject: [PATCH 1/4] feat: Expose Transformer `moduleName` --- lib/transformer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/transformer.js b/lib/transformer.js index 990686b..399d079 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -41,6 +41,11 @@ class Transformer { /** No-op — freeing resources is not needed for the JavaScript implementation. */ free () {} + /** The npm package name being instrumented. */ + get moduleName () { + return this.#moduleName + } + /** * Instruments `code` by injecting diagnostics_channel tracing around the * target functions defined by this transformer's configs. From 61ed7ce8916a60ffb915bdccbb807221b71da5df Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 26 May 2026 13:34:05 +0100 Subject: [PATCH 2/4] Types! --- index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.d.ts b/index.d.ts index eee2794..d0d0f26 100644 --- a/index.d.ts +++ b/index.d.ts @@ -104,6 +104,12 @@ export class InstrumentationMatcher { export class Transformer { private constructor(); free(): void; + + /** + * The name of the module to transform. + */ + get moduleName(): string; + /** * Transform JavaScript code and optionally sourcemap. * From 1c048fbb519814b7093a9ad376b5473fc3952e8a Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 26 May 2026 13:46:40 +0100 Subject: [PATCH 3/4] PR review Co-authored-by: James Sumners --- lib/transformer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 399d079..534e2f0 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -41,7 +41,11 @@ class Transformer { /** No-op — freeing resources is not needed for the JavaScript implementation. */ free () {} - /** The npm package name being instrumented. */ + /** + * The npm package name being instrumented. + * + * @returns {string} + */ get moduleName () { return this.#moduleName } From 5e18a322bbbca5a49fc5b17e60ac8146bae39e5d Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 26 May 2026 13:50:33 +0100 Subject: [PATCH 4/4] Add `filePath` too --- index.d.ts | 7 +++++++ lib/transformer.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/index.d.ts b/index.d.ts index d0d0f26..7d2ec98 100644 --- a/index.d.ts +++ b/index.d.ts @@ -110,6 +110,13 @@ export class Transformer { */ get moduleName(): string; + /** + * The relative file path within the npm package being instrumented. + * + * @returns {string} + */ + get filePath(): string; + /** * Transform JavaScript code and optionally sourcemap. * diff --git a/lib/transformer.js b/lib/transformer.js index 534e2f0..663e3cb 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -50,6 +50,15 @@ class Transformer { return this.#moduleName } + /** + * The relative file path within the npm package being instrumented. + * + * @returns {string} + */ + get filePath () { + return this.#filePath + } + /** * Instruments `code` by injecting diagnostics_channel tracing around the * target functions defined by this transformer's configs.