babel.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* eslint-env node */
  2. import type {TransformOptions} from '@babel/core';
  3. const config: TransformOptions = {
  4. presets: [
  5. [
  6. '@babel/preset-react',
  7. {
  8. runtime: 'automatic',
  9. importSource: '@emotion/react',
  10. },
  11. ],
  12. [
  13. '@babel/preset-env',
  14. {
  15. useBuiltIns: 'usage',
  16. corejs: '3.27',
  17. },
  18. ],
  19. // TODO: Remove allowDeclareFields when we upgrade to Babel 8
  20. ['@babel/preset-typescript', {allowDeclareFields: true}],
  21. ],
  22. overrides: [],
  23. plugins: ['@emotion/babel-plugin', '@babel/plugin-transform-runtime'],
  24. env: {
  25. production: {
  26. plugins: [
  27. ['babel-plugin-add-react-displayname'],
  28. '@sentry/babel-plugin-component-annotate',
  29. ],
  30. },
  31. development: {
  32. plugins: [
  33. '@emotion/babel-plugin',
  34. '@babel/plugin-transform-react-jsx-source',
  35. '@sentry/babel-plugin-component-annotate',
  36. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  37. ],
  38. },
  39. test: {
  40. sourceMaps: process.env.CI ? false : true,
  41. plugins: [
  42. // Required, see https://github.com/facebook/jest/issues/9430
  43. 'dynamic-import-node',
  44. // Disable emotion sourcemaps in tests
  45. // Since emotion spends lots of time parsing and inserting sourcemaps
  46. [
  47. '@emotion/babel-plugin',
  48. {
  49. sourceMap: false,
  50. },
  51. ],
  52. ],
  53. },
  54. },
  55. };
  56. export default config;