-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@nx/js:tsc - wrong extends path used when generated temporary tsconfig #28316
Comments
SebastienGllmt
added a commit
to SebastienGllmt/nx
that referenced
this issue
Oct 6, 2024
leosvelperez
added a commit
that referenced
this issue
Dec 3, 2024
…ile for incremental builds (#29121) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28316
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
isaacplmann
pushed a commit
that referenced
this issue
Feb 11, 2025
…ile for incremental builds (#29121) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28316
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current Behavior
Background
When building with the
tsc
executor, a temporary tsconfig file gets generated for you in{workspaceRoot}/tmp/{relativeProjectRoot}
This temporary tsconfig file is meant to use the tsconfig
extends
syntax to extend the tsconfig in your project root with some custom behavior based on your build settingsex:
The code
Internally, this executor is called here
The first thing it does is take the tsconfig path in your executor's configuration and normalizes it. For example
will turn the relative
tsConfig
path into'/home/user/Documents/git/my-project/packages/backend/db/tsconfig.lib.json'
This new absolute path is then passed down to create the temporary tsconfig file in the following steps
checkDependencies
herecheckDependencies
callscreateTmpTsConfig
hereextends
field is calculated inreadTsConfigWithRemappedPaths
hereThe bug
Note that for the value of
extends
to be calculated correctly in readTsConfigWithRemappedPaths, you have two options:dirnameTsConfig
,tsConfig
) absoluteworkspaceRoot
However, instead, right now
dirnameTsConfig
is turned into a relative path whiletsConfig
is kept as an absolute path (remember we normalized it here)This results in the value of
generatedTsConfig.extends
to be incorrect, causing builds to failExpected Behavior
The paths should either both be absolute, or both be relative.
The easiest way to do this was to pass in the relative path into the
checkDependencies
function (since thetsConfig
variable is not accessed anywhere except to calculategeneratedTsConfig.extends
), but changingdirnameTsConfig
to always be absolute would also be okayGitHub Repo
https://github.com/SebastienGllmt/nx-tsc-repro
Steps to Reproduce
See repro README
Builds seems to work fine for me on my repo.... how come you can reproduce it?
The reason this error wasn't caught before is presumably because if the
extends
path points to an invalid path, builds will still work if they were going to work with the default tsc configuration.Notably, if you add
console.log(tsConfig)
here, you can see that these builds actually result in the following error that gets supressedReliably causing an actual build failure
Although these builds always have a configuration error, as I mentioned that doesn't always actually lead to a build error
nx build
Nx Report
Failure Logs
Package Manager Version
pnpm 9.6.0
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: