From 99c48107705b085d4694158f3ad599703be697af Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 30 May 2015 23:18:45 -0400 Subject: [PATCH] add regeneratot transform to builtin-advanced group --- .../transformation/transformers/index.js | 4 +-- .../transformers/other/regenerator.js | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/babel/transformation/transformers/index.js b/src/babel/transformation/transformers/index.js index 343279ec7d..f96442ce7d 100644 --- a/src/babel/transformation/transformers/index.js +++ b/src/babel/transformation/transformers/index.js @@ -59,13 +59,11 @@ export default { "es6.spec.blockScoping": require("./es6/spec.block-scoping"), reactCompat: require("./other/react-compat"), react: require("./other/react"), + regenerator: require("./other/regenerator"), // es6 syntax transformation is **forbidden** past this point since regenerator will chuck a massive // hissy fit - //- regenerator - regenerator: require("./other/regenerator"), - //- builtin-modules runtime: require("./other/runtime"), "es6.modules": require("./es6/modules"), diff --git a/src/babel/transformation/transformers/other/regenerator.js b/src/babel/transformation/transformers/other/regenerator.js index 265bad2876..adc9252cdc 100644 --- a/src/babel/transformation/transformers/other/regenerator.js +++ b/src/babel/transformation/transformers/other/regenerator.js @@ -3,21 +3,23 @@ import * as t from "../../../types"; import { NodePath } from "ast-types"; export var metadata = { - group: "regenerator" + group: "builtin-advanced" }; -export function Func/*tion*/(node) { - if (node.async || node.generator) { - // Although this code transforms only the subtree rooted at the given - // Function node, that node might contain other generator functions - // that will also be transformed. It might help performance to ignore - // nested functions, and rely on the traversal to visit them later, - // but that's a small optimization. Starting here instead of at the - // root of the AST is the key optimization, since huge async/generator - // functions are relatively rare. - regenerator.transform(convertNodePath(this)); +export var Func/*tion*/ = { + exit(node) { + if (node.async || node.generator) { + // Although this code transforms only the subtree rooted at the given + // Function node, that node might contain other generator functions + // that will also be transformed. It might help performance to ignore + // nested functions, and rely on the traversal to visit them later, + // but that's a small optimization. Starting here instead of at the + // root of the AST is the key optimization, since huge async/generator + // functions are relatively rare. + regenerator.transform(convertNodePath(this)); + } } -} +}; // Given a Babel NodePath, return an ast-types NodePath that includes full // ancestry information (up to and including the Program node). This is