CoffeeScript compiler: strip exported variables *before* running through the Babel compiler, to avoid Babel turning a one-line var statement into a multiline var statement and breaking the parsing logic in stripExportedVars

This commit is contained in:
Geoffrey Booth
2016-09-30 22:33:32 -07:00
parent e4dd8684b1
commit 29c37d5d2d

View File

@@ -83,6 +83,11 @@ export class CoffeeCompiler extends CachingCompiler {
let sourceMap = JSON.parse(output.v3SourceMap);
output.js = stripExportedVars(
output.js,
inputFile.getDeclaredExports().map(e => e.name)
);
if (source.indexOf('`') !== -1) {
// If source contains backticks, pass the coffee output through babel-compiler
const doubleRoastedCoffee =
@@ -108,10 +113,7 @@ export class CoffeeCompiler extends CachingCompiler {
}
}
return addSharedHeader(stripExportedVars(
output.js,
inputFile.getDeclaredExports().map(e => e.name)
), sourceMap);
return addSharedHeader(output.js, sourceMap);
}
addCompileResult(inputFile, sourceWithMap) {