Require Buffer rather than expecting a global
This tiny PR adds const Buffer = require('buffer').Buffer; to the top of lib/util.js, so that util.js can call Buffer.from without relying on Buffer being a global. This allows code bundlers and other static analyzers to detect the use of Buffer and shim it (e.g. with npm:buffer) if it is not part of the target environment, such as when bundling for web browsers.
I suspect this approach might satisfy some of the people describing hold-ups in #68. I have been able to use this fork to bundle gray-matter with esbuild without error.
I would be comfortable publishing this with a patch-level version bump.
I just upgraded react-scripts to v5 and hit #68. For now, I added temporarily global.Buffer = global.Buffer || require('buffer').Buffer; in my codebase, but would appreciate this PR be merged to solve the issue.
@jonschlinkert Are you still maintaining this library? It would be quite helpful to get this merged so it can work with modern WebPack 5+, Vite, and so on, which no longer include node shims by default. There are also several other PRs that help keep this library in shape that you might want look at.