  We introduce the notion of modular $q$-holonomic modules whose fundamental
matrices define a cocycle with improved analyticity properties and show that
the generalised $q$-hypergeometric equation, as well as three key $q$-holonomic
modules of complex Chern--Simons theory are modular. This notion explains
conceptually recent structural properties of quantum invariants of knots and
3-manifolds, and of exact and perturbative Chern--Simons theory, and in
addition provides an effective method to solve the corresponding linear
$q$-difference equations. An alternative title of our paper, emphasising the
equations rather than the modules, is: Modular linear $q$-difference equations.
