From f749871edc37f3026ffb527fdff3ba0fe222e99f Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 4 Dec 2016 13:56:31 -0800 Subject: [PATCH 1/4] Use CoffeeScript 1.12.0 --- .../.npm/plugin/compileCoffeescript/npm-shrinkwrap.json | 6 +++--- packages/coffeescript/package.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/coffeescript/.npm/plugin/compileCoffeescript/npm-shrinkwrap.json b/packages/coffeescript/.npm/plugin/compileCoffeescript/npm-shrinkwrap.json index e00e5397ac..3c9553c754 100644 --- a/packages/coffeescript/.npm/plugin/compileCoffeescript/npm-shrinkwrap.json +++ b/packages/coffeescript/.npm/plugin/compileCoffeescript/npm-shrinkwrap.json @@ -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", diff --git a/packages/coffeescript/package.js b/packages/coffeescript/package.js index c35ad69cea..7aa305b453 100644 --- a/packages/coffeescript/package.js +++ b/packages/coffeescript/package.js @@ -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" } }); From f4dbab623ba45dfb903c1de3a446d79426630ecf Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 4 Dec 2016 14:20:46 -0800 Subject: [PATCH 2/4] Always pass through the coffee compiler output through ecmascript; the opt-in ES2015+ features are too varied to detect now in CoffeeScript 1.12.0+ --- .../plugin/compile-coffeescript.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/coffeescript/plugin/compile-coffeescript.js b/packages/coffeescript/plugin/compile-coffeescript.js index 85a41c8cda..5e032f69fa 100644 --- a/packages/coffeescript/plugin/compile-coffeescript.js +++ b/packages/coffeescript/plugin/compile-coffeescript.js @@ -88,29 +88,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 they’re 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. } } From 3326388d487980e1e85b4e81d50cd5b804077c1a Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Mon, 5 Dec 2016 18:51:35 -0800 Subject: [PATCH 3/4] Enable Babel cache for CoffeeScript compiler --- packages/coffeescript/plugin/compile-coffeescript.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/coffeescript/plugin/compile-coffeescript.js b/packages/coffeescript/plugin/compile-coffeescript.js index 5e032f69fa..28dfa152ce 100644 --- a/packages/coffeescript/plugin/compile-coffeescript.js +++ b/packages/coffeescript/plugin/compile-coffeescript.js @@ -65,6 +65,10 @@ export class CoffeeCompiler extends CachingCompiler { ]; } + setDiskCacheDirectory(cacheDir) { + this.babelCompiler.setDiskCacheDirectory(cacheDir); + } + compileOneFile(inputFile) { const source = inputFile.getContentsAsString(); const compileOptions = this._getCompileOptions(inputFile); From a90e4ee8367b59fe48537aac594cdd2877a874e6 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 6 Dec 2016 19:13:47 -0500 Subject: [PATCH 4/4] Call super.setDiskCacheDirectory to fix coffeescript cache tests. --- packages/coffeescript/plugin/compile-coffeescript.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/coffeescript/plugin/compile-coffeescript.js b/packages/coffeescript/plugin/compile-coffeescript.js index 28dfa152ce..c51b51b58b 100644 --- a/packages/coffeescript/plugin/compile-coffeescript.js +++ b/packages/coffeescript/plugin/compile-coffeescript.js @@ -67,6 +67,7 @@ export class CoffeeCompiler extends CachingCompiler { setDiskCacheDirectory(cacheDir) { this.babelCompiler.setDiskCacheDirectory(cacheDir); + return super.setDiskCacheDirectory(cacheDir); } compileOneFile(inputFile) {