From acf7ef94255f7421b93b517bfc11c8a711f0b2b6 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Tue, 8 Mar 2022 23:40:00 -0800 Subject: [PATCH] simplify `isDebugBuild` and default the return value to `true` --- packages/utils/src/env.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/utils/src/env.ts b/packages/utils/src/env.ts index 44a0ea4fc98c..a2b6eb56d7f9 100644 --- a/packages/utils/src/env.ts +++ b/packages/utils/src/env.ts @@ -1,16 +1,14 @@ /** - * This module mostly exists for optimizations in the build process - * through rollup and terser. We define some global constants which - * are normally undefined. However terser overrides these with global - * definitions which can be evaluated by the static analyzer when - * creating a bundle. - * - * In turn the `isDebugBuild` and `isBrowserBundle` functions are pure - * and can help us remove unused code from the bundles. + * This module exists for optimizations in the build process through rollup and terser. We define some global + * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these + * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will + * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to + * `logger` and preventing node-related code from appearing in browser bundles. */ declare const __SENTRY_BROWSER_BUNDLE__: boolean | undefined; -declare const __SENTRY_NO_DEBUG__: boolean | undefined; + +const __SENTRY_DEBUG__ = true; /** * Figures out if we're building with debug functionality. @@ -18,7 +16,7 @@ declare const __SENTRY_NO_DEBUG__: boolean | undefined; * @returns true if this is a debug build */ export function isDebugBuild(): boolean { - return typeof __SENTRY_NO_DEBUG__ !== 'undefined' && !__SENTRY_BROWSER_BUNDLE__; + return __SENTRY_DEBUG__; } /**