How to exclude dependencies from a dependency in package.json?

I have 3 repos, repo A is a library used by both repo B and C. But repo A has some dependencies that’s not needed by repo C.

I want to reduce size of repo C by remove some packages but since repo B need these dependencies I can’t just delete them from repo A.

Will move these dependencies to devDependencies or optionalDependencies help reduce the size of repo C?