| 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 |
|
| 8 |
import { getVisitor } from "./visit"; |
| 9 |
|
| 10 |
export default function (context) { |
| 11 |
const plugin = { |
| 12 |
visitor: getVisitor(context), |
| 13 |
}; |
| 14 |
|
| 15 |
// Some presets manually call child presets, but fail to pass along the |
| 16 |
// context object. Out of an abundance of caution, we verify that it |
| 17 |
// exists first to avoid causing unnecessary breaking changes. |
| 18 |
const version = context && context.version; |
| 19 |
|
| 20 |
// The "name" property is not allowed in older versions of Babel (6.x) |
| 21 |
// and will cause the plugin validator to throw an exception. |
| 22 |
if (version && parseInt(version, 10) >= 7) { |
| 23 |
plugin.name = "regenerator-transform"; |
| 24 |
} |
| 25 |
|
| 26 |
return plugin; |
| 27 |
} |