Explicit cross-domain contracts via Nx tags
Cross-domain imports go through public barrel exports — Nx tags enforce who may depend on whom.
nx-isolation-nx-tag-contracts
Why it matters
| Stake | If ignored |
|---|---|
| Agent gets lost |
|
| Hidden coupling |
|
| API drift |
|
How to fix
A domain may not import from src/ of another domain. Only via the library barrel (index.ts). Nx enforces this with tags.
Examples
ts
// apps/workspace/src/workflow-builder.ts
import { SiteModel } from '../../../libs/sites-management/data-access/src/lib/internal/models/site';
import { validateSlug } from '../../../libs/sites-management/data-access/src/lib/utils/validation';json
{
"rules": {
"@nx/enforce-module-boundaries": ["error", {
"depConstraints": [
{ "sourceTag": "domain:studio", "onlyDependOnLibsWithTags": ["domain:studio", "domain:shared"] },
{ "sourceTag": "domain:sites-management", "onlyDependOnLibsWithTags": ["domain:sites-management", "domain:shared"] },
{ "sourceTag": "domain:shared", "onlyDependOnLibsWithTags": ["domain:shared"] },
{ "sourceTag": "type:feature", "onlyDependOnLibsWithTags": ["type:feature", "type:data-access", "type:ui", "type:util"] },
{ "sourceTag": "type:ui", "onlyDependOnLibsWithTags": ["type:ui", "type:util"] }
]
}]
}
}