Skip to content

Commit

Permalink
feat(scripts): use solution ts config when enabled within tsc just ta…
Browse files Browse the repository at this point in the history
…sk (microsoft#20515)

* feat(scripts): use solution ts config when enabled within  tsc just task

* fixup! feat(scripts): use solution ts config when enabled within  tsc just task
  • Loading branch information
Hotell authored and Marion Le Pontois committed Jan 17, 2022
1 parent b39375a commit f38a8ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/tasks/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const useTsBuildInfo =
* > - Without setting rootDir we would get output dir mapping following path from monorepo root
*/
function prepareTsTaskConfig(options: TscTaskOptions) {
const tsConfigFilePath = resolveCwd('./tsconfig.json');
const tsConfigMainFilePath = resolveCwd('./tsconfig.json');
const tsConfigLibFilePath = resolveCwd('./tsconfig.lib.json');
const isUsingTsSolutionConfigs = fs.existsSync(tsConfigLibFilePath);

const tsConfigFilePath = isUsingTsSolutionConfigs ? tsConfigLibFilePath : tsConfigMainFilePath;
const tsConfig: TsConfig = jju.parse(fs.readFileSync(tsConfigFilePath, 'utf-8'));

if (tsConfig.extends) {
Expand All @@ -40,10 +44,13 @@ function prepareTsTaskConfig(options: TscTaskOptions) {
const normalizedOptions = { ...options };
normalizedOptions.baseUrl = '.';
normalizedOptions.rootDir = './src';
normalizedOptions.project = path.basename(tsConfigFilePath);

return normalizedOptions;
}

options.target = 'es5';

return options;
}

Expand Down Expand Up @@ -88,6 +95,7 @@ export const ts = {
const extraOptions = getExtraTscParams(getJustArgv());
const options = prepareTsTaskConfig({
...extraOptions,
target: 'es5',
outDir: 'lib-amd',
module: 'amd',
...(useTsBuildInfo && { tsBuildInfoFile: '.amd.tsbuildinfo' }),
Expand Down

0 comments on commit f38a8ba

Please sign in to comment.