How to use the ts-loader/dist/config.js.getConfigFile function in ts-loader

To help you get started, we’ve selected a few ts-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / neuroglancer / config / ts_loader_patch.js View on Github external
* The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const tsLoaderConfigModule = require('ts-loader/dist/config.js');
const tsLoaderUtilsModule = require('ts-loader/dist/utils.js');

tsLoaderConfigModule.getConfigFile = function getConfigFile(
    compiler, loader, loaderOptions, compilerCompatible, log, compilerDetailsLogMessage) {
  let configFilePath = loaderOptions.configFileName;
  var configFileError;
  log.logInfo(('ts-loader: Using config file at ' + configFilePath).green);
  let configFile = compiler.readConfigFile(configFilePath, compiler.sys.readFile);
  if (configFile.error) {
    configFileError = tsLoaderUtilsModule.formatErrors(
        [configFile.error], loaderOptions, compiler, {file: configFilePath})[0];
  }
  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;
    }