Using PDFKit in a netlify function

Hi @stordahl

The cause is related to UnicodeTrie of which there are two references in the shipped function

var trie = new UnicodeTrie(fs.readFileSync(__dirname + "/data.trie"));

// more ...

var trie = new UnicodeTrie(require("fs").readFileSync(__dirname + "/data.trie"));

There is an issue here though it is related specifically to Webpack, and another here which doesn’t have a solution per se. unicode-trie is dependency of both fontkit and linebreak which are in turn both dependencies of pdfkit. I did try the code from this thread (which the OP appears to have gotten working) with the same result as well as trying this code.