babel.config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-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. ['@fullstory/babel-plugin-annotate-react'],
  46. ],
  47. },
  48. development: {
  49. plugins: [
  50. '@emotion/babel-plugin',
  51. '@babel/plugin-transform-react-jsx-source',
  52. ['@fullstory/babel-plugin-annotate-react'],
  53. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  54. ],
  55. },
  56. test: {
  57. sourceMaps: process.env.CI ? false : true,
  58. plugins: [
  59. // Required, see https://github.com/facebook/jest/issues/9430
  60. 'dynamic-import-node',
  61. // Disable emotion sourcemaps in tests
  62. // Since emotion spends lots of time parsing and inserting sourcemaps
  63. [
  64. '@emotion/babel-plugin',
  65. {
  66. sourceMap: false,
  67. },
  68. ],
  69. ],
  70. },
  71. },
  72. };
  73. export default config;