diff --git a/packages/babel-core/src/helpers/normalize-ast.js b/packages/babel-core/src/helpers/normalize-ast.js index 50dd1aa321..dd295e6021 100644 --- a/packages/babel-core/src/helpers/normalize-ast.js +++ b/packages/babel-core/src/helpers/normalize-ast.js @@ -7,9 +7,13 @@ import * as t from "babel-types"; */ export default function (ast, comments, tokens) { - if (ast && ast.type === "Program") { - return t.file(ast, comments || [], tokens || []); - } else { - throw new Error("Not a valid ast?"); + if (ast) { + if (ast.type === "Program") { + return t.file(ast, comments || [], tokens || []); + } else if (ast.type === "File") { + return ast; + } } + + throw new Error("Not a valid ast?"); }