fix incorrect interpreation of export default shorthand, update to new ast definitions - #1091
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
else callback("fail", test.code,
|
||||
"Expected error message: " + test.error + "\nGot error message: " + e.message);
|
||||
} else {
|
||||
callback("error", test.code, e.message || e.toString());
|
||||
callback("error", test.code, e.stack || e.toString());
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -2789,18 +2789,89 @@ test('class Foo { @bar static foo = "bar"; }', {
|
||||
|
||||
// ES7 export extensions - https://github.com/leebyron/ecmascript-more-export-from
|
||||
|
||||
test('export foo, { bar } from "bar";', {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExportNamedDeclaration",
|
||||
start: 0,
|
||||
end: 31,
|
||||
specifiers: [{
|
||||
type: "ExportDefaultSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 7,
|
||||
end: 10,
|
||||
}
|
||||
}, {
|
||||
type: "ExportSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "bar"
|
||||
}
|
||||
}],
|
||||
source: {
|
||||
type: "Literal",
|
||||
value: "bar",
|
||||
start: 25,
|
||||
end: 30
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
ecmaVersion: 7,
|
||||
sourceType: "module",
|
||||
features: { "es7.exportExtensions": true }
|
||||
});
|
||||
|
||||
test('export * as foo, { bar } from "bar";', {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExportNamedDeclaration",
|
||||
start: 0,
|
||||
end: 36,
|
||||
specifiers: [{
|
||||
type: "ExportNamespaceSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 12,
|
||||
end: 15,
|
||||
}
|
||||
}, {
|
||||
type: "ExportSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "bar"
|
||||
}
|
||||
}],
|
||||
source: {
|
||||
type: "Literal",
|
||||
value: "bar",
|
||||
start: 30,
|
||||
end: 35
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
ecmaVersion: 7,
|
||||
sourceType: "module",
|
||||
features: { "es7.exportExtensions": true }
|
||||
});
|
||||
|
||||
test('export foo from "bar";', {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExportNamespaceDeclaration",
|
||||
type: "ExportNamedDeclaration",
|
||||
start: 0,
|
||||
end: 22,
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 7,
|
||||
end: 10,
|
||||
},
|
||||
specifiers: [{
|
||||
type: "ExportDefaultSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 7,
|
||||
end: 10,
|
||||
}
|
||||
}],
|
||||
source: {
|
||||
type: "Literal",
|
||||
value: "bar",
|
||||
@@ -2814,18 +2885,49 @@ test('export foo from "bar";', {
|
||||
features: { "es7.exportExtensions": true }
|
||||
});
|
||||
|
||||
test('export default from "bar";', {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExportNamedDeclaration",
|
||||
start: 0,
|
||||
end: 26,
|
||||
specifiers: [{
|
||||
type: "ExportDefaultSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "default",
|
||||
start: 7,
|
||||
end: 14,
|
||||
}
|
||||
}],
|
||||
source: {
|
||||
type: "Literal",
|
||||
value: "bar",
|
||||
start: 20,
|
||||
end: 25
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
ecmaVersion: 7,
|
||||
sourceType: "module",
|
||||
features: { "es7.exportExtensions": true }
|
||||
});
|
||||
|
||||
test('export * as foo from "bar";', {
|
||||
type: "Program",
|
||||
body: [{
|
||||
type: "ExportAllDeclaration",
|
||||
type: "ExportNamedDeclaration",
|
||||
start: 0,
|
||||
end: 27,
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 12,
|
||||
end: 15,
|
||||
},
|
||||
specifiers: [{
|
||||
type: "ExportNamespaceSpecifier",
|
||||
exported: {
|
||||
type: "Identifier",
|
||||
name: "foo",
|
||||
start: 12,
|
||||
end: 15,
|
||||
}
|
||||
}],
|
||||
source: {
|
||||
type: "Literal",
|
||||
value: "bar",
|
||||
|
||||
@@ -9,6 +9,8 @@ export default class Foo {}
|
||||
export * from "foo";
|
||||
export * as foo from "foo";
|
||||
export foo from "foo";
|
||||
export * as foo, { bar } from "foo";
|
||||
export foo, { bar } from "foo";
|
||||
export { foo } from "foo";
|
||||
export { foo, bar } from "foo";
|
||||
export { foo as bar } from "foo";
|
||||
|
||||
@@ -2,13 +2,15 @@ export default 42;
|
||||
export default {};
|
||||
export default [];
|
||||
export default foo;
|
||||
export default function () {};
|
||||
export default class {};
|
||||
export default function () {}
|
||||
export default class {}
|
||||
export default function foo() {}
|
||||
export default class Foo {}
|
||||
export * from "foo";
|
||||
export * as foo from "foo";
|
||||
export foo from "foo";
|
||||
export * as foo, { bar } from "foo";
|
||||
export foo, { bar } from "foo";
|
||||
export { foo } from "foo";
|
||||
export { foo, bar } from "foo";
|
||||
export { foo as bar } from "foo";
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var _default = babelHelpers.interopRequire(require("bar"));
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
module.exports = _default;
|
||||
var _foo = require("bar").foo;
|
||||
|
||||
exports.foo = _foo;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
import _default from "bar";
|
||||
export default _default;
|
||||
import { foo as _foo } from "bar";
|
||||
export { _foo as foo };
|
||||
|
||||
Reference in New Issue
Block a user