Skip to content

Commit

Permalink
fix(utils): Rename global.ts -> worldwide.ts (#5969)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AbhiPrasad authored Oct 17, 2022
1 parent d2aa8ac commit 0596b6f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/utils/src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GLOBAL_OBJ } from './global';
import { isString } from './is';
import { GLOBAL_OBJ } from './worldwide';

/**
* TODO: Move me to @sentry/browser when @sentry/utils no longer contains any browser code
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './browser';
export * from './dsn';
export * from './error';
export * from './global';
export * from './worldwide';
export * from './instrument';
export * from './is';
export * from './logger';
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WrappedFunction } from '@sentry/types';

import { getGlobalSingleton, GLOBAL_OBJ } from './global';
import { getGlobalSingleton, GLOBAL_OBJ } from './worldwide';

/** Prefix for logging strings */
const PREFIX = 'Sentry Logger ';
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/misc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Event, Exception, Mechanism, StackFrame } from '@sentry/types';

import { GLOBAL_OBJ } from './global';
import { addNonEnumerableProperty } from './object';
import { snipLine } from './string';
import { GLOBAL_OBJ } from './worldwide';

interface CryptoInternal {
getRandomValues(array: Uint8Array): Uint8Array;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/**
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
*
* Note: This file was originally called `global.ts`, but was changed to unblock users which might be doing
* string replaces with bundlers like Vite for `global` (would break imports that rely on importing from utils/src/global).
*
* Why worldwide?
*
* Why not?
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL_OBJ } from '../src/global';
import { GLOBAL_OBJ } from '../src/worldwide';

describe('GLOBAL_OBJ', () => {
test('should return the same object', () => {
Expand Down

0 comments on commit 0596b6f

Please sign in to comment.