Sha256: 0c446d33ac69381935837662850143ba363f1007af24860e04d0217147880e07

Contents?: true

Size: 1.82 KB

Versions: 62

Compression:

Stored size: 1.82 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var coffee = require("coffee-script");
var loaderUtils = require("loader-utils");
module.exports = function(source) {
	this.cacheable && this.cacheable();
	var coffeeRequest = loaderUtils.getRemainingRequest(this);
	var jsRequest = loaderUtils.getCurrentRequest(this);
	var query = loaderUtils.parseQuery(this.query);
	var result;
	try {
		result = coffee.compile(source, {
			literate: query.literate,
			filename: coffeeRequest,
			debug: this.debug,
			bare: true,
			sourceMap: true,
			sourceRoot: "",
			sourceFiles: [coffeeRequest],
			generatedFile: jsRequest
		});
	} catch (e) {
		var err = "";
		if (e.location == null || e.location.first_column == null || e.location.first_line == null) {
			err += "Got an unexpected exception from the coffee-script compiler. The original exception was: " + e + "\n";
			err += "(The coffee-script compiler should not raise *unexpected* exceptions. You can file this error as an issue of the coffee-script compiler: https://github.com/jashkenas/coffee-script/issues)\n";
		} else {
			var codeLine = source.split("\n")[e.location.first_line];
			var offendingCharacter = (e.location.first_column < codeLine.length) ? codeLine[e.location.first_column] : "";
			err += e + "\n";
			// log erroneous line and highlight offending character
			err += "    L" + e.location.first_line + ": " + codeLine.substring(0, e.location.first_column) + offendingCharacter + codeLine.substring(e.location.first_column + 1) + "\n";
			err += "         " + (new Array(e.location.first_column + 1).join(" ")) + "^\n";
		}
		throw new Error(err);
	}
	var map = JSON.parse(result.v3SourceMap);
	map.sourcesContent = [source];
	this.callback(null, result.js, map);
}
module.exports.seperable = true;

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
smock-0.1.268 node_modules/coffee-loader/index.js
smock-0.1.267 node_modules/coffee-loader/index.js
smock-0.1.266 node_modules/coffee-loader/index.js
smock-0.1.265 node_modules/coffee-loader/index.js
smock-0.1.264 node_modules/coffee-loader/index.js
smock-0.1.263 node_modules/coffee-loader/index.js
smock-0.1.262 node_modules/coffee-loader/index.js
smock-0.1.261 node_modules/coffee-loader/index.js
smock-0.1.260 node_modules/coffee-loader/index.js
smock-0.1.259 node_modules/coffee-loader/index.js
smock-0.1.258 node_modules/coffee-loader/index.js
smock-0.1.256 node_modules/coffee-loader/index.js
smock-0.1.255 node_modules/coffee-loader/index.js
smock-0.1.254 node_modules/coffee-loader/index.js
smock-0.1.253 node_modules/coffee-loader/index.js
smock-0.1.252 node_modules/coffee-loader/index.js
smock-0.1.251 node_modules/coffee-loader/index.js
smock-0.1.250 node_modules/coffee-loader/index.js
smock-0.1.249 node_modules/coffee-loader/index.js
smock-0.1.247 node_modules/coffee-loader/index.js