Use readConfigFile instead of require for tsconfig (#7248)

This commit is contained in:
Jack Cross
2019-08-07 14:00:56 -04:00
committed by Brody McKee
parent 65a891c2e0
commit ea2bcb7f59

View File

@@ -12,6 +12,7 @@ const fs = require('fs');
const path = require('path');
const paths = require('./paths');
const chalk = require('react-dev-utils/chalk');
const resolve = require('resolve');
/**
* Get the baseUrl of a compilerOptions object.
@@ -71,7 +72,10 @@ function getModules() {
// TypeScript project and set up the config
// based on tsconfig.json
if (hasTsConfig) {
config = require(paths.appTsConfig);
const ts = require(resolve.sync('typescript', {
basedir: paths.appNodeModules,
}));
config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
// Otherwise we'll check if there is jsconfig.json
// for non TS projects.
} else if (hasJsConfig) {