When you build PackageDepA, that script rewrites PackageDepA to be a dynamic library. But you don't rewrite PackageDepRoot to dynamic, so it will be statically linked.
You can't archive it without the other module is because you are not using @_implementationOnly imports (or internal imports: swift-evolution/proposals/0409-access-level-on-imports.md at main · swiftlang/swift-evolution · GitHub ).
So either rewrite both Package.swift to dynamic when building PackageDepA or use the proper imports in PackageDepA, so it doesn't expose PackageDepRoot as a required dependency.