Policy packs and named presets
Encode Module Federation governance once and reuse it across hosts and remotes —
the same idea as ESLint shareable configs. For per-app "off" / severity
overrides, baselines, and failOn, see
Suppressions and allowlists.
Built-in presets
Profiles are explicit policy overlays, not a second config system. Compose one
with recommended when you want the full catalog, and keep local rules
overrides last:
For an application-level shortcut, use the top-level profile option:
profile is appended after extends and before local rules. The effective
order is default < extends (left to right) < profile < local rules. When
profile: "demo" is used in CI, MFDoctor resolves the safer production overlay
instead of hiding demo-only recommendations. The resolved overlay is visible
in appliedPolicies.
The demo overlay softens local-only demo noise: bare / loopback remoteEntry
recommendations and version-first offline-remotes are hidden only in
development runs. A deployed or non-localhost remote stays visible, and CI
stays loud even when demo is present. It also hides manifest and implicit
Bridge-router nudges only during local development, while keeping them visible
in CI, and softens disabled DTS to info. The production overlay makes
manifest, disabled DTS, implicit Bridge-router, and version-first offline-
remote nudges warning; it also elevates the Observability and prefix-share
recommendations. These overlays only change recommendation severities and
bounded rule options; they do not change default runs or correctness rules.
Use rules: { "<rule-id>": "off" } or a baseline when a production team
intentionally accepts a recommendation.
The manifest and DTS checks only recommend an enablement when MF config shows a
federated surface and the option is explicitly disabled. They are advisory in
the default profile: demo hides manifest guidance and keeps DTS at info,
while production raises both to warning. A local rules entry wins over
either profile, including "off". The Observability nudge is conservative by
default: it requires a supported MF 2.5+ package and an installed or declared
@module-federation/observability-plugin; production can opt into the wider
recommendation. The prefix-share nudge uses observed react/... and
react-dom/... imports and remains independently suppressible.
Shareable packs
A pack is a DoctorPolicyPack: optional name, a rules severity map, and
optional plugins (custom rules from defineRule).
Publish the pack as a workspace or npm package and depend on it from each app. Load it by import or by package/path string (resolved from the project root — no remote HTTP download):
In-repo example: fixtures/policy-packs/acme-mfdoctor-policy.
Shared-usage policy knobs
Packs (and local DoctorOptions) can extend built-in package lists and import
depth without replacing them:
Equivalent local fields on DoctorOptions: importDepth,
additionalCandidates, additionalSingletonRisks, alwaysShared,
deepImportAllowlist.
Override precedence
Later layers win:
- Built-in rule
defaultSeverity - Preset maps from
extends(left → right) - Pack maps from
extends(left → right) - Local
rulesinmfdoctor.config/ adapterDoctorOptions - CLI / adapter flags merged onto options before resolve (for example
--ciforcingmode, or an explicitrulesobject passed from a wrapper)
So: CLI/flags > local rules > pack > preset defaults.
Custom rules stay available through defineRule either as direct extends
entries or as plugins on a pack.
API
definePolicyPack— author a packpresets/recommendedPreset/strictPreset/demoPreset/productionPreset— built-in packs and recommendation overlaysresolvePolicy/resolveOptions— resolveextends+ mergerules- Subpath:
@tonoizer/mfdoctor/policy