Skip to content

Commit

Permalink
feat(scripts): use solution ts config when enabled within tsc just task
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell committed Nov 5, 2021
1 parent c704b87 commit b132657
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/tasks/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ const useTsBuildInfo =
*/
function prepareTsTaskConfig(options: TscTaskOptions) {
const tsConfigFilePath = resolveCwd('./tsconfig.json');
const tsConfig: TsConfig = jju.parse(fs.readFileSync(tsConfigFilePath, 'utf-8'));
const tsConfigLibFilePath = resolveCwd('./tsconfig.lib.json');
const isUsingTsSolutionConfigs = fs.existsSync(tsConfigLibFilePath);

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

if (tsConfig.extends) {
logger.info(`📣 TSC: package is using TS path aliases. Overriding tsconfig settings.`);

const normalizedOptions = { ...options };
normalizedOptions.baseUrl = '.';
normalizedOptions.rootDir = './src';
normalizedOptions.project = isUsingTsSolutionConfigs ? 'tsconfig.lib.json' : null;

return normalizedOptions;
}

options.target = 'es5';

return options;
}

Expand Down Expand Up @@ -88,6 +96,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 b132657

Please sign in to comment.