babel.config.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. '@babel/preset-typescript',
  20. ],
  21. overrides: [],
  22. plugins: [
  23. '@emotion/babel-plugin',
  24. '@babel/plugin-transform-runtime',
  25. '@babel/plugin-transform-class-properties',
  26. ],
  27. env: {
  28. production: {
  29. plugins: [
  30. [
  31. 'transform-react-remove-prop-types',
  32. {
  33. mode: 'remove', // remove from bundle
  34. removeImport: true, // removes `prop-types` import statements
  35. classNameMatchers: [
  36. 'SelectField',
  37. 'FormField',
  38. 'DeprecatedAsyncComponent',
  39. 'DeprecatedAsyncView',
  40. ],
  41. additionalLibraries: [/app\/sentryTypes$/],
  42. },
  43. ],
  44. ['babel-plugin-add-react-displayname'],
  45. ],
  46. },
  47. development: {
  48. plugins: [
  49. '@emotion/babel-plugin',
  50. '@babel/plugin-transform-react-jsx-source',
  51. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  52. ],
  53. },
  54. test: {
  55. sourceMaps: process.env.CI ? false : true,
  56. plugins: [
  57. // Required, see https://github.com/facebook/jest/issues/9430
  58. 'dynamic-import-node',
  59. // Disable emotion sourcemaps in tests
  60. // Since emotion spends lots of time parsing and inserting sourcemaps
  61. [
  62. '@emotion/babel-plugin',
  63. {
  64. sourceMap: false,
  65. },
  66. ],
  67. ],
  68. },
  69. },
  70. };
  71. export default config;