rsnext/test/e2e/instrumentation-hook/general/instrumentation.js
Jiachi Liu b08fb216bf
Fix instrument bundling as client components (#60984)
### What

When users're using nextjs server API that break the build, and error
with incorrect client components usage.
Instrument should be treated as server components or server-only build
target, instead of being treated as client components.

### How

We added a new layer `instrument` for instrument hook bundling, and
apply it with the rsc server webpack loaders

Fixes #57563
Closes NEXT-2181
Closes NEXT-1994
2024-01-24 20:02:53 +01:00

12 lines
321 B
JavaScript

// Should not error
import 'server-only'
export function register() {
if (process.env.NEXT_RUNTIME === 'edge') {
console.log('instrumentation hook on the edge')
} else if (process.env.NEXT_RUNTIME === 'nodejs') {
console.log('instrumentation hook on nodejs')
} else {
require('this should fail')
}
}