Give users helpful feedback if they are detected as using the wrong sourceType.
This commit is contained in:
@@ -31,7 +31,10 @@ export default function(api, options) {
|
||||
|
||||
const getAssertion = localName => template.expression.ast`
|
||||
(function(){
|
||||
throw new Error("The CommonJS '" + "${localName}" + "' variable is not available in ES6 modules.");
|
||||
throw new Error(
|
||||
"The CommonJS '" + "${localName}" + "' variable is not available in ES6 modules." +
|
||||
"Consider setting setting sourceType:script or sourceType:unambiguous in your " +
|
||||
"Babel config for this file.");
|
||||
})()
|
||||
`;
|
||||
|
||||
|
||||
@@ -3,56 +3,56 @@
|
||||
require("foo");
|
||||
|
||||
console.log(function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}());
|
||||
console.log(function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}().prop);
|
||||
|
||||
exports = function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}() + 1;
|
||||
|
||||
exports = function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}() + 4;
|
||||
|
||||
({
|
||||
exports
|
||||
} = ({}, function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}()));
|
||||
[exports] = ([], function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}());
|
||||
exports = {};
|
||||
(function () {
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "exports" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
})().prop = "";
|
||||
console.log(function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}());
|
||||
console.log(function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}().exports);
|
||||
|
||||
module = function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}() + 1;
|
||||
|
||||
module = function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}() + 4;
|
||||
|
||||
({
|
||||
module
|
||||
} = ({}, function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}()));
|
||||
[module] = ([], function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
}());
|
||||
module = {};
|
||||
(function () {
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules.");
|
||||
throw new Error("The CommonJS '" + "module" + "' variable is not available in ES6 modules." + "Consider setting setting sourceType:script or sourceType:unambiguous in your " + "Babel config for this file.");
|
||||
})().prop = "";
|
||||
|
||||
Reference in New Issue
Block a user