babel.config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. plugins: [
  56. // Required, see https://github.com/facebook/jest/issues/9430
  57. 'dynamic-import-node',
  58. // Disable emotion sourcemaps in tests
  59. // Since emotion spends lots of time parsing and inserting sourcemaps
  60. [
  61. '@emotion/babel-plugin',
  62. {
  63. sourceMap: false,
  64. },
  65. ],
  66. ],
  67. },
  68. },
  69. };
  70. export default config;