babel.config.cjs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module.exports = {
  2. compact: false,
  3. presets: [
  4. [
  5. '@babel/env',
  6. {
  7. useBuiltIns: 'usage',
  8. // This version must be aligned with the `core-js` version in `package.json`
  9. corejs: { version: '3.46' },
  10. exclude: [
  11. // Exclude Array.prototype.push polyfill, as it's not needed and affects performance in Chrome
  12. 'es.array.push',
  13. // Exclude objectSpread polyfill, as it's not needed and affects performance
  14. '@babel/plugin-transform-object-rest-spread',
  15. // Exclude _defineProperty polyfill, as it causes a bug without the objectSpread polyfill
  16. '@babel/plugin-transform-computed-properties',
  17. // Use native async functions, for performance
  18. '@babel/plugin-transform-async-to-generator',
  19. // Use native generators, for performance
  20. '@babel/plugin-transform-regenerator',
  21. // Use native async generators, for performance
  22. '@babel/plugin-transform-async-generator-functions',
  23. // Use native for-of loops, for performance
  24. '@babel/plugin-transform-for-of',
  25. ],
  26. },
  27. ],
  28. ['@babel/react', { runtime: 'automatic' }],
  29. '@babel/typescript',
  30. ],
  31. plugins: ['macros'],
  32. overrides: [
  33. // treat .cjs files (e.g. libraries symlinked into node_modules) as commonjs
  34. { test: /\.cjs$/, sourceType: 'script' },
  35. {
  36. // Use [\\/] for cross-platform path separator compatibility
  37. test: /[\\/]libraries[\\/]overleaf-editor-core[\\/].*\.js$/,
  38. sourceType: 'script',
  39. },
  40. ],
  41. }