What I learned:
- Puppeteer doesn’t work out of the box in Vercel. An AWS Lambda-friendly chromium needs to be installed
chrome-aws-lambda
is outdated and is replaced with @sparticuz/chromium
- Using different puppeteer version for localhost and depoyment as sparticuz’s chromium doesn’t work on Mac apple processor
- Different ways to load up the chromium package and perhaps lazy load it
- fetching chromium would eat up bandwidth so 60mb function is preferred right now.
- Different ways to load up large (5.8mb) HTML file in Puppeteer.
- Loading HTML via /public folder eats Vercel’s bandwidth
- Setting up
raw-loader
and directly importing it to route.ts using the webpack loader config in next.config.mjs
- Any statements written in the
eval
function is run inside the puppet browser.
- Print all puppet browser logs into the server logs
- Passing values into the puppet browser
- Import issues with mermaid-cli since maybe they expect a global install → opted for minimal recreation of renderCode instead by looking at the source code.
Attributions/Source Material