Repository navigation
RFC 38: measure relative paths in a fragment from that fragment - #40
Conversation
A relative path in a local fragment is now relative to the directory of the fragment's include path, the way a relative path in the root manifest is relative to the workspace root. This lets a fragment sit next to the files it names, such as a patch list in `patches/`, and gives config dependency entries a consistent base if path-valued settings are ever allowed there. Root-relative resolution moves to the alternatives considered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
PR Summary by QodoRFC 38: Resolve fragment paths relative to the fragment
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Implement the config fragments RFC in pnpm v12. The root pnpm-workspace.yaml can list local YAML files and config dependencies under `include`, each mapped to the settings it owns (or '*' for local files). Every setting and catalog slot (catalog, catalogs.<name>, catalogs) has exactly one owner; a listed setting is reserved even when the file omits it, and legacy aliases share their canonical setting's owner. pnpm-workspace loads the include index and merges the fragments into one document that every reader consumes: config loading, workspace package discovery, catalogs, changed-catalog detection in the projects filter, and the napi config cache. Without `include` the root text is read as before. Fragments are normalized (merge keys applied, tags dropped, scalar keys stringified) before ownership is checked, so a fragment cannot define a catalog it was not delegated through a tag or a `<<` merge. A relative path in a local fragment is relative to the directory of the fragment's include path, the way a path in the root manifest is relative to the workspace root. The loader re-expresses each fragment's relative paths from the workspace root before merging: path settings, `packages` globs, `pnpmfile`, `patchedDependencies`, a path-like `scriptShell`, and local specifiers in catalogs and `overrides` (re-anchored with the same LocalSpec logic catalogs use). Absolute, `~` and `$VAR` paths are kept. This departs from the RFC, which resolved fragment paths from the root, so a fragment can sit next to the files it names. The RFC change is pnpm/rfcs#40. workspace-manifest-writer routes every write to the owning file. Writes to settings owned by a config dependency fail, `include` itself is never written, included files are never deleted, and symlinked includes are written through. Paths it writes to a fragment, such as patch-commit entries, link: overrides and local catalog entries, are written relative to that fragment. Every file's edit is computed before any file is written, so a rejected edit leaves the workspace unchanged, and a failed write restores the files written before it. A config dependency names its settings file in package.json `pnpm.config`. The entry must stay inside the installed package and may only define delegated settings. Its values are applied at the project layer after config dependencies are installed and before hooks run, so they take effect on the first install too. Installs fail closed when an included package's entry cannot be loaded. `bootConfig` holds the policy (minimumReleaseAge*, trustPolicy*) used to resolve config dependencies and the packageManager pnpm version. Package-owned keys fall back to the values from below the project layer, env and CLI overrides still win, and self-update ignores it.
|
Good idea! |
Summary
Changes how relative paths inside a local fragment of RFC 38 resolve. They are now measured from the directory of the fragment's include path, not from the workspace root.
packages,patchedDependencies,patchesDir,pnpmfile,storeDir, ...), ascriptShellthat contains a separator, andfile:,link:and bare-path specifiers in catalogs andoverrides. Absolute,~and$VARpaths are unchanged. pnpm re-expresses them from the root when merging, so the merged configuration means what the same values would mean in the root manifest.patch-commitentry, is written relative to that fragment.tsconfig.jsonextendsand Docker Composeinclude, which resolve paths from the included file.Why
Root-relative paths keep a setting's meaning when it moves between files, but they stop a fragment from being kept with the files it names. A patch list in
patches/patches.yamlwould have to spellpatches/in every entry. Config dependency entries could only resolve paths from the package, which would give the two kinds of source two rules. Moving a setting between files by hand is rare, and pnpm's own writes already go to the owning file.The implementation is in pnpm/pnpm#16967.
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Summary by CodeRabbit