babel.config.ts 1.6 KB

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