Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-typescript-plugin",
"comment": "Support \"${configDir}\" token in tsconfig when using file copier.",
"type": "patch"
}
],
"packageName": "@rushstack/heft-typescript-plugin"
}
21 changes: 20 additions & 1 deletion heft-plugins/heft-typescript-plugin/src/TypeScriptPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import { getTsconfigFilePath } from './tsconfigLoader';
*/
export const PLUGIN_NAME: 'typescript-plugin' = 'typescript-plugin';

/**
* The ${configDir} token supported in TypeScript 5.5
* @see {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files}
*/
const CONFIG_DIR_TOKEN: '${configDir}' = '${configDir}';

/**
* @beta
*/
Expand Down Expand Up @@ -203,7 +209,20 @@ export async function loadPartialTsconfigFileAsync(
},
jsonPathMetadata: {
'$.compilerOptions.outDir': {
pathResolutionMethod: PathResolutionMethod.resolvePathRelativeToConfigurationFile
pathResolutionMethod: PathResolutionMethod.custom,
customResolver(
resolverOptions: ConfigurationFile.IJsonPathMetadataResolverOptions<IPartialTsconfig>
): string {
if (resolverOptions.propertyValue.includes(CONFIG_DIR_TOKEN)) {
// Typescript 5.5. introduced the `${configDir}` token to refer to the directory containing the root tsconfig
const configDir: string = path.dirname(tsconfigFilePath);
// The token is an absolute path, so it should occur at most once.
return path.resolve(resolverOptions.propertyValue.replace(CONFIG_DIR_TOKEN, configDir));
} else {
const thisConfigDir: string = path.dirname(resolverOptions.configurationFilePath);
return path.resolve(thisConfigDir, resolverOptions.propertyValue);
}
}
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions rigs/local-node-rig/profiles/default/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"isolatedModules": true,
"target": "es2018",

"outDir": "../../../../lib",
"rootDir": "../../../../src",
"outDir": "${configDir}/lib",
"rootDir": "${configDir}/src",

"types": ["heft-jest", "node"],
"typeRoots": ["../../../../node_modules/@types", "../../node_modules/@types"]
"typeRoots": ["${configDir}/node_modules/@types", "../../node_modules/@types"]
},
"include": ["../../../../src/**/*.ts", "../../../../src/**/*.tsx"]
"include": ["${configDir}/src/**/*.ts", "${configDir}/src/**/*.tsx"]
}
10 changes: 5 additions & 5 deletions rigs/local-web-rig/profiles/app/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"target": "es2017",
"lib": ["es2017", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],

"outDir": "../../../../lib",
"rootDir": "../../../../src",
"rootDirs": ["../../../../src", "../../../../temp/sass-ts"],
"outDir": "${configDir}/lib",
"rootDir": "${configDir}/src",
"rootDirs": ["${configDir}/src", "${configDir}/temp/sass-ts"],

"types": ["heft-jest", "webpack-env"],
"typeRoots": ["../../../../node_modules/@types", "../../node_modules/@types"]
"typeRoots": ["${configDir}/node_modules/@types", "../../node_modules/@types"]
},
"include": ["../../../../src/**/*.ts", "../../../../src/**/*.tsx"]
"include": ["${configDir}/src/**/*.ts", "${configDir}/src/**/*.tsx"]
}
10 changes: 5 additions & 5 deletions rigs/local-web-rig/profiles/library/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"resolveJsonModule": true,
"isolatedModules": true,

"outDir": "../../../../lib",
"rootDir": "../../../../src",
"rootDirs": ["../../../../src", "../../../../temp/sass-ts"],
"outDir": "${configDir}/lib",
"rootDir": "${configDir}/src",
"rootDirs": ["${configDir}/src", "${configDir}/temp/sass-ts"],

"types": ["heft-jest", "webpack-env"],
"typeRoots": ["../../../../node_modules/@types", "../../node_modules/@types"]
"typeRoots": ["${configDir}/node_modules/@types", "../../node_modules/@types"]
},
"include": ["../../../../src/**/*.ts", "../../../../src/**/*.tsx"]
"include": ["${configDir}/src/**/*.ts", "${configDir}/src/**/*.tsx"]
}
Loading