diff --git a/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts b/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts index 25bc45d3ac4c..fadb4cdd4820 100644 --- a/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts +++ b/packages/nextjs/test/config/turbopack/constructTurbopackConfig.test.ts @@ -1337,6 +1337,19 @@ describe('orchestrion diagnostics-channel injection', () => { expect(JSON.parse(JSON.stringify(firestore!.module.filePath))).not.toEqual({}); }); + it('restricts the orchestrion rule to the node environment', () => { + const result = constructTurbopackConfig({ + userNextConfig: {}, + userSentryOptions: { _experimental: { useDiagnosticsChannelInjection: true } }, + nextJsVersion: '16.0.0', + }); + + // `condition: 'node'` is what keeps the transform off client code — orchestrion + // splices `node:diagnostics_channel` calls that throw `X is not a function` in the browser. + const rule = result.rules!['*.{js,mjs,cjs}'] as { condition?: unknown }; + expect(rule.condition).toBe('node'); + }); + it('does not add the orchestrion rule when injection is not opted in', () => { const result = constructTurbopackConfig({ userNextConfig: {},