Default templates to sourceType:module.
This commit is contained in:
parent
afc3963848
commit
fc3433c5cf
@ -6,7 +6,7 @@ const helpers = {};
|
||||
export default helpers;
|
||||
|
||||
function defineHelper(str) {
|
||||
return template(str, { sourceType: "module" });
|
||||
return template(str);
|
||||
}
|
||||
|
||||
helpers.typeof = defineHelper(`
|
||||
|
||||
@ -17,7 +17,7 @@ export default function defineHelper(
|
||||
throw new Error(`The ${id} helper is already defined.`);
|
||||
}
|
||||
Object.defineProperty(helpers, id, {
|
||||
value: template(code, { sourceType: "module" }),
|
||||
value: template(code),
|
||||
});
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -129,6 +129,7 @@ function factory(code: string, opts?: Object): Function {
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
preserveComments: false,
|
||||
sourceType: "module",
|
||||
},
|
||||
opts,
|
||||
);
|
||||
|
||||
@ -5,18 +5,18 @@ import chai from "chai";
|
||||
const comments = "// Sum two numbers\nconst add = (a, b) => a + b;";
|
||||
|
||||
describe("templating", function() {
|
||||
it("import statement will cause parser to throw by default", function() {
|
||||
it("import statements are allowed by default", function() {
|
||||
chai
|
||||
.expect(function() {
|
||||
template("import foo from 'foo'")({});
|
||||
})
|
||||
.to.throw();
|
||||
.not.to.throw();
|
||||
});
|
||||
|
||||
it("import statements are allowed with sourceType: module", function() {
|
||||
it("with statements are allowed with sourceType: script", function() {
|
||||
chai
|
||||
.expect(function() {
|
||||
template("import foo from 'foo'", { sourceType: "module" })({});
|
||||
template("with({}){}", { sourceType: "script" })({});
|
||||
})
|
||||
.not.to.throw();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user