description and source-codefunction loader(contents) {
this.cacheable && this.cacheable();
var callback = this.async();
var options = getLoaderOptions(this);
var _a = instances.getTypeScriptInstance(options, this), instance = _a.instance, error = _a.error;
if (error) {
callback(error);
return;
}
var rawFilePath = path.normalize(this.resourcePath);
var filePath = utils.appendTsSuffixIfMatch(options.appendTsSuffixTo, rawFilePath);
var fileVersion = updateFileInCache(filePath, contents, instance);
var _b = options.transpileOnly
? getTranspilationEmit(filePath, contents, instance, this)
: getEmit(rawFilePath, filePath, instance, this), outputText = _b.outputText, sourceMapText = _b.sourceMapText;
if (outputText === null || outputText === undefined) {
var additionalGuidance = filePath.indexOf('node_modules') !== -1
? "\nYou should not need to recompile .ts files in node_modules.\nPlease contact the package author to advise them to
use --declaration --outDir.\nMore https://github.com/Microsoft/TypeScript/issues/12358"
: "";
throw new Error("Typescript emitted no output for " + filePath + "." + additionalGuidance);
}
var _c = makeSourceMap(sourceMapText, outputText, filePath, contents, this), sourceMap = _c.sourceMap, output = _c.output;
// Make sure webpack is aware that even though the emitted JavaScript may be the same as
// a previously cached version the TypeScript may be different and therefore should be
// treated as new
this._module.meta.tsLoaderFileVersion = fileVersion;
callback(null, output, sourceMap);
}