mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #8133 from GeoffreyBooth/coffeescript-1.12.0
Use CoffeeScript 1.12.0
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 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.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user