Volume measurements of herbs are hopelessly imprecise to begin with; what you actually measure as 1/4 cup depends entirely on how tightly you pack them, how wet the leaves are, even the size/shape of your measuring cup or spoon. When given a measurement like that, you should always treat it as a rough guideline; don't worry about being exact, it's not necessary in this recipe.
That said, what it actually means is that you should measure out the 1/4 cup and then shred them. Another example of this type of language is when you see something like "4 tbsp of vegetable oil, divided" - that always means you measure out the 4 tbsp and then divide into two portions, not measure out two separate portions of 4 tbsp each.
So measure it first, then shred it. If you were supposed to shred it first, it would say "1/4 cup shredded fresh basil leaves" instead. There is an appreciable difference as to how much basil you'll end up with, but again, you've been given a very rough measurement to begin with, so treat it accordingly, and don't worry if you've got a little extra or a little less. The most reliable way to know if you've got the right amount is to simply taste it.