vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.94k stars 26.68k forks source link

Import .ts files in Instrumentation #69519

Open CyberT33N opened 2 weeks ago

CyberT33N commented 2 weeks ago

Verify canary release

I can use in my tsconfig.json:

To use:

const path = 'test.ts'
await import(path)

However, when I will run the same code inside of the Instrumentation I get:

Is the Instrumenation not working with the tsconfig.json?

Expected Behavior

Instrumenation works with dynamic import of .ts files

Netail commented 2 weeks ago

Try to import without the .ts extension behind it

// instrumentation.ts

export function register() {
  await import('./instrumentation-node')
}
// instrumentation-node.ts

console.log('test');