babel.config.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // TODO: Remove allowDeclareFields when we upgrade to Babel 8
  20. ['@babel/preset-typescript', {allowDeclareFields: true}],
  21. ],
  22. overrides: [],
  23. plugins: ['@emotion/babel-plugin', '@babel/plugin-transform-runtime'],
  24. env: {
  25. production: {
  26. plugins: [
  27. [
  28. 'transform-react-remove-prop-types',
  29. {
  30. mode: 'remove', // remove from bundle
  31. removeImport: true, // removes `prop-types` import statements
  32. classNameMatchers: [
  33. 'SelectField',
  34. 'FormField',
  35. 'DeprecatedAsyncComponent',
  36. 'DeprecatedAsyncView',
  37. ],
  38. additionalLibraries: [/app\/sentryTypes$/],
  39. },
  40. ],
  41. ['babel-plugin-add-react-displayname'],
  42. '@sentry/babel-plugin-component-annotate',
  43. ],
  44. },
  45. development: {
  46. plugins: [
  47. '@emotion/babel-plugin',
  48. '@babel/plugin-transform-react-jsx-source',
  49. '@sentry/babel-plugin-component-annotate',
  50. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  51. ],
  52. },
  53. test: {
  54. sourceMaps: process.env.CI ? false : true,
  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;