package rescriptdep

All checked builds pass
  1. Overview
  2. Docs
A dependency analyzer for ReScript modules

Install

dune-project
 Dependency

Authors

Maintainers

Sources

rescriptdep-0.3.0.tar.gz
md5=0dc249fc6c124f6adfd3834571ea24a3
sha512=44894ed1848eb19317303f72213d732d1bc93b2f5e0710a5d20ac49bbf634a1ed830c10019b5f087b3e00bd103ec7e910226465b34e1c94824d831c68f4c5c9e

doc/README.html

ReScriptDep

A dependency analyzer for ReScript modules.

Introduction

ReScriptDep is a tool for analyzing dependencies between ReScript modules. It uses cmt files to identify module dependencies and can visualize them or output them in JSON format.

Installation

# Install via opam
opam install rescriptdep

Building with Static Linking (Linux)

To build rescriptdep with static linking on Linux, which creates a standalone executable without external dependencies:

# Build the project using the static profile
dune build --profile static

# This will generate a statically linked executable for Linux environments

Usage

# Basic usage
rescriptdep [options] files_or_dirs

# Options
# -o, --output <file>         : Output file (default: stdout)
# -f, --format <format>       : Output format (dot, json)
# -m, --module <name>         : Focus on specific module and its dependencies
# -v, --verbose               : Enable verbose output
# -b, --benchmark             : Enable performance benchmarking
# --no-cache                  : No effect, kept for compatibility (rescriptdep keeps no cache)
# --clear-cache               : No effect, kept for compatibility
# -nd, --no-dependents        : Find modules that have no dependents (not imported by any other modules)
# -vb, --value-binding <name> : Count usage of a value binding (by name) across the project (in the module itself and all dependents; requires -m)
# -vl, --value-line <line>    : Line number of the value binding (1-based, for disambiguation when multiple bindings have the same name; use with -vb)

files_or_dirs are compiled .cmt files or directories that contain them, usually the project's lib/bs.

Standard library and compiler-internal modules are left out of the graph, but a module that has its own .cmt file is always kept, even when its name matches one of them (for example Format).

Only the DOT or JSON output goes to stdout. Warnings (for example an unreadable entry in lib/bs, which is skipped) and the -v/-b messages go to stderr.

With -vb, each module reports its usage count, or a negative code when it could not be analyzed: -2 no implementation, -3 unreadable .cmt file, -4 no .cmt file, -5 no file path, -6 the compiler that built the module is not supported by value usage analysis.

Supported ReScript Versions

ReScript

Dependency graph

Value usage (-vb)

11.0.0 - 11.1.4

Yes

Yes

12.0.0 - 12.3.1

Yes

Yes

13.0.0-alpha.1 - alpha.3, alpha.5, alpha.6

Yes

Yes

13.0.0-alpha.4

Yes

No (-6), see below

rescriptdep identifies the compiler from each .cmt file and, for ReScript 12 and later, from the version rewatch records in lib/bs/compiler-info.json. Files in formats no supported compiler writes are rejected with an error instead of being misread. Other versions of a supported format (for example a later 13.0 prerelease) get the dependency graph, and -6 from -vb until their typed tree has been checked.

ReScript 13.0.0-alpha.4

Value usage analysis (-vb, the inline "Used N times" count in the VS Code extension) is not supported for projects built with 13.0.0-alpha.4, and every module reports -6. The dependency graph works as usual.

-vb reads the typed tree stored in .cmt files, which depends on the exact layout of the compiler's data types. 13.0.0-alpha.4 inserted the for...of constructors in the middle of the expression type, a layout no other release uses: 13.0.0-alpha.5 moved them to the end of the type. Rather than keep a decoder for that single prerelease, rescriptdep skips it. Upgrade to 13.0.0-alpha.5 or later to use value usage analysis.

Development

For detailed information about building the project, running tests, and contributing, please see CONTRIBUTING.md.

Quick Start for Development

# Build the project
make build

# Run the CI-equivalent test suite (requires pnpm 10.x)
make test

License

MIT