Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable puppeteer and Chromium to work with latest versions of Node. #14

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions functions/screenshot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { builder } = require("@netlify/functions");
const chromium = require("chrome-aws-lambda");
const chromium = require("@sparticuz/chromium");
const puppeteer = require("puppeteer-core");

function isFullUrl(url) {
try {
Expand All @@ -15,7 +16,7 @@ async function screenshot(url, { format, viewport, dpr = 1, withJs = true, wait,
// Must be between 3000 and 8500
timeout = Math.min(Math.max(timeout, 3000), 8500);

const browser = await chromium.puppeteer.launch({
const browser = await puppeteer.launch({
executablePath: await chromium.executablePath,
args: chromium.args,
defaultViewport: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"homepage": "https://github.com/11ty/api-screenshot#readme",
"dependencies": {
"@netlify/functions": "^1.0.0",
"chrome-aws-lambda": "^10.1.0",
"puppeteer-core": "^10.1.0"
"@sparticuz/chromium": "^108.0.0",
"puppeteer-core": "^19.2.2"
}
}