Ensure that Program nodes have a sourceType.

This commit is contained in:
Logan Smyth 2017-09-19 14:50:21 -07:00
parent b83fa26937
commit fec79e358c
2 changed files with 3 additions and 2 deletions

View File

@ -104,7 +104,7 @@ function buildRuntimeRewritePlugin(relativePath, helperName) {
}
function buildHelper(helperName, modules, useBuiltIns) {
const tree = t.program(helpers.get(helperName).nodes);
const tree = t.program(helpers.get(helperName).nodes, [], "module");
const transformOpts = makeTransformOpts(modules, useBuiltIns);

View File

@ -513,13 +513,14 @@ defineType("NewExpression", { inherits: "CallExpression" });
defineType("Program", {
visitor: ["directives", "body"],
builder: ["body", "directives"],
builder: ["body", "directives", "sourceType"],
fields: {
sourceFile: {
validate: assertValueType("string"),
},
sourceType: {
validate: assertOneOf("script", "module"),
default: "script",
},
directives: {
validate: chain(