compile() returns fn(locals, callback) -- expected, is like pug
https://github.com/pugjs/then-pug/blob/master/packages/then-pug/lib/index.js#L384
compileFile() returns type stream -- unexpected, should be like compile()
https://github.com/pugjs/then-pug/blob/master/packages/then-pug/lib/index.js#L477
Workaround :
import {promises as fs} from 'fs';
async function renderAsync(filepath, locals) {
let options = {filename: filepath};
let fn = pug.compile(await fs.readFile(options.filename, 'utf8'), options);
// promise helper
return new Promise( ret => fn(locals, (e,r) => ret(r)) );
}
let html = await renderAsync('filename', {...locals});