nx
nx copied to clipboard
Bug: @nrwl/js:tsc Invalid extends in tmp tsConfig - path.relative not being aware of current working dir
Current Behavior
When running the tsc executor to build a package, if I run the command from the root directory of the monorepo or the pacakge itself one (root) will work just fine while the other will not transpile anyfile.
I pinpointed the issue here https://github.com/nrwl/nx/blob/master/packages/workspace/src/utilities/buildable-libs-utils.ts#L161.
where path.relative should make sure that tsConfigPath is an absolute so it is valid weather you run the command from the root or the package folder itself. We can probably join the workspaceRoot here to fix this. https://github.com/nrwl/nx/blob/master/packages/workspace/src/utilities/buildable-libs-utils.ts#L238
Happy to make a PR if that can help move it forward. In the meantime we will just only run the commands from the root folder.
Expected Behavior
The 2 commands should give the same results
GitHub Repo
No response
Steps to Reproduce
- Create a monorepo
- Create a project with typescript
- Add tsc runner following the documentation example
- run
nx run project:buildfrom root folder &nx buildfrom the project folder - One will build the files correctly the other will be a folder with just package.json
Nx Report
Node : 16.19.0
OS : darwin arm64
yarn : 1.22.19
nx : 15.8.3
lerna : 6.5.1
@nrwl/js : 15.8.3
@nrwl/jest : 15.8.3
@nrwl/linter : 15.8.3
@nrwl/workspace : 15.8.3
@nrwl/cli : 15.8.3
@nrwl/devkit : 15.8.3
@nrwl/tao : 15.8.3
typescript : 4.6.2
Failure Logs
No failure just invalid behavior
Additional Information
No response
Hey 👋
I would be happy to make a PR if that can help. Can you confirm the issue and would that you would be willing to accept a fix as described in the issue description ?
That path is passed from here: https://github.com/nrwl/nx/blob/8c9ad0da69b76def41ef1af615d0795272a0b78f/packages/js/src/executors/tsc/tsc.impl.ts#L46-L49
There's a normalized options object, in which all paths are absolute. Removing the underscore should fix the issue. The raw _options object is also used further down, I'm not sure if that's intentional or a mistake too.
+1 on this issue, I've been experiencing the same thing. Builds only succeed from the root directory. @cutiful @alexandrebodin I modified the following locally to use options rather than _options and can confirm that fixed the issue.
https://github.com/nrwl/nx/blob/8c9ad0da69b76def41ef1af615d0795272a0b78f/packages/js/src/executors/tsc/tsc.impl.ts#L46-L49
https://github.com/nrwl/nx/blob/8c9ad0da69b76def41ef1af615d0795272a0b78f/packages/js/src/executors/tsc/tsc.impl.ts#L69-L70
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
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.