Nenhuma Descrição

babel.config.js 975B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * A babel preset wrapper to set @babel/plugin-transform-runtime's absoluteRuntime to true.
  3. *
  4. * @param {string|Function} preset - The preset being wrapped.
  5. * @returns {Function} The wrapped preset-function.
  6. */
  7. function presetOverrideBabelPluginTransformRuntimeAbsoluteRuntime( preset ) {
  8. if ( 'string' === typeof preset ) {
  9. preset = require( preset );
  10. }
  11. return ( api, opts ) => {
  12. const ret = preset( api, opts );
  13. // Override the configuration for @babel/plugin-transform-runtime to set absoluteRuntime true.
  14. // This prevents it from blowing up when other workspace projects are symlinked.
  15. ret.plugins.forEach( p => {
  16. if ( Array.isArray( p ) && /[\\/]@babel[\\/]plugin-transform-runtime[\\/]/.test( p[ 0 ] ) ) {
  17. p[ 1 ].absoluteRuntime = true;
  18. }
  19. } );
  20. return ret;
  21. };
  22. }
  23. const config = {
  24. presets: [
  25. presetOverrideBabelPluginTransformRuntimeAbsoluteRuntime(
  26. '@automattic/calypso-build/babel/default'
  27. ),
  28. ],
  29. };
  30. module.exports = config;