make it illegal to export a __esModule property - #673

This commit is contained in:
Sebastian McKenzie 2015-02-03 14:41:11 +11:00
parent 630f1717f0
commit 92d9b3ff5f
5 changed files with 15 additions and 0 deletions

View File

@ -212,6 +212,12 @@ DefaultFormatter.prototype.getExternalReference = function (node, nodes) {
}
};
DefaultFormatter.prototype.checkExportIdentifier = function (node) {
if (t.isIdentifier(node, { name: "__esModule" })) {
throw this.file.errorWithNode(node, "Illegal export __esModule - this is used internally for CommonJS interop");
}
};
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
@ -251,6 +257,7 @@ DefaultFormatter.prototype.buildExportsWildcard = function (objectIdentifier) {
};
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
this.checkExportIdentifier(id);
return util.template("exports-assign", {
VALUE: init,
KEY: id

View File

@ -0,0 +1 @@
export { __esModule };

View File

@ -0,0 +1,3 @@
{
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
}

View File

@ -0,0 +1 @@
export var __esModule = false;

View File

@ -0,0 +1,3 @@
{
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
}