loader: support passing a function returning a promise