How components are found
A scan reads your repo's React, Vue and Angular files and records every component it sees in use. Framework support lists what counts as a component in each framework. This page explains the two kinds of component and how each is matched across repos, and what happens when your dependencies aren't installed.
What gets an entry
A component your repo defines gets an entry even when nothing uses it, as long as its own code uses another component, such as a page component that only your framework's router loads.
The scan doesn't know which packages make up your design system. It records every package the same way, and you pick out the ones that matter with tags in the dashboard.
Two kinds of component
Every component is one of two kinds:
- External: it comes from an installed package, such as
import { Button } from "@acme/ui". - Local: your repo defines it, such as
import { Card } from "./Card". A component from another workspace package in the same monorepo is local too: it is still your repo's code.
A web component such as <acme-button> is one of these two: local when your repo defines it, and external when it comes from a package or nothing defines it. If you publish web components, see Link web components to your package.
If your repo uses path aliases, the scan needs them to follow imports: see Resolve imports in a monorepo.
Matching across repos
External and local components are matched across repos in different ways:
- External: matched by package and name.
Buttonfrom@acme/uiis the same component instorefrontandcheckout, so the dashboard can add their usage together and show every repo that uses it. The package entry point counts too:Buttonimported from@acme/ui/buttonis a separate component fromButtonimported from@acme/ui. - Local: matched by repo and file. A
Cardinstorefrontand aCardincheckoutare two components, even when the files look alike. - Web components, external or local: matched by tag name.
<acme-button>is the same component in every repo that uses it.
Install dependencies before you scan
Install your dependencies before you scan. When a package your package.json declares isn't installed, the scan can't tie its uses to a component. They are recorded as unmatched uses, and none of that package's components get an entry. The scan's summary says so:
Scout couldn't match 4 more uses to a component. See https://scoutui.dev/docs/guides/troubleshoot-a-scan#unresolved-occurrences
4 of them are from packages that aren't installed.
Until the packages in dependencies and devDependencies are installed, scout scan stops before it scans. A dry run (scout scan --dry-run) scans anyway and prints the summary above.
Unmatched uses stay in the JSON with the reason for each, but the dashboard leaves them out of every count. A use is unmatched too when its import points at a file that doesn't exist, or when nothing imports its name. When a component you expect is missing, see Troubleshoot a scan.
One entry per component, one per place it is used
A scan records usage at two levels of detail:
- One entry per component, with the totals: how many places use it, in how many files, and which values each prop was given.
- One entry per use, the place in the code where the component is used: the file, the line, and the props written there.
The totals answer "how much is this used, and how?". The uses answer "where do I go to change it?". A component's page in the dashboard shows both. In the JSON they are the components and occurrences arrays; the scan file reference lists their fields.
A compound component such as <Dialog.Popup> gets its own entry, named Dialog.Popup, separate from Dialog.
The glossary defines the other terms used on this page.