Merge pull request #8133 from GeoffreyBooth/coffeescript-1.12.0

Use CoffeeScript 1.12.0
This commit is contained in:
Ben Newman
2016-12-06 20:32:26 -05:00
committed by GitHub
3 changed files with 31 additions and 26 deletions

View File

@@ -1,9 +1,9 @@
{
"dependencies": {
"coffee-script": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.11.1.tgz",
"from": "coffee-script@1.11.1"
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.0.tgz",
"from": "coffee-script@1.12.0"
},
"source-map": {
"version": "0.5.6",

View File

@@ -1,6 +1,6 @@
Package.describe({
summary: "Javascript dialect with fewer braces and semicolons",
version: "1.11.1_4"
version: "1.12.0_1"
});
Package.registerBuildPlugin({
@@ -8,7 +8,7 @@ Package.registerBuildPlugin({
use: ['caching-compiler', 'ecmascript'],
sources: ['plugin/compile-coffeescript.js'],
npmDependencies: {
"coffee-script": "1.11.1",
"coffee-script": "1.12.0",
"source-map": "0.5.6"
}
});

View File

@@ -65,6 +65,11 @@ export class CoffeeCompiler extends CachingCompiler {
];
}
setDiskCacheDirectory(cacheDir) {
this.babelCompiler.setDiskCacheDirectory(cacheDir);
return super.setDiskCacheDirectory(cacheDir);
}
compileOneFile(inputFile) {
const source = inputFile.getContentsAsString();
const compileOptions = this._getCompileOptions(inputFile);
@@ -88,29 +93,29 @@ export class CoffeeCompiler extends CachingCompiler {
inputFile.getDeclaredExports().map(e => e.name)
);
if (/`|\b(?:import|export|yield)\b/.test(source)) {
// If source contains backticks or features that output as ES2015+,
// pass the coffee output through babel-compiler
const doubleRoastedCoffee =
this.babelCompiler.processOneFileForTarget(inputFile, output.js);
// CoffeeScript contains a handful of features that output as ES2015+,
// such as modules, generator functions, for…of, and tagged template
// literals. Because theyre too varied to detect, pass all CoffeeScript
// compiler output through the Babel compiler.
const doubleRoastedCoffee =
this.babelCompiler.processOneFileForTarget(inputFile, output.js);
if (doubleRoastedCoffee != null &&
doubleRoastedCoffee.data != null) {
output.js = doubleRoastedCoffee.data;
if (doubleRoastedCoffee != null &&
doubleRoastedCoffee.data != null) {
output.js = doubleRoastedCoffee.data;
if (doubleRoastedCoffee.sourceMap) {
// Combine the original CoffeeScript source map with the one
// produced by this.babelCompiler.processOneFileForTarget.
const smg = new SourceMapGenerator(
new SourceMapConsumer(doubleRoastedCoffee.sourceMap));
smg.applySourceMap(new SourceMapConsumer(sourceMap));
sourceMap = smg.toJSON();
} else {
// If the .coffee file is contained by a node_modules directory,
// then BabelCompiler will not transpile it, and there will be
// no sourceMap, but that's fine because the original
// CoffeeScript sourceMap will still be valid.
}
if (doubleRoastedCoffee.sourceMap) {
// Combine the original CoffeeScript source map with the one
// produced by this.babelCompiler.processOneFileForTarget.
const smg = new SourceMapGenerator(
new SourceMapConsumer(doubleRoastedCoffee.sourceMap));
smg.applySourceMap(new SourceMapConsumer(sourceMap));
sourceMap = smg.toJSON();
} else {
// If the .coffee file is contained by a node_modules directory,
// then BabelCompiler will not transpile it, and there will be
// no sourceMap, but that's fine because the original
// CoffeeScript sourceMap will still be valid.
}
}