exportGlobals.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import * as React from 'react';
  2. import {findDOMNode} from 'react-dom';
  3. import {createRoot} from 'react-dom/client';
  4. // eslint-disable-next-line no-restricted-imports
  5. import * as ReactRouter from 'react-router';
  6. import * as Sentry from '@sentry/react';
  7. import moment from 'moment';
  8. import * as Reflux from 'reflux';
  9. import plugins from 'sentry/plugins';
  10. const globals = {
  11. // The following globals are used in sentry-plugins webpack externals
  12. // configuration.
  13. React,
  14. Reflux,
  15. Sentry,
  16. moment,
  17. Router: ReactRouter,
  18. ReactDOM: {findDOMNode, createRoot},
  19. // django templates make use of these globals
  20. SentryApp: {},
  21. };
  22. // The SentryApp global contains exported app modules for use in javascript
  23. // modules that are not compiled with the sentry bundle.
  24. const SentryApp = {
  25. // The following components are used in sentry-plugins.
  26. FormState: require('sentry/components/forms/state').default,
  27. LoadingIndicator: require('sentry/components/loadingIndicator').default,
  28. plugins: {
  29. add: plugins.add,
  30. addContext: plugins.addContext,
  31. BasePlugin: plugins.BasePlugin,
  32. DefaultIssuePlugin: plugins.DefaultIssuePlugin,
  33. },
  34. // The following components are used in legacy django HTML views
  35. // or in the Sentry sandbox
  36. ConfigStore: require('sentry/stores/configStore').default,
  37. HookStore: require('sentry/stores/hookStore').default,
  38. GuideActionCreator: require('sentry/actionCreators/guides'),
  39. Modal: require('sentry/actionCreators/modal'),
  40. getModalPortal: require('sentry/utils/getModalPortal').default,
  41. Client: require('sentry/api').Client,
  42. // This is used in the Email Modal in the Sandbox
  43. IconArrow: require('sentry/icons/iconArrow').IconArrow,
  44. };
  45. globals.SentryApp = SentryApp;
  46. Object.keys(globals).forEach(name => (window[name] = globals[name]));
  47. export {globals as exportedGlobals};