aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ts-loader/dist/config.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/ts-loader/dist/config.js
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/ts-loader/dist/config.js')
-rw-r--r--node_modules/ts-loader/dist/config.js77
1 files changed, 77 insertions, 0 deletions
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;