hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

hardhat compile and test contracts

Open wighawag opened this issue 9 months ago • 1 comments

Feedback

Currently it seems that hardhat compile do not compile test contract

but it compiles them when running test unless --no-compile is specified in which case it won't compile them

this means that if you want to control compilation and use --no-compile the only way to compile the test contract is to use

hardhat compile src/**/*.sol (assuming contract source is src)

but this behaviot depends on the shell and can cause problem where this command is specified in npm/package.json scripts

it would be great to have an option to compile all contracts

wighawag avatar Mar 15 '25 21:03 wighawag

I guess a simple way to solve this is for hardhat compile to support globs

wighawag avatar Mar 15 '25 22:03 wighawag

We need some design work here. Maybe two apis in the build system: one for tests and other for standard contracts. Then we need to decide what the default for compile is.

Perhaps subtasks, e.g. npx hardhat compile tests

kanej avatar Jul 15 '25 16:07 kanej