mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-29 01:45:40 +08:00
Use readConfigFile instead of require for tsconfig (#7248)
This commit is contained in:
6
packages/react-scripts/config/modules.js
vendored
6
packages/react-scripts/config/modules.js
vendored
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user