Give users helpful feedback if they are detected as using the wrong sourceType.

This commit is contained in:
Logan Smyth
2018-03-03 13:21:38 -08:00
parent 5c3092d86f
commit 5f6e3122a0
6 changed files with 33 additions and 15 deletions

View File

@@ -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.");
})()
`;