Edit: Removed incorrect claim that |B| > |A| sufficed for the counter example.
It's also the definitions the book supplies though (and the standard ones). Mathematics works over definitions. Everyone is free to do math over whatever definitions they want - but what is or isn't true follows from them. Lots of definitions and theorems exclude things like empty-set cases because they're weird, but that has to be explicit (otherwise someone will apply a theorem to the empty set and it will lead them to incorrect conclusions).
No, empty A is critical to the counterexample. In your example, g(x) = 1 is a left inverse.
The point is you either send an element of the codomain to its (unique by injectivity) preimage if it's in the image, or to an arbitrary element of A if it's not, and that's a left inverse. But then if B has an element, A needs one for you to pick your arbitrary target.
In a sense, your claim that the problem is a smaller domain than codomain does contribute though; if f is also surjective, then this case can't happen, so bijective iff invertible (the empty function is vacuously bijective and its own inverse).