Skip to content

Commit fd2a99c

Browse files
authored
misc(esbuild): Log warning when attempting to inject debug IDs with esbuild bundle option active (#526)
1 parent 295fa19 commit fd2a99c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Diff for: packages/bundler-plugin-core/src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { normalizeUserOptions, validateOptions } from "./options-mapping";
99
import { createDebugIdUploadFunction } from "./debug-id-upload";
1010
import { releaseManagementPlugin } from "./plugins/release-management";
1111
import { telemetryPlugin } from "./plugins/telemetry";
12-
import { createLogger } from "./sentry/logger";
12+
import { createLogger, Logger } from "./sentry/logger";
1313
import { allowedToSendTelemetry, createSentryInstance } from "./sentry/telemetry";
1414
import { Options, SentrySDKBuildFlags } from "./types";
1515
import {
@@ -30,7 +30,7 @@ interface SentryUnpluginFactoryOptions {
3030
releaseInjectionPlugin: (injectionCode: string) => UnpluginOptions;
3131
componentNameAnnotatePlugin?: () => UnpluginOptions;
3232
moduleMetadataInjectionPlugin?: (injectionCode: string) => UnpluginOptions;
33-
debugIdInjectionPlugin: () => UnpluginOptions;
33+
debugIdInjectionPlugin: (logger: Logger) => UnpluginOptions;
3434
debugIdUploadPlugin: (upload: (buildArtifacts: string[]) => Promise<void>) => UnpluginOptions;
3535
bundleSizeOptimizationsPlugin: (buildFlags: SentrySDKBuildFlags) => UnpluginOptions;
3636
}
@@ -281,7 +281,7 @@ export function sentryUnpluginFactory({
281281
);
282282
}
283283

284-
plugins.push(debugIdInjectionPlugin());
284+
plugins.push(debugIdInjectionPlugin(logger));
285285

286286
if (!options.authToken) {
287287
logger.warn(
@@ -592,3 +592,4 @@ export function getDebugIdSnippet(debugId: string): string {
592592
export { stringToUUID, replaceBooleanFlagsInCode } from "./utils";
593593

594594
export type { Options, SentrySDKBuildFlags } from "./types";
595+
export type { Logger } from "./sentry/logger";

Diff for: packages/esbuild-plugin/src/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getDebugIdSnippet,
55
SentrySDKBuildFlags,
66
} from "@sentry/bundler-plugin-core";
7+
import type { Logger } from "@sentry/bundler-plugin-core";
78
import type { UnpluginOptions } from "unplugin";
89
import * as path from "path";
910

@@ -41,7 +42,7 @@ function esbuildReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
4142
};
4243
}
4344

44-
function esbuildDebugIdInjectionPlugin(): UnpluginOptions {
45+
function esbuildDebugIdInjectionPlugin(logger: Logger): UnpluginOptions {
4546
const pluginName = "sentry-esbuild-debug-id-injection-plugin";
4647
const stubNamespace = "sentry-debug-id-stub";
4748

@@ -50,6 +51,12 @@ function esbuildDebugIdInjectionPlugin(): UnpluginOptions {
5051

5152
esbuild: {
5253
setup({ initialOptions, onLoad, onResolve }) {
54+
if (initialOptions.bundle) {
55+
logger.warn(
56+
"Esbuild's `bundle: true` option is currently not supported! Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps with the `bundle` option, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/"
57+
);
58+
}
59+
5360
onResolve({ filter: /.*/ }, (args) => {
5461
if (args.kind !== "entry-point") {
5562
return;

0 commit comments

Comments
 (0)