Extending nitro node-server preset/entry

I'm trying to add OpenTelemetry instrumentation to a Nuxt module by extending the Nitro node-server preset.

I know I can execute something like this:

node --require instrumentation.js .output/server/index.mjs


But I would like to integrate it with Nitro for several reasons:

Simplify the start command
Bundle dependencies to keep everything within the .output folder
Enable future enhancements with hooks and custom tracing
I tried to create a new entry for Nitro by importing this file:

https://stackblitz.com/edit/unjs-nitro-starter-wxdb1h?file=server%2Fentry.ts

However, it's not working. I'm not sure if I'm missing something.

---

I also tried cloning the node-server entry to make modifications:

https://stackblitz.com/edit/unjs-nitro-starter-hpgti5?file=server%2Fentry.ts

This works, but it's not ideal.
Solution
The problem was that Rollup was excluding the import because the imported code wasn't being used.

This could be a possible solution:

https://stackblitz.com/edit/unjs-nitro-starter-nig5kw?file=server%2Fentry.ts
Was this page helpful?