index.js 826 B

123456789101112131415161718192021222324252627
  1. /**
  2. * Copyright (c) 2014-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import { getVisitor } from "./visit";
  8. export default function (context) {
  9. const plugin = {
  10. visitor: getVisitor(context),
  11. };
  12. // Some presets manually call child presets, but fail to pass along the
  13. // context object. Out of an abundance of caution, we verify that it
  14. // exists first to avoid causing unnecessary breaking changes.
  15. const version = context && context.version;
  16. // The "name" property is not allowed in older versions of Babel (6.x)
  17. // and will cause the plugin validator to throw an exception.
  18. if (version && parseInt(version, 10) >= 7) {
  19. plugin.name = "regenerator-transform";
  20. }
  21. return plugin;
  22. }