Company
Date Published
Author
George MacKerron
Word count
1600
Language
English
Hacker News points
None

Summary

George MacKerron illustrates techniques to run NPM packages outside of Node.js environments, such as Vercel Edge Functions and web browsers, using esbuild to create runnable bundles. He highlights the challenges posed by Node-specific features in NPM packages, which can hinder their use on non-Node platforms. MacKerron shares strategies like using third-party shim libraries for global objects, creating stub packages for less critical Node libraries, and re-implementing Node features for essential functionalities. He also discusses package masquerading to substitute dependencies, demonstrating these methods in the development of the @neondatabase/serverless driver, adapted from the node-postgres pg package, to make Postgres usable on serverless platforms.