You'd have to mount it on a wire a bit past the end of the barrel, or custom create a barrel that expands toward the end. Depends on whether dispelling the magic is an instant transformation, or if it "grows" at some rate.
If you can shrink and expand stuff instantly, the thing getting bigger or smaller is the least useful part of that spell. You wouldn't even need gunpowder to launch stuff, put a shrunk cannonball against a wall, expand it, hope the wall holds and it's the cannonball that has to accelerate to light speed to not be in the same place as the wall. Or get a giant explosion, that's more likely.
That does raise some interesting questions. To break as few laws of physics as possible, we can assume there's no truly "instant" transformation. The question then becomes how quickly the transformation happens, and whether the transformation is linear with respect to radius, volume, or mass.
I feel like Randall Munroe would have a good answer.
Meme is still correct though as that's my face while calculating what to change so they don't TPK or something when they try it on the next encounter....
Rogue fires gun. Cannonball grows and shatters the gun. Gun pieces fall to floor in front of rogue. If you look, the ring is still in the wreckage, and still usable. Enemy spends a turn just looking at the rogue in amusement. Turn after goes as usual.