A new rigorous approach for precise and efficient calculation of light propagation along nonuniform waveguides is presented. Resonant states of a uniform waveguide, which satisfy outgoingwave boundary conditions, form a natural basis for expansion of the local electromagnetic field. Using such an expansion at fixed frequency, we convert the wave equation for light propagation in a non-uniform waveguide into an ordinary second-order matrix differential equation for the expansion coefficients depending on the coordinate along the waveguide. We illustrate the method on several examples of non-uniform planar waveguides and evaluate its efficiency compared to the aperiodic Fourier modal method and the finite element method, showing improvements of one to four orders of magnitude. A similar improvement can be expected also for applications in other fields of physics showing wave phenomena, such as acoustics and quantum mechanics.