Skip to content

Commit ea2bcb7

Browse files
jackjocrossmrmckeb
authored andcommitted
Use readConfigFile instead of require for tsconfig (#7248)
1 parent 65a891c commit ea2bcb7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/react-scripts/config/modules.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const fs = require('fs');
1212
const path = require('path');
1313
const paths = require('./paths');
1414
const chalk = require('react-dev-utils/chalk');
15+
const resolve = require('resolve');
1516

1617
/**
1718
* Get the baseUrl of a compilerOptions object.
@@ -71,7 +72,10 @@ function getModules() {
7172
// TypeScript project and set up the config
7273
// based on tsconfig.json
7374
if (hasTsConfig) {
74-
config = require(paths.appTsConfig);
75+
const ts = require(resolve.sync('typescript', {
76+
basedir: paths.appNodeModules,
77+
}));
78+
config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
7579
// Otherwise we'll check if there is jsconfig.json
7680
// for non TS projects.
7781
} else if (hasJsConfig) {

0 commit comments

Comments
 (0)