b08fb216bf
### 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
12 lines
321 B
JavaScript
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')
|
|
}
|
|
}
|