8000 feat(google-cloud): Expose ESM build (#12149) · benjick/sentry-javascript@f7bd662 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7bd662

Browse files
authored
feat(google-cloud): Expose ESM build (getsentry#12149)
This exposes the ESM build for `@sentry/google-cloud-serverless`, with the caveat that the performance related instrumentation does not work atm. These need to be ported to use OpenTelemetry instrumentation.
1 parent 85158c5 commit f7bd662

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

packages/google-cloud-serverless/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"exports": {
2323
"./package.json": "./package.json",
2424
".": {
25+
"import": {
26+
"types": "./build/types/index.d.ts",
27+
"default": "./build/esm/index.js"
28+
},
2529
"require": {
2630
"types": "./build/types/index.d.ts",
2731
"default": "./build/cjs/index.js"

packages/google-cloud-serverless/src/sdk.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ import type { Integration, Options, SdkMetadata } from '@sentry/types';
55
import { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';
66
import { googleCloudHttpIntegration } from './integrations/google-cloud-http';
77

8+
function isCjs(): boolean {
9+
return typeof require !== 'undefined';
10+
}
11+
12+
function getCjsOnlyIntegrations(): Integration[] {
13+
return isCjs()
14+
? [
15+
googleCloudHttpIntegration({ optional: true }), // We mark this integration optional since '@google-cloud/common' module could be missing.
16+
googleCloudGrpcIntegration({ optional: true }), // We mark this integration optional since 'google-gax' module could be missing.
17+
]
18+
: [];
19+
}
20+
821
/** Get the default integrations for the GCP SDK. */
922
export function getDefaultIntegrations(_options: Options): Integration[] {
10-
return [
11-
...getDefaultIntegrationsWithoutPerformance(),
12-
googleCloudHttpIntegration({ optional: true }), // We mark this integration optional since '@google-cloud/common' module could be missing.
13-
googleCloudGrpcIntegration({ optional: true }), // We mark this integration optional since 'google-gax' module could be missing.
14-
];
23+
return [...getDefaultIntegrationsWithoutPerformance(), ...getCjsOnlyIntegrations()];
1524
}
1625

1726
/**

0 commit comments

Comments
 (0)
0