The rotating or wobbling mirror ones use a large area photodiode and scan the laser light so only a small dot is illuminated at a time, and filter out all other light other than the laser light, so can get very good recognition with no degradation from focussing errors. Ones that use a line scanner typically use a barrel shaped lens to focus light onto the CDD, and typically are focussed at infinity for the lens, so will work so long as the barcode is more than about 5cm away for most small cheap plastic lenses. They work so long as the barcode is smaller than the image focussed on the line CCD, and till the space between the smallest feature ( a line representing a 1 bit, either black or white) is less than a single pixel in width. This can give a large range, as you can get 2k line CDD imagers in a small single chip package about a DIP18 long. those are also used in fax machines and digital scanners if they only do a monochrome scan.
You also get 3D scanners which are basically a digital camera and software, and these do a good job on damaged barcodes, as they can often use the undamaged parts of the barcode to recreate the damaged sections, like on a barcode that has a faded part and a good part but which a line scanner cannot read.