Instead of actual parts, a ship might carry 3-D printers and bags of various powdered ingredients, and simply download the design files needed to print items as necessary.
Today's ships and subs are not going to make everything they need on board, although it is tempting to imagine better uses for freed-up storage spaces.