Resurgence and modularity in string theory