babel.config.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.15',
  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. // NOTE: The order of the decorator and class-property plugins is important
  38. // here. Decorators must be processed first before class properties, see:
  39. // https://babeljs.io/docs/en/plugins#plugin-ordering
  40. ['@babel/plugin-proposal-decorators', {legacy: true}],
  41. '@babel/plugin-proposal-class-properties',
  42. ],
  43. env: {
  44. production: {
  45. plugins: [
  46. [
  47. 'transform-react-remove-prop-types',
  48. {
  49. mode: 'remove', // remove from bundle
  50. removeImport: true, // removes `prop-types` import statements
  51. classNameMatchers: [
  52. 'SelectField',
  53. 'FormField',
  54. 'AsyncComponent',
  55. 'AsyncView',
  56. ],
  57. additionalLibraries: [/app\/sentryTypes$/],
  58. },
  59. ],
  60. ['babel-plugin-add-react-displayname'],
  61. ],
  62. },
  63. development: {
  64. plugins: [
  65. '@emotion/babel-plugin',
  66. '@babel/plugin-transform-react-jsx-source',
  67. ...(process.env.SENTRY_UI_HOT_RELOAD ? ['react-refresh/babel'] : []),
  68. ],
  69. },
  70. test: {
  71. // Required, see https://github.com/facebook/jest/issues/9430
  72. plugins: ['dynamic-import-node'],
  73. },
  74. },
  75. };
  76. export default config;