aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ts-loader/dist
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ts-loader/dist')
-rw-r--r--node_modules/ts-loader/dist/after-compile.js147
-rw-r--r--node_modules/ts-loader/dist/compilerSetup.js52
-rw-r--r--node_modules/ts-loader/dist/config.js77
-rw-r--r--node_modules/ts-loader/dist/constants.js17
-rw-r--r--node_modules/ts-loader/dist/index.js155
-rw-r--r--node_modules/ts-loader/dist/instances.js87
-rw-r--r--node_modules/ts-loader/dist/interfaces.js2
-rw-r--r--node_modules/ts-loader/dist/logger.js75
-rw-r--r--node_modules/ts-loader/dist/resolver.js6
-rw-r--r--node_modules/ts-loader/dist/servicesHost.js108
-rw-r--r--node_modules/ts-loader/dist/utils.js123
-rw-r--r--node_modules/ts-loader/dist/watch-run.js38
12 files changed, 887 insertions, 0 deletions
diff --git a/node_modules/ts-loader/dist/after-compile.js b/node_modules/ts-loader/dist/after-compile.js
new file mode 100644
index 000000000..7c8cb7ef8
--- /dev/null
+++ b/node_modules/ts-loader/dist/after-compile.js
@@ -0,0 +1,147 @@
+"use strict";
+var path = require("path");
+var utils = require("./utils");
+var constants = require("./constants");
+function makeAfterCompile(instance, configFilePath) {
+ var getCompilerOptionDiagnostics = true;
+ var checkAllFilesForErrors = true;
+ return function (compilation, callback) {
+ // Don't add errors for child compilations
+ if (compilation.compiler.isChild()) {
+ callback();
+ return;
+ }
+ removeTSLoaderErrors(compilation.errors);
+ provideCompilerOptionDiagnosticErrorsToWebpack(getCompilerOptionDiagnostics, compilation, instance, configFilePath);
+ getCompilerOptionDiagnostics = false;
+ var modules = determineModules(compilation);
+ var filesToCheckForErrors = determineFilesToCheckForErrors(checkAllFilesForErrors, instance);
+ checkAllFilesForErrors = false;
+ var filesWithErrors = {};
+ provideErrorsToWebpack(filesToCheckForErrors, filesWithErrors, compilation, modules, instance);
+ provideDeclarationFilesToWebpack(filesToCheckForErrors, instance.languageService, compilation);
+ instance.filesWithErrors = filesWithErrors;
+ instance.modifiedFiles = null;
+ callback();
+ };
+}
+/**
+ * handle compiler option errors after the first compile
+ */
+function provideCompilerOptionDiagnosticErrorsToWebpack(getCompilerOptionDiagnostics, compilation, instance, configFilePath) {
+ if (getCompilerOptionDiagnostics) {
+ var languageService = instance.languageService, loaderOptions = instance.loaderOptions, compiler = instance.compiler;
+ utils.registerWebpackErrors(compilation.errors, utils.formatErrors(languageService.getCompilerOptionsDiagnostics(), loaderOptions, compiler, { file: configFilePath || 'tsconfig.json' }));
+ }
+}
+/**
+ * build map of all modules based on normalized filename
+ * this is used for quick-lookup when trying to find modules
+ * based on filepath
+ */
+function determineModules(compilation) {
+ var modules = {};
+ compilation.modules.forEach(function (module) {
+ if (module.resource) {
+ var modulePath = path.normalize(module.resource);
+ if (utils.hasOwnProperty(modules, modulePath)) {
+ var existingModules = modules[modulePath];
+ if (existingModules.indexOf(module) === -1) {
+ existingModules.push(module);
+ }
+ }
+ else {
+ modules[modulePath] = [module];
+ }
+ }
+ });
+ return modules;
+}
+function determineFilesToCheckForErrors(checkAllFilesForErrors, instance) {
+ var files = instance.files, modifiedFiles = instance.modifiedFiles, filesWithErrors = instance.filesWithErrors;
+ // calculate array of files to check
+ var filesToCheckForErrors = {};
+ if (checkAllFilesForErrors) {
+ // check all files on initial run
+ filesToCheckForErrors = files;
+ }
+ else if (modifiedFiles) {
+ // check all modified files, and all dependants
+ Object.keys(modifiedFiles).forEach(function (modifiedFileName) {
+ utils.collectAllDependants(instance.reverseDependencyGraph, modifiedFileName)
+ .forEach(function (fileName) {
+ filesToCheckForErrors[fileName] = files[fileName];
+ });
+ });
+ }
+ // re-check files with errors from previous build
+ if (filesWithErrors) {
+ Object.keys(filesWithErrors).forEach(function (fileWithErrorName) {
+ return filesToCheckForErrors[fileWithErrorName] = filesWithErrors[fileWithErrorName];
+ });
+ }
+ return filesToCheckForErrors;
+}
+function provideErrorsToWebpack(filesToCheckForErrors, filesWithErrors, compilation, modules, instance) {
+ var compiler = instance.compiler, languageService = instance.languageService, files = instance.files, loaderOptions = instance.loaderOptions;
+ Object.keys(filesToCheckForErrors)
+ .filter(function (filePath) { return !!filePath.match(constants.dtsTsTsxRegex); })
+ .forEach(function (filePath) {
+ var errors = languageService.getSyntacticDiagnostics(filePath).concat(languageService.getSemanticDiagnostics(filePath));
+ if (errors.length > 0) {
+ filesWithErrors[filePath] = files[filePath];
+ }
+ // if we have access to a webpack module, use that
+ if (utils.hasOwnProperty(modules, filePath)) {
+ var associatedModules = modules[filePath];
+ associatedModules.forEach(function (module) {
+ // remove any existing errors
+ removeTSLoaderErrors(module.errors);
+ // append errors
+ var formattedErrors = utils.formatErrors(errors, loaderOptions, compiler, { module: module });
+ utils.registerWebpackErrors(module.errors, formattedErrors);
+ utils.registerWebpackErrors(compilation.errors, formattedErrors);
+ });
+ }
+ else {
+ // otherwise it's a more generic error
+ utils.registerWebpackErrors(compilation.errors, utils.formatErrors(errors, loaderOptions, compiler, { file: filePath }));
+ }
+ });
+}
+/**
+ * gather all declaration files from TypeScript and output them to webpack
+ */
+function provideDeclarationFilesToWebpack(filesToCheckForErrors, languageService, compilation) {
+ Object.keys(filesToCheckForErrors)
+ .filter(function (filePath) { return !!filePath.match(constants.tsTsxRegex); })
+ .forEach(function (filePath) {
+ var output = languageService.getEmitOutput(filePath);
+ var declarationFile = output.outputFiles.filter(function (outputFile) { return !!outputFile.name.match(constants.dtsDtsxRegex); }).pop();
+ if (declarationFile) {
+ var assetPath = path.relative(compilation.compiler.context, declarationFile.name);
+ compilation.assets[assetPath] = {
+ source: function () { return declarationFile.text; },
+ size: function () { return declarationFile.text.length; },
+ };
+ }
+ });
+}
+/**
+ * handle all other errors. The basic approach here to get accurate error
+ * reporting is to start with a "blank slate" each compilation and gather
+ * all errors from all files. Since webpack tracks errors in a module from
+ * compilation-to-compilation, and since not every module always runs through
+ * the loader, we need to detect and remove any pre-existing errors.
+ */
+function removeTSLoaderErrors(errors) {
+ var index = -1;
+ var length = errors.length;
+ while (++index < length) {
+ if (errors[index].loaderSource === 'ts-loader') {
+ errors.splice(index--, 1);
+ length--;
+ }
+ }
+}
+module.exports = makeAfterCompile;
diff --git a/node_modules/ts-loader/dist/compilerSetup.js b/node_modules/ts-loader/dist/compilerSetup.js
new file mode 100644
index 000000000..6b456f100
--- /dev/null
+++ b/node_modules/ts-loader/dist/compilerSetup.js
@@ -0,0 +1,52 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var semver = require('semver');
+var constants = require("./constants");
+function getCompiler(loaderOptions, log) {
+ var compiler;
+ var errorMessage;
+ var compilerDetailsLogMessage;
+ var compilerCompatible = false;
+ try {
+ compiler = require(loaderOptions.compiler);
+ }
+ catch (e) {
+ errorMessage = loaderOptions.compiler === 'typescript'
+ ? 'Could not load TypeScript. Try installing with `npm install typescript`. If TypeScript is installed globally, try using `npm link typescript`.'
+ : "Could not load TypeScript compiler with NPM package name `" + loaderOptions.compiler + "`. Are you sure it is correctly installed?";
+ }
+ if (!errorMessage) {
+ compilerDetailsLogMessage = "ts-loader: Using " + loaderOptions.compiler + "@" + compiler.version;
+ compilerCompatible = false;
+ if (loaderOptions.compiler === 'typescript') {
+ if (compiler.version && semver.gte(compiler.version, '1.6.2-0')) {
+ // don't log yet in this case, if a tsconfig.json exists we want to combine the message
+ compilerCompatible = true;
+ }
+ else {
+ log.logError((compilerDetailsLogMessage + ". This version is incompatible with ts-loader. Please upgrade to the latest version of TypeScript.").red);
+ }
+ }
+ else {
+ log.logWarning((compilerDetailsLogMessage + ". This version may or may not be compatible with ts-loader.").yellow);
+ }
+ }
+ return { compiler: compiler, compilerCompatible: compilerCompatible, compilerDetailsLogMessage: compilerDetailsLogMessage, errorMessage: errorMessage };
+}
+exports.getCompiler = getCompiler;
+function getCompilerOptions(compilerCompatible, compiler, configParseResult) {
+ var compilerOptions = Object.assign({}, configParseResult.options, {
+ skipDefaultLibCheck: true,
+ suppressOutputPathCheck: true,
+ });
+ // if `module` is not specified and not using ES6 target, default to CJS module output
+ if ((!compilerOptions.module) && compilerOptions.target !== constants.ScriptTargetES2015) {
+ compilerOptions.module = constants.ModuleKindCommonJs;
+ }
+ else if (compilerCompatible && semver.lt(compiler.version, '1.7.3-0') && compilerOptions.target === constants.ScriptTargetES2015) {
+ // special handling for TS 1.6 and target: es6
+ compilerOptions.module = constants.ModuleKindNone;
+ }
+ return compilerOptions;
+}
+exports.getCompilerOptions = getCompilerOptions;
diff --git a/node_modules/ts-loader/dist/config.js b/node_modules/ts-loader/dist/config.js
new file mode 100644
index 000000000..9c74f89ba
--- /dev/null
+++ b/node_modules/ts-loader/dist/config.js
@@ -0,0 +1,77 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var path = require("path");
+var utils = require("./utils");
+function getConfigFile(compiler, loader, loaderOptions, compilerCompatible, log, compilerDetailsLogMessage) {
+ var configFilePath = findConfigFile(compiler, path.dirname(loader.resourcePath), loaderOptions.configFileName);
+ var configFileError;
+ var configFile;
+ if (configFilePath) {
+ if (compilerCompatible) {
+ log.logInfo((compilerDetailsLogMessage + " and " + configFilePath).green);
+ }
+ else {
+ log.logInfo(("ts-loader: Using config file at " + configFilePath).green);
+ }
+ // HACK: relies on the fact that passing an extra argument won't break
+ // the old API that has a single parameter
+ configFile = compiler.readConfigFile(configFilePath, compiler.sys.readFile);
+ if (configFile.error) {
+ configFileError = utils.formatErrors([configFile.error], loaderOptions, compiler, { file: configFilePath })[0];
+ }
+ }
+ else {
+ if (compilerCompatible) {
+ log.logInfo(compilerDetailsLogMessage.green);
+ }
+ configFile = {
+ config: {
+ compilerOptions: {},
+ files: [],
+ },
+ };
+ }
+ if (!configFileError) {
+ configFile.config.compilerOptions = Object.assign({}, configFile.config.compilerOptions, loaderOptions.compilerOptions);
+ // do any necessary config massaging
+ if (loaderOptions.transpileOnly) {
+ configFile.config.compilerOptions.isolatedModules = true;
+ }
+ }
+ return {
+ configFilePath: configFilePath,
+ configFile: configFile,
+ configFileError: configFileError
+ };
+}
+exports.getConfigFile = getConfigFile;
+/**
+ * The tsconfig.json is found using the same method as `tsc`, starting in the current directory
+ * and continuing up the parent directory chain.
+ */
+function findConfigFile(compiler, searchPath, configFileName) {
+ while (true) {
+ var fileName = path.join(searchPath, configFileName);
+ if (compiler.sys.fileExists(fileName)) {
+ return fileName;
+ }
+ var parentPath = path.dirname(searchPath);
+ if (parentPath === searchPath) {
+ break;
+ }
+ searchPath = parentPath;
+ }
+ return undefined;
+}
+function getConfigParseResult(compiler, configFile, configFilePath) {
+ var configParseResult;
+ if (typeof compiler.parseJsonConfigFileContent === 'function') {
+ // parseConfigFile was renamed between 1.6.2 and 1.7
+ configParseResult = compiler.parseJsonConfigFileContent(configFile.config, compiler.sys, path.dirname(configFilePath || ''));
+ }
+ else {
+ configParseResult = compiler.parseConfigFile(configFile.config, compiler.sys, path.dirname(configFilePath || ''));
+ }
+ return configParseResult;
+}
+exports.getConfigParseResult = getConfigParseResult;
diff --git a/node_modules/ts-loader/dist/constants.js b/node_modules/ts-loader/dist/constants.js
new file mode 100644
index 000000000..e97cf0e4c
--- /dev/null
+++ b/node_modules/ts-loader/dist/constants.js
@@ -0,0 +1,17 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var os = require("os");
+exports.EOL = os.EOL;
+exports.CarriageReturnLineFeed = '\r\n';
+exports.LineFeed = '\n';
+exports.CarriageReturnLineFeedCode = 0;
+exports.LineFeedCode = 1;
+exports.ScriptTargetES2015 = 2;
+exports.ModuleKindNone = 0;
+exports.ModuleKindCommonJs = 1;
+exports.tsTsxRegex = /\.ts(x?)$/i;
+exports.dtsDtsxRegex = /\.d\.ts(x?)$/i;
+exports.dtsTsTsxRegex = /(\.d)?\.ts(x?)$/i;
+exports.tsTsxJsJsxRegex = /\.tsx?$|\.jsx?$/i;
+exports.jsJsx = /\.js(x?)$/i;
+exports.jsJsxMap = /\.js(x?)\.map$/i;
diff --git a/node_modules/ts-loader/dist/index.js b/node_modules/ts-loader/dist/index.js
new file mode 100644
index 000000000..335c1b190
--- /dev/null
+++ b/node_modules/ts-loader/dist/index.js
@@ -0,0 +1,155 @@
+"use strict";
+var path = require("path");
+var loaderUtils = require("loader-utils");
+require('colors');
+var instances = require("./instances");
+var utils = require("./utils");
+var constants = require("./constants");
+var webpackInstances = [];
+var loaderOptionsCache = {};
+/**
+ * The entry point for ts-loader
+ */
+function 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);
+}
+/**
+ * either retrieves loader options from the cache
+ * or creates them, adds them to the cache and returns
+ */
+function getLoaderOptions(loader) {
+ // differentiate the TypeScript instance based on the webpack instance
+ var webpackIndex = webpackInstances.indexOf(loader._compiler);
+ if (webpackIndex === -1) {
+ webpackIndex = webpackInstances.push(loader._compiler) - 1;
+ }
+ var queryOptions = loaderUtils.getOptions(loader) || {};
+ var configFileOptions = loader.options.ts || {};
+ var instanceName = webpackIndex + '_' + (queryOptions.instance || configFileOptions.instance || 'default');
+ if (utils.hasOwnProperty(loaderOptionsCache, instanceName)) {
+ return loaderOptionsCache[instanceName];
+ }
+ var options = Object.assign({}, {
+ silent: false,
+ logLevel: 'INFO',
+ logInfoToStdOut: false,
+ compiler: 'typescript',
+ configFileName: 'tsconfig.json',
+ transpileOnly: false,
+ visualStudioErrorFormat: false,
+ compilerOptions: {},
+ appendTsSuffixTo: [],
+ entryFileIsJs: false,
+ }, configFileOptions, queryOptions);
+ options.ignoreDiagnostics = utils.arrify(options.ignoreDiagnostics).map(Number);
+ options.logLevel = options.logLevel.toUpperCase();
+ options.instance = instanceName;
+ loaderOptionsCache[instanceName] = options;
+ return options;
+}
+/**
+ * Either add file to the overall files cache or update it in the cache when the file contents have changed
+ * Also add the file to the modified files
+ */
+function updateFileInCache(filePath, contents, instance) {
+ // Update file contents
+ var file = instance.files[filePath];
+ if (!file) {
+ file = instance.files[filePath] = { version: 0 };
+ }
+ if (file.text !== contents) {
+ file.version++;
+ file.text = contents;
+ instance.version++;
+ }
+ // push this file to modified files hash.
+ if (!instance.modifiedFiles) {
+ instance.modifiedFiles = {};
+ }
+ instance.modifiedFiles[filePath] = file;
+ return file.version;
+}
+function getEmit(rawFilePath, filePath, instance, loader) {
+ // Emit Javascript
+ var output = instance.languageService.getEmitOutput(filePath);
+ loader.clearDependencies();
+ loader.addDependency(rawFilePath);
+ var allDefinitionFiles = Object.keys(instance.files).filter(function (defFilePath) { return !!defFilePath.match(constants.dtsDtsxRegex); });
+ // Make this file dependent on *all* definition files in the program
+ var addDependency = loader.addDependency.bind(loader);
+ allDefinitionFiles.forEach(addDependency);
+ /* - alternative approach to the below which is more correct but has a heavy performance cost
+ see https://github.com/TypeStrong/ts-loader/issues/393
+ with this approach constEnumReExportWatch test will pass; without it, not.
+
+ // Additionally make this file dependent on all imported files as well
+ // as any deeper recursive dependencies
+ const additionalDependencies = utils.collectAllDependencies(instance.dependencyGraph, filePath);
+ */
+ // Additionally make this file dependent on all imported files
+ var additionalDependencies = instance.dependencyGraph[filePath]
+ && instance.dependencyGraph[filePath].map(function (module) { return module.originalFileName; });
+ if (additionalDependencies) {
+ additionalDependencies.forEach(addDependency);
+ }
+ loader._module.meta.tsLoaderDefinitionFileVersions = allDefinitionFiles
+ .concat(additionalDependencies)
+ .map(function (defFilePath) { return defFilePath + '@' + (instance.files[defFilePath] || { version: '?' }).version; });
+ var outputFile = output.outputFiles.filter(function (outputFile) { return !!outputFile.name.match(constants.jsJsx); }).pop();
+ var outputText = (outputFile) ? outputFile.text : undefined;
+ var sourceMapFile = output.outputFiles.filter(function (outputFile) { return !!outputFile.name.match(constants.jsJsxMap); }).pop();
+ var sourceMapText = (sourceMapFile) ? sourceMapFile.text : undefined;
+ return { outputText: outputText, sourceMapText: sourceMapText };
+}
+/**
+ * Transpile file
+ */
+function getTranspilationEmit(filePath, contents, instance, loader) {
+ var fileName = path.basename(filePath);
+ var _a = instance.compiler.transpileModule(contents, {
+ compilerOptions: instance.compilerOptions,
+ reportDiagnostics: true,
+ fileName: fileName,
+ }), outputText = _a.outputText, sourceMapText = _a.sourceMapText, diagnostics = _a.diagnostics;
+ utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, instance.loaderOptions, instance.compiler, { module: loader._module }));
+ return { outputText: outputText, sourceMapText: sourceMapText };
+}
+function makeSourceMap(sourceMapText, outputText, filePath, contents, loader) {
+ if (!sourceMapText) {
+ return { output: outputText, sourceMap: undefined };
+ }
+ return {
+ output: outputText.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''),
+ sourceMap: Object.assign(JSON.parse(sourceMapText), {
+ sources: [loaderUtils.getRemainingRequest(loader)],
+ file: filePath,
+ sourcesContent: [contents]
+ })
+ };
+}
+module.exports = loader;
diff --git a/node_modules/ts-loader/dist/instances.js b/node_modules/ts-loader/dist/instances.js
new file mode 100644
index 000000000..fc9c13cc5
--- /dev/null
+++ b/node_modules/ts-loader/dist/instances.js
@@ -0,0 +1,87 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var path = require("path");
+var fs = require("fs");
+require('colors');
+var afterCompile = require("./after-compile");
+var config = require("./config");
+var compilerSetup = require("./compilerSetup");
+var utils = require("./utils");
+var logger = require("./logger");
+var makeServicesHost = require("./servicesHost");
+var watchRun = require("./watch-run");
+var instances = {};
+/**
+ * The loader is executed once for each file seen by webpack. However, we need to keep
+ * a persistent instance of TypeScript that contains all of the files in the program
+ * along with definition files and options. This function either creates an instance
+ * or returns the existing one. Multiple instances are possible by using the
+ * `instance` property.
+ */
+function getTypeScriptInstance(loaderOptions, loader) {
+ if (utils.hasOwnProperty(instances, loaderOptions.instance)) {
+ return { instance: instances[loaderOptions.instance] };
+ }
+ var log = logger.makeLogger(loaderOptions);
+ var _a = compilerSetup.getCompiler(loaderOptions, log), compiler = _a.compiler, compilerCompatible = _a.compilerCompatible, compilerDetailsLogMessage = _a.compilerDetailsLogMessage, errorMessage = _a.errorMessage;
+ if (errorMessage) {
+ return { error: utils.makeError({ rawMessage: errorMessage }) };
+ }
+ var _b = config.getConfigFile(compiler, loader, loaderOptions, compilerCompatible, log, compilerDetailsLogMessage), configFilePath = _b.configFilePath, configFile = _b.configFile, configFileError = _b.configFileError;
+ if (configFileError) {
+ return { error: configFileError };
+ }
+ var configParseResult = config.getConfigParseResult(compiler, configFile, configFilePath);
+ if (configParseResult.errors.length) {
+ utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(configParseResult.errors, loaderOptions, compiler, { file: configFilePath }));
+ return { error: utils.makeError({ rawMessage: 'error while parsing tsconfig.json', file: configFilePath }) };
+ }
+ var compilerOptions = compilerSetup.getCompilerOptions(compilerCompatible, compiler, configParseResult);
+ var files = {};
+ if (loaderOptions.transpileOnly) {
+ // quick return for transpiling
+ // we do need to check for any issues with TS options though
+ var program = compiler.createProgram([], compilerOptions);
+ var diagnostics = program.getOptionsDiagnostics();
+ utils.registerWebpackErrors(loader._module.errors, utils.formatErrors(diagnostics, loaderOptions, compiler, { file: configFilePath || 'tsconfig.json' }));
+ return { instance: instances[loaderOptions.instance] = { compiler: compiler, compilerOptions: compilerOptions, loaderOptions: loaderOptions, files: files, dependencyGraph: {}, reverseDependencyGraph: {} } };
+ }
+ // Load initial files (core lib files, any files specified in tsconfig.json)
+ var normalizedFilePath;
+ try {
+ var filesToLoad = configParseResult.fileNames;
+ filesToLoad.forEach(function (filePath) {
+ normalizedFilePath = path.normalize(filePath);
+ files[normalizedFilePath] = {
+ text: fs.readFileSync(normalizedFilePath, 'utf-8'),
+ version: 0
+ };
+ });
+ }
+ catch (exc) {
+ return { error: utils.makeError({
+ rawMessage: "A file specified in tsconfig.json could not be found: " + normalizedFilePath
+ }) };
+ }
+ // if allowJs is set then we should accept js(x) files
+ var scriptRegex = configParseResult.options.allowJs && loaderOptions.entryFileIsJs
+ ? /\.tsx?$|\.jsx?$/i
+ : /\.tsx?$/i;
+ var instance = instances[loaderOptions.instance] = {
+ compiler: compiler,
+ compilerOptions: compilerOptions,
+ loaderOptions: loaderOptions,
+ files: files,
+ languageService: null,
+ version: 0,
+ dependencyGraph: {},
+ reverseDependencyGraph: {},
+ modifiedFiles: null,
+ };
+ var servicesHost = makeServicesHost(scriptRegex, log, loader, instance, loaderOptions.appendTsSuffixTo);
+ instance.languageService = compiler.createLanguageService(servicesHost, compiler.createDocumentRegistry());
+ loader._compiler.plugin("after-compile", afterCompile(instance, configFilePath));
+ loader._compiler.plugin("watch-run", watchRun(instance));
+ return { instance: instance };
+}
+exports.getTypeScriptInstance = getTypeScriptInstance;
diff --git a/node_modules/ts-loader/dist/interfaces.js b/node_modules/ts-loader/dist/interfaces.js
new file mode 100644
index 000000000..c8ad2e549
--- /dev/null
+++ b/node_modules/ts-loader/dist/interfaces.js
@@ -0,0 +1,2 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/node_modules/ts-loader/dist/logger.js b/node_modules/ts-loader/dist/logger.js
new file mode 100644
index 000000000..821e4f9ba
--- /dev/null
+++ b/node_modules/ts-loader/dist/logger.js
@@ -0,0 +1,75 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var Console = require('console').Console;
+var stderrConsole = new Console(process.stderr);
+var stdoutConsole = new Console(process.stdout);
+var LogLevel;
+(function (LogLevel) {
+ LogLevel[LogLevel["INFO"] = 1] = "INFO";
+ LogLevel[LogLevel["WARN"] = 2] = "WARN";
+ LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
+})(LogLevel || (LogLevel = {}));
+var doNothingLogger = function () {
+ var _messages = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ _messages[_i] = arguments[_i];
+ }
+};
+function makeLoggerFunc(loaderOptions) {
+ return loaderOptions.silent
+ ? function (_whereToLog, _messages) { }
+ : function (whereToLog, messages) { return console.log.apply(whereToLog, messages); };
+}
+function makeExternalLogger(loaderOptions, logger) {
+ var output = loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole;
+ return function () {
+ var messages = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ messages[_i] = arguments[_i];
+ }
+ return logger(output, messages);
+ };
+}
+function makeLogInfo(loaderOptions, logger) {
+ return LogLevel[loaderOptions.logLevel] <= LogLevel.INFO
+ ? function () {
+ var messages = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ messages[_i] = arguments[_i];
+ }
+ return logger(loaderOptions.logInfoToStdOut ? stdoutConsole : stderrConsole, messages);
+ }
+ : doNothingLogger;
+}
+function makeLogError(loaderOptions, logger) {
+ return LogLevel[loaderOptions.logLevel] <= LogLevel.ERROR
+ ? function () {
+ var messages = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ messages[_i] = arguments[_i];
+ }
+ return logger(stderrConsole, messages);
+ }
+ : doNothingLogger;
+}
+function makeLogWarning(loaderOptions, logger) {
+ return LogLevel[loaderOptions.logLevel] <= LogLevel.WARN
+ ? function () {
+ var messages = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ messages[_i] = arguments[_i];
+ }
+ return logger(stderrConsole, messages);
+ }
+ : doNothingLogger;
+}
+function makeLogger(loaderOptions) {
+ var logger = makeLoggerFunc(loaderOptions);
+ return {
+ log: makeExternalLogger(loaderOptions, logger),
+ logInfo: makeLogInfo(loaderOptions, logger),
+ logWarning: makeLogWarning(loaderOptions, logger),
+ logError: makeLogError(loaderOptions, logger)
+ };
+}
+exports.makeLogger = makeLogger;
diff --git a/node_modules/ts-loader/dist/resolver.js b/node_modules/ts-loader/dist/resolver.js
new file mode 100644
index 000000000..8680bff1e
--- /dev/null
+++ b/node_modules/ts-loader/dist/resolver.js
@@ -0,0 +1,6 @@
+"use strict";
+var node = require("enhanced-resolve/lib/node");
+function makeResolver(options) {
+ return node.create.sync(options.resolve);
+}
+module.exports = makeResolver;
diff --git a/node_modules/ts-loader/dist/servicesHost.js b/node_modules/ts-loader/dist/servicesHost.js
new file mode 100644
index 000000000..2029801c2
--- /dev/null
+++ b/node_modules/ts-loader/dist/servicesHost.js
@@ -0,0 +1,108 @@
+"use strict";
+var constants = require("./constants");
+var path = require("path");
+var makeResolver = require("./resolver");
+var utils = require("./utils");
+/**
+ * Create the TypeScript language service
+ */
+function makeServicesHost(scriptRegex, log, loader, instance, appendTsSuffixTo) {
+ var compiler = instance.compiler, compilerOptions = instance.compilerOptions, files = instance.files;
+ var newLine = compilerOptions.newLine === constants.CarriageReturnLineFeedCode ? constants.CarriageReturnLineFeed :
+ compilerOptions.newLine === constants.LineFeedCode ? constants.LineFeed :
+ constants.EOL;
+ // make a (sync) resolver that follows webpack's rules
+ var resolveSync = makeResolver(loader.options);
+ var moduleResolutionHost = {
+ fileExists: function (fileName) { return utils.readFile(fileName) !== undefined; },
+ readFile: function (fileName) { return utils.readFile(fileName); },
+ };
+ return {
+ getProjectVersion: function () { return "" + instance.version; },
+ getScriptFileNames: function () { return Object.keys(files).filter(function (filePath) { return !!filePath.match(scriptRegex); }); },
+ getScriptVersion: function (fileName) {
+ fileName = path.normalize(fileName);
+ return files[fileName] && files[fileName].version.toString();
+ },
+ getScriptSnapshot: function (fileName) {
+ // This is called any time TypeScript needs a file's text
+ // We either load from memory or from disk
+ fileName = path.normalize(fileName);
+ var file = files[fileName];
+ if (!file) {
+ var text = utils.readFile(fileName);
+ if (!text) {
+ return undefined;
+ }
+ file = files[fileName] = { version: 0, text: text };
+ }
+ return compiler.ScriptSnapshot.fromString(file.text);
+ },
+ /**
+ * getDirectories is also required for full import and type reference completions.
+ * Without it defined, certain completions will not be provided
+ */
+ getDirectories: compiler.sys ? compiler.sys.getDirectories : undefined,
+ /**
+ * For @types expansion, these two functions are needed.
+ */
+ directoryExists: compiler.sys ? compiler.sys.directoryExists : undefined,
+ getCurrentDirectory: function () { return process.cwd(); },
+ getCompilationSettings: function () { return compilerOptions; },
+ getDefaultLibFileName: function (options) { return compiler.getDefaultLibFilePath(options); },
+ getNewLine: function () { return newLine; },
+ log: log.log,
+ resolveModuleNames: function (moduleNames, containingFile) {
+ return resolveModuleNames(resolveSync, moduleResolutionHost, appendTsSuffixTo, scriptRegex, instance, moduleNames, containingFile);
+ }
+ };
+}
+function resolveModuleNames(resolveSync, moduleResolutionHost, appendTsSuffixTo, scriptRegex, instance, moduleNames, containingFile) {
+ var resolvedModules = moduleNames.map(function (moduleName) {
+ return resolveModuleName(resolveSync, moduleResolutionHost, appendTsSuffixTo, scriptRegex, instance, moduleName, containingFile);
+ });
+ populateDependencyGraphs(resolvedModules, instance, containingFile);
+ return resolvedModules;
+}
+function resolveModuleName(resolveSync, moduleResolutionHost, appendTsSuffixTo, scriptRegex, instance, moduleName, containingFile) {
+ var compiler = instance.compiler, compilerOptions = instance.compilerOptions;
+ var resolutionResult;
+ try {
+ var originalFileName = resolveSync(undefined, path.normalize(path.dirname(containingFile)), moduleName);
+ var resolvedFileName = utils.appendTsSuffixIfMatch(appendTsSuffixTo, originalFileName);
+ if (resolvedFileName.match(scriptRegex)) {
+ resolutionResult = { resolvedFileName: resolvedFileName, originalFileName: originalFileName };
+ }
+ }
+ catch (e) { }
+ var tsResolution = compiler.resolveModuleName(moduleName, containingFile, compilerOptions, moduleResolutionHost);
+ if (tsResolution.resolvedModule) {
+ var resolvedFileName = path.normalize(tsResolution.resolvedModule.resolvedFileName);
+ var tsResolutionResult = {
+ originalFileName: resolvedFileName,
+ resolvedFileName: resolvedFileName,
+ isExternalLibraryImport: tsResolution.resolvedModule.isExternalLibraryImport
+ };
+ if (resolutionResult) {
+ if (resolutionResult.resolvedFileName === tsResolutionResult.resolvedFileName) {
+ resolutionResult.isExternalLibraryImport = tsResolutionResult.isExternalLibraryImport;
+ }
+ }
+ else {
+ resolutionResult = tsResolutionResult;
+ }
+ }
+ return resolutionResult;
+}
+function populateDependencyGraphs(resolvedModules, instance, containingFile) {
+ resolvedModules = resolvedModules
+ .filter(function (m) { return m !== null && m !== undefined; });
+ instance.dependencyGraph[path.normalize(containingFile)] = resolvedModules;
+ resolvedModules.forEach(function (resolvedModule) {
+ if (!instance.reverseDependencyGraph[resolvedModule.resolvedFileName]) {
+ instance.reverseDependencyGraph[resolvedModule.resolvedFileName] = {};
+ }
+ instance.reverseDependencyGraph[resolvedModule.resolvedFileName][path.normalize(containingFile)] = true;
+ });
+}
+module.exports = makeServicesHost;
diff --git a/node_modules/ts-loader/dist/utils.js b/node_modules/ts-loader/dist/utils.js
new file mode 100644
index 000000000..30292d942
--- /dev/null
+++ b/node_modules/ts-loader/dist/utils.js
@@ -0,0 +1,123 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+var path = require("path");
+var fs = require("fs");
+var constants = require("./constants");
+function registerWebpackErrors(existingErrors, errorsToPush) {
+ Array.prototype.splice.apply(existingErrors, [0, 0].concat(errorsToPush));
+}
+exports.registerWebpackErrors = registerWebpackErrors;
+function hasOwnProperty(obj, property) {
+ return Object.prototype.hasOwnProperty.call(obj, property);
+}
+exports.hasOwnProperty = hasOwnProperty;
+/**
+ * Take TypeScript errors, parse them and format to webpack errors
+ * Optionally adds a file name
+ */
+function formatErrors(diagnostics, loaderOptions, compiler, merge) {
+ return diagnostics
+ .filter(function (diagnostic) { return loaderOptions.ignoreDiagnostics.indexOf(diagnostic.code) === -1; })
+ .map(function (diagnostic) {
+ var errorCategory = compiler.DiagnosticCategory[diagnostic.category].toLowerCase();
+ var errorCategoryAndCode = errorCategory + ' TS' + diagnostic.code + ': ';
+ var messageText = errorCategoryAndCode + compiler.flattenDiagnosticMessageText(diagnostic.messageText, constants.EOL);
+ var error;
+ if (diagnostic.file) {
+ var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
+ var errorMessage = "" + '('.white + (lineChar.line + 1).toString().cyan + "," + (lineChar.character + 1).toString().cyan + "): " + messageText.red;
+ if (loaderOptions.visualStudioErrorFormat) {
+ errorMessage = path.normalize(diagnostic.file.fileName).red + errorMessage;
+ }
+ error = makeError({
+ message: errorMessage,
+ rawMessage: messageText,
+ location: { line: lineChar.line + 1, character: lineChar.character + 1 }
+ });
+ }
+ else {
+ error = makeError({ rawMessage: messageText });
+ }
+ return Object.assign(error, merge);
+ });
+}
+exports.formatErrors = formatErrors;
+function readFile(fileName) {
+ fileName = path.normalize(fileName);
+ try {
+ return fs.readFileSync(fileName, 'utf8');
+ }
+ catch (e) {
+ return undefined;
+ }
+}
+exports.readFile = readFile;
+function makeError(_a) {
+ var rawMessage = _a.rawMessage, message = _a.message, location = _a.location, file = _a.file;
+ var error = {
+ rawMessage: rawMessage,
+ message: message || "" + rawMessage.red,
+ loaderSource: 'ts-loader'
+ };
+ return Object.assign(error, { location: location, file: file });
+}
+exports.makeError = makeError;
+function appendTsSuffixIfMatch(patterns, path) {
+ if (patterns.length > 0) {
+ for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
+ var regexp = patterns_1[_i];
+ if (path.match(regexp)) {
+ return path + '.ts';
+ }
+ }
+ }
+ return path;
+}
+exports.appendTsSuffixIfMatch = appendTsSuffixIfMatch;
+/**
+ * Recursively collect all possible dependants of passed file
+ */
+function collectAllDependants(reverseDependencyGraph, fileName, collected) {
+ if (collected === void 0) { collected = {}; }
+ var result = {};
+ result[fileName] = true;
+ collected[fileName] = true;
+ if (reverseDependencyGraph[fileName]) {
+ Object.keys(reverseDependencyGraph[fileName]).forEach(function (dependantFileName) {
+ if (!collected[dependantFileName]) {
+ collectAllDependants(reverseDependencyGraph, dependantFileName, collected)
+ .forEach(function (fName) { return result[fName] = true; });
+ }
+ });
+ }
+ return Object.keys(result);
+}
+exports.collectAllDependants = collectAllDependants;
+/**
+ * Recursively collect all possible dependencies of passed file
+ */
+function collectAllDependencies(dependencyGraph, filePath, collected) {
+ if (collected === void 0) { collected = {}; }
+ var result = {};
+ result[filePath] = true;
+ collected[filePath] = true;
+ var directDependencies = dependencyGraph[filePath];
+ if (directDependencies) {
+ directDependencies.forEach(function (dependencyModule) {
+ if (!collected[dependencyModule.originalFileName]) {
+ collectAllDependencies(dependencyGraph, dependencyModule.resolvedFileName, collected)
+ .forEach(function (filePath) { return result[filePath] = true; });
+ }
+ });
+ }
+ return Object.keys(result);
+}
+exports.collectAllDependencies = collectAllDependencies;
+function arrify(val) {
+ if (val === null || val === undefined) {
+ return [];
+ }
+ return Array.isArray(val) ? val : [val];
+}
+exports.arrify = arrify;
+;
diff --git a/node_modules/ts-loader/dist/watch-run.js b/node_modules/ts-loader/dist/watch-run.js
new file mode 100644
index 000000000..7c96d796b
--- /dev/null
+++ b/node_modules/ts-loader/dist/watch-run.js
@@ -0,0 +1,38 @@
+"use strict";
+var path = require("path");
+var utils = require("./utils");
+var constants = require("./constants");
+/**
+ * Make function which will manually update changed files
+ */
+function makeWatchRun(instance) {
+ var lastTimes = {};
+ var startTime = null;
+ return function (watching, cb) {
+ var watcher = watching.compiler.watchFileSystem.watcher ||
+ watching.compiler.watchFileSystem.wfs.watcher;
+ if (null === instance.modifiedFiles) {
+ instance.modifiedFiles = {};
+ }
+ startTime = startTime || watching.startTime;
+ var times = watcher.getTimes();
+ Object.keys(times)
+ .filter(function (filePath) {
+ return times[filePath] > (lastTimes[filePath] || startTime)
+ && !!filePath.match(constants.tsTsxJsJsxRegex);
+ })
+ .forEach(function (filePath) {
+ lastTimes[filePath] = times[filePath];
+ filePath = path.normalize(filePath);
+ var file = instance.files[filePath];
+ if (file) {
+ file.text = utils.readFile(filePath) || '';
+ file.version++;
+ instance.version++;
+ instance.modifiedFiles[filePath] = file;
+ }
+ });
+ cb();
+ };
+}
+module.exports = makeWatchRun;