env.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * This module exists for optimizations in the build process through rollup and terser. We define some global
  3. * constants, which can be overridden during build. By guarding certain pieces of code with functions that return these
  4. * constants, we can control whether or not they appear in the final bundle. (Any code guarded by a false condition will
  5. * never run, and will hence be dropped during treeshaking.) The two primary uses for this are stripping out calls to
  6. * `logger` and preventing node-related code from appearing in browser bundles.
  7. *
  8. * Attention:
  9. * This file should not be used to define constants/flags that are intended to be used for tree-shaking conducted by
  10. * users. These flags should live in their respective packages, as we identified user tooling (specifically webpack)
  11. * having issues tree-shaking these constants across package boundaries.
  12. * An example for this is the __SENTRY_DEBUG__ constant. It is declared in each package individually because we want
  13. * users to be able to shake away expressions that it guards.
  14. */
  15. /**
  16. * Figures out if we're building a browser bundle.
  17. *
  18. * @returns true if this is a browser bundle build.
  19. */
  20. function isBrowserBundle() {
  21. return typeof __SENTRY_BROWSER_BUNDLE__ !== 'undefined' && !!__SENTRY_BROWSER_BUNDLE__;
  22. }
  23. /**
  24. * Get source of SDK.
  25. */
  26. function getSDKSource() {
  27. // @ts-expect-error "npm" is injected by rollup during build process
  28. return "npm";
  29. }
  30. export { getSDKSource, isBrowserBundle };
  31. //# sourceMappingURL=env.js.map