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

Cool library, but my path alias (tsconfig) is printing rather strange. #22

Open
kainbryanjones opened this issue Dec 20, 2023 · 3 comments

Comments

@kainbryanjones
Copy link

In my tsconfig.json

    "paths": {
      "@/*": ["./src/*"],
    },
//this is one of my imports (in class AndroidHandler)
import {eventHandlerWrapper} from "@/utils";

then in the graph it looks like this

image

this is my script

    "draw-dependcy-graph": "ts_dependency_graph --start src/index.ts --h --graph_folder | dot -T png > dependency_graph.png",
@PSeitz
Copy link
Owner

PSeitz commented Dec 20, 2023

Can you add a test in the test project to replicate the issue?

https://github.com/PSeitz/ts-dependency-graph/blob/master/test_project/tsconfig.json
https://github.com/PSeitz/ts-dependency-graph/blob/master/test/test.spec.ts#L159

@kainbryanjones
Copy link
Author

Can you add a test in the test project to replicate the issue?

https://github.com/PSeitz/ts-dependency-graph/blob/master/test_project/tsconfig.json https://github.com/PSeitz/ts-dependency-graph/blob/master/test/test.spec.ts#L159

Sure, but I'm not entriely sure how the codebase works so will do a bit of research before I make any PR.

From what I can tell I should

set up a path like this

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

and then import it in the test project somewhere, but not entirely sure what the 'expect' in jest should be

expect(graph).toEqual({
            edges: [
                {
                    node1: { path: 'test_project/src/App.tsx', layer: 1000 },
                    node2: { path: 'test_project/src/components/Button.tsx', layer: 1000 },
                },
                {
                    node1: { path: 'test_project/src/App.tsx', layer: 1000 },
                    node2: { path: 'test_project/src/components/Input.tsx', layer: 1000 },
                },
                {
                    node1: { path: 'test_project/src/components/Input.tsx', layer: 1000 },
                    node2: { path: 'test_project/src/helpers/index.ts', layer: 1000 },
                },
                {
                    node1: { path: 'test_project/src/helpers/index.ts', layer: 1000 },
                    node2: { path: 'test_project/src/helpers/helper.ts', layer: 1000 },
                },
            ],
            nodes: [
                { path: 'test_project/src/App.tsx', layer: 1000 },
                { path: 'test_project/src/components/Button.tsx', layer: 1000 },
                { path: 'test_project/src/components/Input.tsx', layer: 1000 },
                { path: 'test_project/src/helpers/index.ts', layer: 1000 },
                { path: 'test_project/src/helpers/helper.ts', layer: 1000 },
            ],
            start_nodes: new Set().add({ layer: 1000, path: 'test_project/src/App.tsx' }),
            color_edges: false,
        })

this is yours so I imagine it would be simiular?

@PSeitz
Copy link
Owner

PSeitz commented Dec 22, 2023

You can just edit the existing project, edges reflects the imports or dependencies, nodes the files

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

No branches or pull requests

2 participants