Skip to content

Commit 758a60d

Browse files
committed
Fix nextjs router import
1 parent 1946283 commit 758a60d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/nextjs/src/client/routing/pagesRouterRoutingInstrumentation.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import {
1414
stripUrlQueryAndFragment,
1515
} from '@sentry/utils';
1616
import type { NEXT_DATA as NextData } from 'next/dist/next-server/lib/utils';
17-
import { default as Router } from 'next/router';
17+
import RouterImport from 'next/router';
18+
19+
// next/router v10 is CJS
20+
//
21+
// For ESM/CJS interoperability 'reasons', depending on how this file is loaded, Router might be on the default export
22+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
23+
const Router: typeof RouterImport = RouterImport.events ? RouterImport : (RouterImport as any).default;
1824

1925
import { DEBUG_BUILD } from '../../common/debug-build';
2026

packages/nextjs/test/performance/pagesRouterInstrumentation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { WINDOW } from '@sentry/react';
22
import { JSDOM } from 'jsdom';
33
import type { NEXT_DATA as NextData } from 'next/dist/next-server/lib/utils';
4-
import { default as Router } from 'next/router';
4+
import Router from 'next/router';
55

66
import { pagesRouterInstrumentation } from '../../src/client/routing/pagesRouterRoutingInstrumentation';
77

0 commit comments

Comments
 (0)