diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index b52ea6b82a..c680d87b99 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -82,6 +82,7 @@ module.exports = { testsSetup: resolveApp('src/setupTests.ts'), appNodeModules: resolveApp('node_modules'), appTsConfig: resolveApp('tsconfig.json'), + appTsTestConfig: resolveApp('tsconfig.test.json'), publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')), // These properties only exist before ejecting: @@ -112,6 +113,7 @@ if ( testsSetup: resolveOwn('template/src/setupTests.ts'), appNodeModules: resolveOwn('node_modules'), appTsConfig: resolveOwn('template/tsconfig.json'), + appTsTestConfig: resolveOwn('template/tsconfig.test.json'), publicUrl: getPublicUrl(resolveOwn('package.json')), servedPath: getServedPath(resolveOwn('package.json')), // These properties only exist before ejecting: diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 9063be329d..019767d7e8 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -47,7 +47,7 @@ module.exports = (resolve, rootDir) => { }, globals: { 'ts-jest': { - tsConfigFile: paths.appTsConfig, + tsConfigFile: paths.appTsTestConfig, }, }, }; diff --git a/packages/react-scripts/template/tsconfig.json b/packages/react-scripts/template/tsconfig.json index 2f2a20c728..8597354149 100644 --- a/packages/react-scripts/template/tsconfig.json +++ b/packages/react-scripts/template/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "outDir": "build/dist", - "module": "commonjs", + "module": "esnext", "target": "es5", "lib": ["es6", "dom"], "sourceMap": true, diff --git a/packages/react-scripts/template/tsconfig.test.json b/packages/react-scripts/template/tsconfig.test.json new file mode 100644 index 0000000000..65ffdd4939 --- /dev/null +++ b/packages/react-scripts/template/tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs" + } +} \ No newline at end of file