babel.config.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* eslint-env node */
  2. import {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-proposal-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. 'AsyncComponent',
  39. 'AsyncView',
  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. // Required, see https://github.com/facebook/jest/issues/9430
  56. plugins: ['dynamic-import-node'],
  57. },
  58. },
  59. };
  60. export default config;