From 8c9cf51dd20264e184d98b074202e3428b8321d1 Mon Sep 17 00:00:00 2001 From: jack Date: Wed, 19 Jun 2019 10:20:31 -0400 Subject: [PATCH] Use readConfigFile instead of require for tsconfig --- packages/react-scripts/config/modules.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/modules.js b/packages/react-scripts/config/modules.js index b232fe37150..d861f2b2dc8 100644 --- a/packages/react-scripts/config/modules.js +++ b/packages/react-scripts/config/modules.js @@ -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) {