Skip to content
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

Question: How to configure for tsconfig path mapping in yarn monorepo? #862

Closed
KevinSchiener opened this issue Nov 7, 2023 · 4 comments
Closed
Labels

Comments

@KevinSchiener
Copy link

KevinSchiener commented Nov 7, 2023

Summary

I get error not-to-unresolvable when running in a monorepo where the packages have individual path mappings in their tsconfig.json.

Can I configure dependency-cruiser to pick up the package tsconfig.json when running from the workspace root?

Context

I have a yarn workspaces monorepo with different packages in /packages/ and /apps/. Some packages define path maps in their respective tsconfig.json.

- /root
  - tsconfig.json
  - /apps
  - /packages
    - /A
      - tsconfig.json
    - /B
      - tsconfig.json

Example:

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@/*": [
                "src/*"
            ]
        },

These mappings are not picked up by dependency-cruiser when running from the repository root and will result in errors like:

error not-to-unresolvable: package/A/src/pages/Dashboard/Dashboard.tsx → @/hooks/use-pageTitle

It only works if I run dependency-cruiser from the /packages/A folder directly. My guess is that it only picks up the tsconfig.json from the current working directory.

I only have a .dependency-cruiser.js in the root.

Is there a way to have it pick up the configs of each subfolder respectively?

Environment

  • Version used: 15.2.0
  • Node version: 18.18.0
  • Operating System and version: MacOS 13.3.1 (22E261)
@KevinSchiener KevinSchiener changed the title Question: How to detect tsconfig.json per package in monorepo? tsconfig.json path mapping "@/": ["src/*"] not working Nov 7, 2023
@KevinSchiener KevinSchiener changed the title tsconfig.json path mapping "@/": ["src/*"] not working Question: How to configure for tsconfig path mapping in yarn monorepo? Nov 7, 2023
@sverweij
Copy link
Owner

Hi @KevinSchiener dependency-cruiser currently directly supports one tsconfig.json. Supporting multiple ones at the same time is a future feature. It'll likely need a meaty chunk of time to implement correctly (and make it work with reasonable speed).

There are workarounds, but they will require some manual work.

Related: #565

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@KevinSchiener
Copy link
Author

@sverweij Thanks for the reply. Hadn't gotten around to the issue for a while.

@kakidiakoafonso
Copy link

@sverweij Thanks for the reply. Hadn't gotten around to the issue for a while.

how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants