Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 5fe4a0f

Browse files
committed
fix(typescriptTransform): Let tsc read the config instead of requiring it
Requiring the config does not support tsconfig options like "extends", which is useful for using multiple configs on a single project.
1 parent 1dcfa1d commit 5fe4a0f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Diff for: packages/react-scripts/config/jest/typescriptTransform.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ const tsconfigPath = require('app-root-path').resolve('/tsconfig.json');
99
let compilerConfig = {
1010
module: tsc.ModuleKind.CommonJS,
1111
jsx: tsc.JsxEmit.React,
12-
}
12+
};
1313

1414
if (fs.existsSync(tsconfigPath)) {
1515
try {
16-
const tsconfig = require(tsconfigPath);
16+
const tsconfig = tsc.readConfigFile(tsconfigPath).config;
1717

1818
if (tsconfig && tsconfig.compilerOptions) {
1919
compilerConfig = tsconfig.compilerOptions;
2020
}
21-
} catch (e) { /* Do nothing - default is set */ }
21+
} catch (e) {
22+
/* Do nothing - default is set */
23+
}
2224
}
2325

2426
module.exports = {
2527
process(src, path) {
2628
if (path.endsWith('.ts') || path.endsWith('.tsx')) {
27-
return tsc.transpile(
28-
src,
29-
compilerConfig,
30-
path, []
31-
);
29+
return tsc.transpile(src, compilerConfig, path, []);
3230
}
3331
return src;
3432
},

0 commit comments

Comments
 (0)