I'm working on a Dapp for voting in a municipality and national election. There is a lot of code, and I've met the max limit of the contract size many times but have been able to keep it under the limit by cutting down functions, compress requires error text, move internal functions inline, and other small fixes to reduce size. But now, even if I do everything as efficiently as possible, I still go over the limit, and I'm not done with the Dapp yet. I've used this doc to reduce size: "https://ethereum.org/en/developers/tutorials/downsizing-contracts-to-fight-the-contract-size-limit/#remove-functions" I'm now looking into splitting the contracts into smaller contracts or making a library, but splitting the contracts into smaller ones OR creating a library, still gives the same problem when migrating in truffle. I've read that when using a library, I should avoid internal functions because they are included in the main contract instead of being used from the outside.
If you want to look at my code, check out our repo here: "https://github.com/voljumet/ChainVote/tree/libbie-1" (we have commented out some of the functions to be able to migrate)
Edit: The question: how to use a library, and if I'm doing it correctly, is there something with testing it in truffle that causes the contract to exceed the maximum size?