fix export default expression; (#1932)
This commit is contained in:
@@ -2302,8 +2302,7 @@ function parse($TEXT, options) {
|
|||||||
if (is("keyword", "default")) {
|
if (is("keyword", "default")) {
|
||||||
is_default = true;
|
is_default = true;
|
||||||
next();
|
next();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
exported_names = import_names(false);
|
exported_names = import_names(false);
|
||||||
|
|
||||||
if (exported_names) {
|
if (exported_names) {
|
||||||
@@ -2337,6 +2336,7 @@ function parse($TEXT, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var is_definition =
|
var is_definition =
|
||||||
is("keyword", "var") || is("keyword", "let") || is("keyword", "const") ||
|
is("keyword", "var") || is("keyword", "let") || is("keyword", "const") ||
|
||||||
|
|||||||
@@ -239,6 +239,10 @@ TreeTransformer.prototype = new TreeWalker;
|
|||||||
self.expression = self.expression.transform(tw);
|
self.expression = self.expression.transform(tw);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_(AST_Export, function(self, tw){
|
||||||
|
if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
|
||||||
|
});
|
||||||
|
|
||||||
_(AST_TemplateString, function(self, tw) {
|
_(AST_TemplateString, function(self, tw) {
|
||||||
for (var i = 0; i < self.segments.length; i++) {
|
for (var i = 0; i < self.segments.length; i++) {
|
||||||
if (!(self.segments[i] instanceof AST_TemplateSegment)) {
|
if (!(self.segments[i] instanceof AST_TemplateSegment)) {
|
||||||
|
|||||||
@@ -203,15 +203,42 @@ import_all_statement: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export_statement: {
|
export_statement: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
export default 1;
|
export default 1 + 2;
|
||||||
export var foo = 4;
|
export var foo = 4;
|
||||||
export let foo = 6;
|
export let foo = 6;
|
||||||
export const foo = 6;
|
export const foo = 6;
|
||||||
export function foo() {};
|
export function foo() {};
|
||||||
export class foo { };
|
export class foo { };
|
||||||
}
|
}
|
||||||
expect_exact: "export default 1;export var foo=4;export let foo=6;export const foo=6;export function foo(){};export class foo{};"
|
expect_exact: "export default 3;export var foo=4;export let foo=6;export const foo=6;export function foo(){};export class foo{};"
|
||||||
|
}
|
||||||
|
|
||||||
|
export_default_object_expression: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
export default {
|
||||||
|
foo: 1 + 2,
|
||||||
|
bar() { return 4; },
|
||||||
|
get baz() { return this.foo; },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
expect_exact: "export default{foo:3,bar(){return 4},get baz(){return this.foo}};"
|
||||||
|
}
|
||||||
|
|
||||||
|
export_default_array: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
export default [ 1 + 2, foo ];
|
||||||
|
}
|
||||||
|
expect_exact: "export default[3,foo];"
|
||||||
}
|
}
|
||||||
|
|
||||||
export_module_statement: {
|
export_module_statement: {
|
||||||
|
|||||||
Reference in New Issue
Block a user