Skip to content

Commit f06fb5d

Browse files
committed
Upgrade puppeteer, use cache-utils
1 parent dd35a17 commit f06fb5d

File tree

3 files changed

+59
-38
lines changed

3 files changed

+59
-38
lines changed

package-lock.json

Lines changed: 47 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"express": "^4.17.1",
3030
"html-minifier": "^4.0.0",
3131
"lighthouse": "^9.6.3",
32-
"puppeteer": "^18.0.0"
32+
"puppeteer": "^19.5.2"
3333
},
3434
"engines": {
3535
"node": ">=14.15 <19"

src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { join } from 'path';
2+
13
import chalk from 'chalk';
24
import * as dotenv from 'dotenv';
35

@@ -8,8 +10,17 @@ import getSettings from './lib/get-settings/index.js';
810
import runAudit from './lib/run-audit/index.js';
911

1012
dotenv.config();
13+
const puppeteerCacheDir = join(__dirname, '.cache', 'puppeteer');
14+
15+
export const onPreBuild = async ({ utils } = {}) => {
16+
// Puppeteer relies on a global cache since v19.x, which otherwise would not be persisted in Netlify builds
17+
await utils?.cache.restore(puppeteerCacheDir);
18+
};
1119

1220
export const onPostBuild = async ({ constants, utils, inputs } = {}) => {
21+
// Persist Puppeteer cache for subsequent builds/plugin runs
22+
await utils?.cache.save(puppeteerCacheDir);
23+
1324
const { failBuild, show } = getUtils({ utils });
1425
let errorMetadata = [];
1526

0 commit comments

Comments
 (0)