Skip to content

Commit 2ce4745

Browse files
authored
fix: Make utils package also esm (#1999)
Convert @sentry/utils package to expose esm builds
1 parent 913eafc commit 2ce4745

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+162
-404
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 5.0.6
4+
5+
- [utils]: Change how we use `utils` and expose `esm` build
6+
- [utils]: Remove `store` and `fs` classes -> moved to @sentry/electron where this is used
7+
38
## 5.0.5
49

510
- [esm]: `module` in `package.json` now provides a `es5` build instead of `es2015`

packages/browser/rollup.config.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,30 @@ const terserInstance = terser({
2121
},
2222
});
2323

24+
const paths = {
25+
'@sentry/utils': ['../utils/src'],
26+
'@sentry/core': ['../core/src'],
27+
'@sentry/hub': ['../hub/src'],
28+
'@sentry/types': ['../types/src'],
29+
'@sentry/minimal': ['../minimal/src'],
30+
};
31+
2432
const plugins = [
2533
typescript({
2634
tsconfig: 'tsconfig.build.json',
2735
tsconfigOverride: {
2836
compilerOptions: {
2937
declaration: false,
3038
module: 'ES2015',
31-
paths: {
32-
'@sentry/utils/*': ['../utils/src/*'],
33-
'@sentry/core': ['../core/src'],
34-
'@sentry/hub': ['../hub/src'],
35-
'@sentry/types': ['../types/src'],
36-
'@sentry/minimal': ['../minimal/src'],
37-
},
39+
paths,
3840
},
3941
},
4042
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
4143
}),
4244
resolve({
43-
browser: true,
44-
module: false,
45-
modulesOnly: true,
45+
module: true,
46+
browser: false,
47+
modulesOnly: false,
4648
}),
4749
commonjs(),
4850
];
@@ -97,13 +99,7 @@ export default [
9799
compilerOptions: {
98100
declaration: false,
99101
module: 'ES2015',
100-
paths: {
101-
'@sentry/utils/*': ['../utils/src/*'],
102-
'@sentry/core': ['../core/src'],
103-
'@sentry/hub': ['../hub/src'],
104-
'@sentry/types': ['../types/src'],
105-
'@sentry/minimal': ['../minimal/src'],
106-
},
102+
paths,
107103
target: 'es6',
108104
},
109105
},
@@ -125,13 +121,7 @@ export default [
125121
compilerOptions: {
126122
declaration: false,
127123
module: 'ES2015',
128-
paths: {
129-
'@sentry/utils/*': ['../utils/src/*'],
130-
'@sentry/core': ['../core/src'],
131-
'@sentry/hub': ['../hub/src'],
132-
'@sentry/types': ['../types/src'],
133-
'@sentry/minimal': ['../minimal/src'],
134-
},
124+
paths,
135125
target: 'es6',
136126
},
137127
},

packages/browser/src/backend.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { BaseBackend } from '@sentry/core';
22
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
3-
import { isDOMError, isDOMException, isError, isErrorEvent, isPlainObject } from '@sentry/utils/is';
4-
import { addExceptionTypeValue } from '@sentry/utils/misc';
5-
import { supportsFetch } from '@sentry/utils/supports';
6-
import { SyncPromise } from '@sentry/utils/syncpromise';
3+
import {
4+
addExceptionTypeValue,
5+
isDOMError,
6+
isDOMException,
7+
isError,
8+
isErrorEvent,
9+
isPlainObject,
10+
supportsFetch,
11+
SyncPromise,
12+
} from '@sentry/utils';
713

814
import { eventFromPlainObject, eventFromStacktrace, prepareFramesForEvent } from './parsers';
915
import { computeStackTrace } from './tracekit';

packages/browser/src/client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { API, BaseClient, Scope } from '@sentry/core';
22
import { DsnLike, Event, EventHint } from '@sentry/types';
3-
import { logger } from '@sentry/utils/logger';
4-
import { getGlobalObject } from '@sentry/utils/misc';
5-
import { SyncPromise } from '@sentry/utils/syncpromise';
3+
import { getGlobalObject, logger, SyncPromise } from '@sentry/utils';
64

75
import { BrowserBackend, BrowserOptions } from './backend';
86
import { SDK_NAME, SDK_VERSION } from './version';

packages/browser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDi
3333
export { SDK_NAME, SDK_VERSION } from './version';
3434

3535
import { Integrations as CoreIntegrations } from '@sentry/core';
36-
import { getGlobalObject } from '@sentry/utils/misc';
36+
import { getGlobalObject } from '@sentry/utils';
3737

3838
import * as BrowserIntegrations from './integrations';
3939
import * as Transports from './transports';

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { API, getCurrentHub } from '@sentry/core';
22
import { Breadcrumb, BreadcrumbHint, Integration, Severity } from '@sentry/types';
3-
import { isString } from '@sentry/utils/is';
4-
import { logger } from '@sentry/utils/logger';
5-
import { getEventDescription, getGlobalObject, parseUrl } from '@sentry/utils/misc';
6-
import { fill, normalize } from '@sentry/utils/object';
7-
import { safeJoin } from '@sentry/utils/string';
8-
import { supportsHistory, supportsNativeFetch } from '@sentry/utils/supports';
3+
import {
4+
fill,
5+
getEventDescription,
6+
getGlobalObject,
7+
isString,
8+
logger,
9+
normalize,
10+
parseUrl,
11+
safeJoin,
12+
supportsHistory,
13+
supportsNativeFetch,
14+
} from '@sentry/utils';
915

1016
import { BrowserClient } from '../client';
1117

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { getCurrentHub } from '@sentry/core';
22
import { Event, Integration } from '@sentry/types';
3-
import { logger } from '@sentry/utils/logger';
4-
import { addExceptionTypeValue } from '@sentry/utils/misc';
5-
import { normalize } from '@sentry/utils/object';
6-
import { truncate } from '@sentry/utils/string';
3+
import { addExceptionTypeValue, logger, normalize, truncate } from '@sentry/utils';
74

85
import { eventFromStacktrace } from '../parsers';
96
import {

packages/browser/src/integrations/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { captureException, getCurrentHub, withScope } from '@sentry/core';
22
import { Event as SentryEvent, Mechanism, WrappedFunction } from '@sentry/types';
3-
import { addExceptionTypeValue, htmlTreeAsString } from '@sentry/utils/misc';
4-
import { normalize } from '@sentry/utils/object';
3+
import { addExceptionTypeValue, htmlTreeAsString, normalize } from '@sentry/utils';
54

65
const debounceDuration: number = 1000;
76
let keypressTimeout: number | undefined;
@@ -38,6 +37,7 @@ export function wrap(
3837
fn: WrappedFunction,
3938
options: {
4039
mechanism?: Mechanism;
40+
capture?: boolean;
4141
} = {},
4242
before?: WrappedFunction,
4343
): any {

packages/browser/src/integrations/trycatch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Integration, WrappedFunction } from '@sentry/types';
2-
import { getGlobalObject } from '@sentry/utils/misc';
3-
import { fill } from '@sentry/utils/object';
2+
import { fill, getGlobalObject } from '@sentry/utils';
43

54
import { breadcrumbEventHandler, keypressEventHandler, wrap } from './helpers';
65

packages/browser/src/integrations/useragent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
22
import { Event, Integration } from '@sentry/types';
3-
import { getGlobalObject } from '@sentry/utils/misc';
3+
import { getGlobalObject } from '@sentry/utils';
44

55
const global = getGlobalObject<Window>();
66

0 commit comments

Comments
 (0)