Skip to main content
Version: 3.x

mops sync

Analyze source code and:

  • Add missing packages that are used in the source code but are not listed in mops.toml
  • Remove unused packages listed in mops.toml but not imported in the source code
mops sync

mops sync compiles nothing, but it does read your imports with moc, so it requires a pinned [toolchain] moc.

mops sync reads the same set of sources as mops test: files inside node_modules/, .mops/, .git/, .dfx/, dist/, build/ and bundle/ are skipped, as are directories below the project root that are their own checkout — a git worktree, a submodule, a nested clone. An import that only appears in such a copy does not keep a package looking used. Unlike mops format and mops lint, it reads files the project's .gitignore excludes: a generated source still needs its imports installed.

--dry-run​

Print what would be added and removed without touching mops.toml, the local cache or the lockfile.

mops sync --dry-run
Missing packages: core, fuzz
Unused packages: itertools
Would add core
Would add fuzz (dev)
Would remove itertools

When there is nothing to do, it prints Everything is in sync.

Dev dependencies​

A package imported only from test, tests, bench or benchmark directories is added to [dev-dependencies]. A package imported anywhere else is added to [dependencies], even if it is also used in tests.

Packages that are already declared are never moved between the two sections — mops sync only classifies packages it adds.

Pinned aliases​

Pinned aliases are matched against imports verbatim, so mo:map@8.1.0 corresponds to the "map@8.1.0" key and mo:map to the map key. The two are tracked independently: removing one never rewrites the other.

Lockfile​

The lockfile is always kept in sync — there is no flag to opt out, except --dry-run, which writes nothing at all.