babel.config.ts 1.5 KB

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