NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7.26k stars 1.4k forks source link

Change how config files are searched in upper directories #3477

Open fvictorio opened 1 year ago

fvictorio commented 1 year ago

The way Hardhat currently searches for a config is:

This is problematic in some scenarios. Instead, we should search for any possible config file in the current directory, and then in the parent directory, and so on.

I believe this is technically a breaking change, so I'm going to mark it as so. But you could argue it's a bug fix. If a lot of people need this and we are not about to release a new major soon, I could consider doing it in v2, since I feel it's unlikely to break someone's workflow. But, you know...

neila commented 8 months ago

I'm experiencing this precise issue right now, and would also love to see this search algorithm improved. I am working with a hardhat with typescript setup while referring to multiple submodules of smart contract contract libraries. However, most if not all of the contracts in the submodules are developed using the javascript setup (which is fair given the adoption of typescript in smart contract development is a relatively recent scene). When I try to run some of the testing scripts in the submodules, they don't work, because instead of applying the actual hardhat.config.js files from each submodule, it applies the .ts file from my main repository.

Since each project is well-contained, hardhat could just apply the closest config file (and by that I mean in each project's root) and this wouldn't be a problem. Given the contained nature of node/hardhat environment, I think it would make a lot more sense to use closest config file, regardless of js/ts, allowing for a much more modular dev experience.

fvictorio commented 8 months ago

Yeah, that makes sense. I initially marked this as a breaking change, but I would be fine with filing this under "well, it's actually a fix!", if this is a big issue for your project.