index.js 924 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * Copyright (c) 2014, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  7. * additional grant of patent rights can be found in the PATENTS file in
  8. * the same directory.
  9. */
  10. export default function (context) {
  11. const plugin = {
  12. visitor: require("./visit").visitor,
  13. };
  14. // Some presets manually call child presets, but fail to pass along the
  15. // context object. Out of an abundance of caution, we verify that it
  16. // exists first to avoid causing unnecessary breaking changes.
  17. const version = context && context.version;
  18. // The "name" property is not allowed in older versions of Babel (6.x)
  19. // and will cause the plugin validator to throw an exception.
  20. if (version && parseInt(version, 10) >= 7) {
  21. plugin.name = "regenerator-transform";
  22. }
  23. return plugin;
  24. }