Skip to content

feat: Add optional diagnostics hook - #29

Merged
timfish merged 6 commits into
mainfrom
feat/getTransformedModules
May 27, 2026
Merged

feat: Add optional diagnostics hook#29
timfish merged 6 commits into
mainfrom
feat/getTransformedModules

Conversation

@timfish

@timfish timfish commented May 26, 2026

Copy link
Copy Markdown
Member

This is dependent on this PR:

A diagnostics hook can be set which is called every time a module is transformed
or transformation fails. This hook will only work with the synchronous
registerHooks because the older register hook runs in a different thread.

import { setDiagnosticsHook } from '@apm-js-collab/tracing-hooks/hook-sync.mjs'

setDiagnosticsHook(({ url, moduleName, error }) => {
  if(error) {
    // injection failed
  } else {
    // injection succeeded
  }
})

@jsumners-nr jsumners-nr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This usage definitely makes me wonder if the resolved install directory should be included with the specifier.

@timfish

timfish commented May 26, 2026

Copy link
Copy Markdown
Member Author

I just changed this to a hook. The first argument is the moduleName and the second argument is Error if the injection failed.

Comment thread hook.mjs Outdated
@timfish

timfish commented May 26, 2026

Copy link
Copy Markdown
Member Author

The hook now takes an object and I've included url.

Comment thread hook.mjs
@timfish timfish changed the title feat: Add getTransformedModules for diagnostics feat: Add optional diagnostics hook May 26, 2026

@jsumners-nr jsumners-nr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabulous!

@timfish

timfish commented May 26, 2026

Copy link
Copy Markdown
Member Author

I should probably add a test for this!

@jsumners-nr

Copy link
Copy Markdown
Contributor

I should probably add a test for this!

Maybe. Could be useful. Who's to say? 😂

@timfish

timfish commented May 27, 2026

Copy link
Copy Markdown
Member Author

The new test passes once I updated to the the latest Orchestrion!

@timfish
timfish merged commit d33052b into main May 27, 2026
6 checks passed
@timfish
timfish deleted the feat/getTransformedModules branch May 27, 2026 17:32
@timfish timfish mentioned this pull request May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants