support export default of anonymous functions and classes (#1954)
This commit is contained in:
@@ -2373,10 +2373,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") ||
|
|
||||||
is("keyword", "class") || is("keyword", "function");
|
|
||||||
|
|
||||||
if (is_definition) {
|
if (is_definition) {
|
||||||
exported_definition = statement();
|
exported_definition = statement();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -241,6 +241,30 @@ export_default_array: {
|
|||||||
expect_exact: "export default[3,foo];"
|
expect_exact: "export default[3,foo];"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export_default_anon_function: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
export default function(){
|
||||||
|
console.log(1 + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "export default function(){console.log(3)};"
|
||||||
|
}
|
||||||
|
|
||||||
|
export_default_anon_class: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
export default class {
|
||||||
|
foo() { console.log(1 + 2); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "export default class{foo(){console.log(3)}};"
|
||||||
|
}
|
||||||
|
|
||||||
export_module_statement: {
|
export_module_statement: {
|
||||||
input: {
|
input: {
|
||||||
export * from "a.js";
|
export * from "a.js";
|
||||||
|
|||||||
Reference in New Issue
Block a user