From 39fbd550c4c8a4e5f3fe811312deb27d7c74d129 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 12 Aug 2015 02:57:36 +0100 Subject: [PATCH] also transforming of File asts --- packages/babel-core/src/helpers/normalize-ast.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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?"); }