Skip to content

Commit 0596b6f

Browse files
authored
fix(utils): Rename global.ts -> worldwide.ts (#5969)
Renames `global.ts` to `worldwide.ts` so we don't have issues with bundlers like as is described in https://docs.sentry.io/platforms/javascript/troubleshooting/#build-errors-with-vite. Luckily the rest of our references to global is removed since we did changes with the WinterCG work. It's not quite our responsibility to handle this, since Vite themselves recommends not use variables like global with the define setting, but we can unblock folks from not having build errors with our SDK, so I'm fine with this change.
1 parent d2aa8ac commit 0596b6f

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

packages/utils/src/browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { GLOBAL_OBJ } from './global';
21
import { isString } from './is';
2+
import { GLOBAL_OBJ } from './worldwide';
33

44
/**
55
* TODO: Move me to @sentry/browser when @sentry/utils no longer contains any browser code

packages/utils/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export * from './browser';
22
export * from './dsn';
33
export * from './error';
4-
export * from './global';
4+
export * from './worldwide';
55
export * from './instrument';
66
export * from './is';
77
export * from './logger';

packages/utils/src/logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { WrappedFunction } from '@sentry/types';
22

3-
import { getGlobalSingleton, GLOBAL_OBJ } from './global';
3+
import { getGlobalSingleton, GLOBAL_OBJ } from './worldwide';
44

55
/** Prefix for logging strings */
66
const PREFIX = 'Sentry Logger ';

packages/utils/src/misc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { Event, Exception, Mechanism, StackFrame } from '@sentry/types';
33

4-
import { GLOBAL_OBJ } from './global';
54
import { addNonEnumerableProperty } from './object';
65
import { snipLine } from './string';
6+
import { GLOBAL_OBJ } from './worldwide';
77

88
interface CryptoInternal {
99
getRandomValues(array: Uint8Array): Uint8Array;

packages/utils/src/global.ts packages/utils/src/worldwide.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
/**
22
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
33
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
4+
*
5+
* Note: This file was originally called `global.ts`, but was changed to unblock users which might be doing
6+
* string replaces with bundlers like Vite for `global` (would break imports that rely on importing from utils/src/global).
7+
*
8+
* Why worldwide?
9+
*
10+
* Why not?
411
*/
512

613
/* eslint-disable @typescript-eslint/no-explicit-any */

packages/utils/test/global.test.ts packages/utils/test/worldwide.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GLOBAL_OBJ } from '../src/global';
1+
import { GLOBAL_OBJ } from '../src/worldwide';
22

33
describe('GLOBAL_OBJ', () => {
44
test('should return the same object', () => {

0 commit comments

Comments
 (0)