Skip to content

Conversation

domharries
Copy link
Contributor

This PR adds support for paths (and baseUrl) that are defined in a parent tsconfig.json, linked using the extends field. I came across this issue because this is the default setup for nx projects.

The PR adds node.js style resolution of the extends field, and guards against infinite extends loops. I pulled resolveJson5File out into a separate file as it seems require.resolve is pretty impossible to mock for the tests. The PR changes the logic to eagerly resolve baseUrl into an absolute path, as the value is always relative to whichever config file it was defined in.

I tested using this nx template which uses a parent tsconfig to import the util styles: https://github.com/domharries/cssmodules-nx-example/blob/main/apps/cssmodules-nx-example/src/app/app.tsx

Copy link
Owner

@antonk52 antonk52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been a missing feature for a while. Appreciate the contribution, comments, test cases, and repro example. I will be releasing a new version shortly

@antonk52 antonk52 merged commit b8d061a into antonk52:main Dec 2, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants