Summary
After upgrading heft to 0.51.0, our projects failed to build because the typescript compiler was no longer emitting files into the specified outDir location. Instead, the files were next to the sources as if outDir was not set in tsconfig.json.
Repro steps
Run heft build with these settings in tsconfig.json:
{
"compilerOptions": {
"composite": true,
"outDir": "lib",
"types": ["node", "jest"]
},
"include": ["./src/**/*", "./__tests__/**/*"],
"exclude": [
"./lib",
"node_modules"
]
}
typescript.json in the rig should not have a project value set (defaults to ./tsconfig.json).
Expected result:
Compiled .js files will be in a folder structure under ./lib.
Actual result:
The tsconfig.tsbuildinfo file is under ./lib, but the compiled .js and .d.ts files remain next to the sources.
Details
As of heft 0.51.0 and heft-typescript-plugin 0.1.0, the configFilePath supplied to the typescript compiler program is no longer resolved, and this subtle difference changes where the compiler outputs files.
0.50.x versions with the built-in plugin would resolve the path:
https://github.com/microsoft/rushstack/blob/%40rushstack/heft_v0.50.7/apps/heft/src/plugins/TypeScriptPlugin/TypeScriptPlugin.ts#L209
producing a compiler option: "configFilePath”:”/path-to-project/tsconfig.json"
The new plugin simply concats the project with the build folder:
https://github.com/barryhagan/rushstack/blob/main/heft-plugins/heft-typescript-plugin/src/TypeScriptPlugin.ts#L176
producing a compiler option: "configFilePath”:”/path-to-project/./tsconfig.json"
This is might actually be a bug in the typescript compiler as the extra './' path segment should not do this, but it causes the compiler to not use the configured outDir value.
A simple workaround is to set project in typescript.json to be tsconfig.json instead of defaulting to ./tsconfig.json so the string concat works, but it would be nice to restore the path.resolve to avoid this problem.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question |
Answer |
@rushstack/heft version? |
0.51.0 |
| Operating system? |
Mac |
| Would you consider contributing a PR? |
Yes |
Node.js version (node -v)? |
18.15.0 |
Summary
After upgrading heft to 0.51.0, our projects failed to build because the typescript compiler was no longer emitting files into the specified
outDirlocation. Instead, the files were next to the sources as ifoutDirwas not set in tsconfig.json.Repro steps
Run
heft buildwith these settings in tsconfig.json:typescript.json in the rig should not have a
projectvalue set (defaults to ./tsconfig.json).Expected result:
Compiled .js files will be in a folder structure under ./lib.
Actual result:
The
tsconfig.tsbuildinfofile is under ./lib, but the compiled .js and .d.ts files remain next to the sources.Details
As of heft 0.51.0 and heft-typescript-plugin 0.1.0, the
configFilePathsupplied to the typescript compiler program is no longer resolved, and this subtle difference changes where the compiler outputs files.0.50.x versions with the built-in plugin would resolve the path:
https://github.com/microsoft/rushstack/blob/%40rushstack/heft_v0.50.7/apps/heft/src/plugins/TypeScriptPlugin/TypeScriptPlugin.ts#L209
producing a compiler option:
"configFilePath”:”/path-to-project/tsconfig.json"The new plugin simply concats the project with the build folder:
https://github.com/barryhagan/rushstack/blob/main/heft-plugins/heft-typescript-plugin/src/TypeScriptPlugin.ts#L176
producing a compiler option:
"configFilePath”:”/path-to-project/./tsconfig.json"This is might actually be a bug in the typescript compiler as the extra './' path segment should not do this, but it causes the compiler to not use the configured
outDirvalue.A simple workaround is to set
projectin typescript.json to betsconfig.jsoninstead of defaulting to./tsconfig.jsonso the string concat works, but it would be nice to restore the path.resolve to avoid this problem.Standard questions
Please answer these questions to help us investigate your issue more quickly:
@rushstack/heftversion?node -v)?