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

Module graph reports multiple times same modules imports #1374

Closed
6 tasks done
underfisk opened this issue May 25, 2022 · 4 comments · Fixed by #1431
Closed
6 tasks done

Module graph reports multiple times same modules imports #1374

underfisk opened this issue May 25, 2022 · 4 comments · Fixed by #1431

Comments

@underfisk
Copy link

Describe the bug

I have been playing around with the module graph and I was curious if the reported modules are actually duplicated or if it's just an analysis of the file imports because it looks like lodash is represented more than once and some other packages (mostly @mui related but even testing library appears multiple times).

Screenshot 2022-05-25 at 7 19 38 PM

Reproduction

https://github.com/underfisk/vitest-module-graph

System Info

System:
    OS: macOS 12.3.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.49 GB / 64.00 GB
    Shell: 3.2.2 - /usr/local/bin/fish
  Binaries:
    Node: 16.15.0 - ~/.volta/tools/image/node/16.15.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 8.5.5 - ~/.volta/tools/image/node/16.15.0/bin/npm
  Browsers:
    Chrome: 101.0.4951.64
    Safari: 15.4

Used Package Manager

yarn

Validations

@nieyuyao
Copy link
Contributor

It seems that there should actually be two modules @testing-library/jest-dom and @testing-library/react. But showing the same name?

@underfisk
Copy link
Author

@nieyuyao Correct, i believe that for the testing library it does make sense but jest-dom is invoked only at the setup file so its not directly invoked through the file.

@sheremet-va
Copy link
Member

sheremet-va commented May 31, 2022

@nieyuyao Correct, i believe that for the testing library it does make sense but jest-dom is invoked only at the setup file so its not directly invoked through the file.

Setup file is part of the suite, tho. Module Graph shows you every module that was invoked durung the run.

@nieyuyao
Copy link
Contributor

nieyuyao commented Jun 1, 2022

The following code truncates the dependency name. So how to deal with dependencies with the same package name?

function defineExternalModuleNode(module: string): ModuleNode {
let label = module
if (label.includes('/node_modules/'))
label = label.split(/\/node_modules\//g).pop()!.split(/\//g).shift()!
else

@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants