From fec79e358cdf745a0696e77c64ed2b6734ce518f Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Tue, 19 Sep 2017 14:50:21 -0700 Subject: [PATCH] Ensure that Program nodes have a sourceType. --- packages/babel-runtime/scripts/build-dist.js | 2 +- packages/babel-types/src/definitions/core.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/babel-runtime/scripts/build-dist.js b/packages/babel-runtime/scripts/build-dist.js index 4f9a3c5a1f..f581bdb4a3 100644 --- a/packages/babel-runtime/scripts/build-dist.js +++ b/packages/babel-runtime/scripts/build-dist.js @@ -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); diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index abdcd57bb1..9bb1181762 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -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(