Skip to content

Commit b46a1bb

Browse files
authored
ref(feedback): Do not import window from browser pkg to avoid circular import (#9604)
We will be exporting the Feedback package from the `@sentry/browser` package, so to avoid circular imports when we do, we should remove imports from `@sentry/browser` (this is what we did in Replay)
1 parent f24ea88 commit b46a1bb

File tree

8 files changed

+13
-10
lines changed

8 files changed

+13
-10
lines changed

packages/feedback/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"@sentry/browser": "7.81.0",
2726
"@sentry/core": "7.81.0",
2827
"@sentry/types": "7.81.0",
2928
"@sentry/utils": "7.81.0"

packages/feedback/src/constants.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import { GLOBAL_OBJ } from '@sentry/utils';
2+
3+
// exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
4+
// prevents the browser package from being bundled in the CDN bundle, and avoids a
5+
// circular dependency between the browser and feedback packages
6+
export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
7+
18
const LIGHT_BACKGROUND = '#ffffff';
29
const INHERIT = 'inherit';
310
const SUBMIT_COLOR = 'rgba(108, 95, 199, 1)';

packages/feedback/src/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { WINDOW } from '@sentry/browser';
21
import type { Integration } from '@sentry/types';
32
import { isBrowser, logger } from '@sentry/utils';
43

@@ -15,6 +14,7 @@ import {
1514
NAME_PLACEHOLDER,
1615
SUBMIT_BUTTON_LABEL,
1716
SUCCESS_MESSAGE_TEXT,
17+
WINDOW,
1818
} from './constants';
1919
import type { FeedbackInternalOptions, FeedbackWidget, OptionalFeedbackConfiguration } from './types';
2020
import { mergeOptions } from './util/mergeOptions';

packages/feedback/src/widget/Icon.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../constants';
32
import { setAttributesNS } from '../util/setAttributesNS';
43

54
const SIZE = 20;

packages/feedback/src/widget/Logo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../constants';
32
import type { FeedbackInternalOptions } from '../types';
43
import { setAttributesNS } from '../util/setAttributesNS';
54

packages/feedback/src/widget/SuccessIcon.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
2-
1+
import { WINDOW } from '../constants';
32
import { setAttributesNS } from '../util/setAttributesNS';
43

54
const WIDTH = 16;

packages/feedback/src/widget/createShadowHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { WINDOW } from '@sentry/browser';
21
import { logger } from '@sentry/utils';
32

3+
import { WINDOW } from '../constants';
44
import type { FeedbackInternalOptions } from '../types';
55
import { createDialogStyles } from './Dialog.css';
66
import { createMainStyles } from './Main.css';

packages/feedback/src/widget/util/createElement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WINDOW } from '@sentry/browser';
1+
import { WINDOW } from '../../constants';
22

33
/**
44
* Helper function to create an element. Could be used as a JSX factory

0 commit comments

Comments
 (0)