fix(publish): memoize publish order depth (#36215)