Refactor how Require, ModuleProvider, and friends.

This adds support for module.id and lays the groundwork for dealing with
cyclical dependencies.