Add production-dependency example
This commit is contained in:
parent
dc0a61daa1
commit
b8bfaffda1
|
|
@ -10,3 +10,4 @@ _/amazon/samconfig.toml
|
||||||
_/amazon/.aws-sam
|
_/amazon/.aws-sam
|
||||||
*.tar
|
*.tar
|
||||||
*.tgz
|
*.tgz
|
||||||
|
examples/**/package-lock.json
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
const puppeteer = require("puppeteer-core");
|
||||||
|
const chromium = require('@sparticuz/chromium');
|
||||||
|
|
||||||
|
const handler = async () => {
|
||||||
|
try {
|
||||||
|
const browser = await puppeteer.launch({
|
||||||
|
args: chromium.args,
|
||||||
|
defaultViewport: chromium.defaultViewport,
|
||||||
|
executablePath: await chromium.executablePath(),
|
||||||
|
headless: chromium.headless,
|
||||||
|
ignoreHTTPSErrors: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const page = await browser.newPage();
|
||||||
|
|
||||||
|
await page.goto("https://www.example.com", { waitUntil: "networkidle0" });
|
||||||
|
|
||||||
|
console.log("Chromium:", await browser.version());
|
||||||
|
console.log("Page Title:", await page.title());
|
||||||
|
|
||||||
|
await page.close();
|
||||||
|
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(error.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handler();
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "chromium-production-dependency",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "This package demonstrates using @sparticuz/chromium as a production dependency. WARNING: This package is over 50 megabytes and will likely not deploy using anything other than self-host",
|
||||||
|
"license": "ISC",
|
||||||
|
"author": {
|
||||||
|
"name": "Kyle McNally"
|
||||||
|
},
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@sparticuz/chromium": "110.0.0",
|
||||||
|
"puppeteer-core": "19.6.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue