babel.config.js 856 B

12345678910111213141516171819202122232425262728
  1. module.exports = (api) => {
  2. const targets = {}
  3. if (api.env('test')) {
  4. targets.node = 'current'
  5. }
  6. return {
  7. presets: [
  8. ['@babel/preset-env', {
  9. include: [
  10. '@babel/plugin-proposal-nullish-coalescing-operator',
  11. '@babel/plugin-proposal-optional-chaining',
  12. '@babel/plugin-proposal-numeric-separator',
  13. ],
  14. loose: true,
  15. targets,
  16. useBuiltIns: false, // Don't add polyfills automatically.
  17. // We can uncomment the following line if we start adding polyfills to the non-legacy dist files.
  18. // corejs: { version: '3.24', proposals: true },
  19. modules: false,
  20. }],
  21. ],
  22. plugins: [
  23. ['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
  24. process.env.NODE_ENV !== 'dev' && 'babel-plugin-inline-package-json',
  25. ].filter(Boolean),
  26. }
  27. }