-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
A-configArea: configArea: configA-remappingsArea: remappingsArea: remappingsT-featureType: featureType: feature
Description
Component
Forge
Describe the feature you would like
When using Soldeer to manage dependencies, installed packages often contain their own remappings.txt files that reference node_modules/ paths (since they were originally designed for npm/pnpm). When Foundry compiles files within these dependencies, it uses the dependency's local remappings.txt instead of the project's global remappings, causing compilation failures.
Current Behavior:
- Soldeer installs dependencies to
dependencies/folder (e.g.,dependencies/dep-with-node-modules-deps-1.0.0/) - Installed dependencies contain their own
remappings.txtfiles with paths like:solmate/=node_modules/solmate/ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts/ - When Foundry compiles files inside
dependencies/dep-with-node-modules-deps-1.0.0/src/, it uses the dependency'sremappings.txt, not the project's - Since
node_modules/doesn't exist (we're using Soldeer), compilation fails with "No such file or directory" errors
Why This Happens:
- Dependencies are often published as npm packages or git repos with their own build configuration
- Their
remappings.txtassumes npm-stylenode_modules/directory structure - Foundry's remapping resolution is hierarchical - it uses the closest
remappings.txtto the file being compiled - Project-level
remappings.txtdoes NOT override dependency-level ones
Current Workarounds (all problematic):
- Manually edit dependency remappings.txt: Fragile, gets overwritten on
soldeer update - Symlink node_modules: Hacky, breaks clean dependency management
- Define remappings in foundry.toml: Doesn't actually override dependency-level remappings.txt files
Solution
Provide a mechanism to make project-level remappings truly global, overriding any remappings.txt files found in dependencies.
Option A: Soldeer Configuration Flag
Add a soldeer config option to ignore/override dependency remappings:
[soldeer]
remappings_generate = true
remappings_override = true # NEW: Project remappings override dependency remappingsOption B: Foundry Configuration Flag
Add a foundry.toml option to enforce global remappings:
[profile.default]
remappings_scope = "global" # NEW: Use only project-level remappings, ignore dependency remappingsExpected Behavior:
With either of these solutions implemented:
- Developer installs dependencies via soldeer
- Project-level
remappings.txtdefines all import paths using soldeer directory structure - When Foundry compiles files anywhere in the project (including inside dependencies), it uses only the project-level remappings
- Dependencies compile successfully without manual intervention
Benefits:
- ✅ Clean dependency management with soldeer
- ✅ No manual editing of dependency files
- ✅ Works across soldeer updates
- ✅ Predictable, reproducible builds
- ✅ Aligns with soldeer's goal of replacing npm/git submodules
Additional context
No response
Metadata
Metadata
Assignees
Labels
A-configArea: configArea: configA-remappingsArea: remappingsArea: remappingsT-featureType: featureType: feature
Type
Projects
Status
Backlog