diff --git a/index.d.ts b/index.d.ts index eee2794..7d2ec98 100644 --- a/index.d.ts +++ b/index.d.ts @@ -104,6 +104,19 @@ export class InstrumentationMatcher { export class Transformer { private constructor(); free(): void; + + /** + * The name of the module to transform. + */ + 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 990686b..663e3cb 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -41,6 +41,24 @@ class Transformer { /** No-op — freeing resources is not needed for the JavaScript implementation. */ free () {} + /** + * The npm package name being instrumented. + * + * @returns {string} + */ + get moduleName () { + 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.