package.json exports/imports maps, TypeScript aliases, and traces dependencies across package boundaries.
followMonorepoPackages Flag
The--follow-monorepo-packages flag enables resolution of imports from monorepo workspace packages. By default, this flag is set to false to maintain compatibility with single-package projects.
What It Does
When enabled, rev-dep will:Detect workspace packages automatically
Detect workspace packages automatically
Rev-dep scans for monorepo configuration files including:
pnpm-workspace.yamlpackage.jsonworkspaces field (npm/yarn)- Lerna configuration
Resolve imports between packages
Resolve imports between packages
Cross-package imports are resolved using the package’s exports configuration, falling back to
main/module fields when exports are not defined.Follow package.json exports
Follow package.json exports
Full support for the modern
exports field including conditional exports, wildcards, and nested conditions.Configuration File Usage
In yourrev-dep.config.json, use the followMonorepoPackages property at the rule level:
Exports Map Support
Rev-dep fully supports theexports field in package.json files, which is the standard way to define package entry points in modern Node.js projects.
Supported Features
The exports map support includes:- Conditional exports using conditions like
node,import,default, and custom conditions - Wildcard patterns for flexible subpath mapping
- Sugar syntax for simple main export definitions
- Nested conditions for complex resolution scenarios
Example Package Configuration
package.json
import '@myorg/utils'resolves to./dist/index.mjs(when usingimportcondition)import '@myorg/utils/helpers'resolves to./dist/helpers.jsimport '@myorg/utils/types/config'resolves to./dist/types/config.d.ts
Condition Names
To control which conditional exports are resolved, use the--condition-names flag. This allows you to specify the priority of conditions when resolving package exports.
The conditions are processed in the order specified, with the first matching condition being used.
Common Conditions
| Condition | Description |
|---|---|
node | Node.js environment |
import | ES modules |
require | CommonJS |
default | Fallback condition |
| Custom | Project or build tool specific conditions |
Configuration File Usage
Set condition names globally in your config:rev-dep.config.json
How It Works
Rev-dep’s monorepo resolution follows this workflow:Monorepo Detection
When
followMonorepoPackages is enabled, rev-dep scans for workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.)Package Resolution
Imports to workspace packages are resolved using the package’s exports configuration, falling back to main/module fields when exports are not defined
Dependency Validation
The tool validates that cross-package imports are only allowed when the target package is listed in the consumer’s dependencies or devDependencies
This makes rev-dep particularly effective for large-scale monorepo projects where understanding cross-package dependencies is crucial for maintaining code quality and architecture.
Best Practices
Enable for monorepos
Always set
followMonorepoPackages: true in your config when working with monoreposUse exports field
Define clear package boundaries using the
exports field in package.jsonSet condition names
Configure appropriate condition names for your build environment
Validate dependencies
Let rev-dep ensure cross-package imports are properly declared
