make it illegal to export a __esModule property - #673
This commit is contained in:
parent
630f1717f0
commit
92d9b3ff5f
@ -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) {
|
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
|
||||||
var inherits = false;
|
var inherits = false;
|
||||||
if (node.specifiers.length === 1) inherits = node;
|
if (node.specifiers.length === 1) inherits = node;
|
||||||
@ -251,6 +257,7 @@ DefaultFormatter.prototype.buildExportsWildcard = function (objectIdentifier) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
|
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
|
||||||
|
this.checkExportIdentifier(id);
|
||||||
return util.template("exports-assign", {
|
return util.template("exports-assign", {
|
||||||
VALUE: init,
|
VALUE: init,
|
||||||
KEY: id
|
KEY: id
|
||||||
|
|||||||
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { __esModule };
|
||||||
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule-2/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
|
||||||
|
}
|
||||||
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export var __esModule = false;
|
||||||
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/illegal-export-esmodule/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"throws": "Illegal export __esModule - this is used internally for CommonJS interop"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user