Skip to content

Commit f831eb1

Browse files
authored
fix(deps): Upgrade puppeteer using cache utils (#540)
* Upgrade puppeteer, use cache-utils * try getting homedir in es6 way * Add some log lines
1 parent dd35a17 commit f831eb1

File tree

3 files changed

+65
-38
lines changed

3 files changed

+65
-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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { join } from 'path';
2+
import { homedir } from 'os';
3+
14
import chalk from 'chalk';
25
import * as dotenv from 'dotenv';
36

@@ -9,7 +12,21 @@ import runAudit from './lib/run-audit/index.js';
912

1013
dotenv.config();
1114

15+
const puppeteerCacheDir = join(homedir(), '.cache', 'puppeteer');
16+
17+
export const onPreBuild = async ({ utils } = {}) => {
18+
console.log('Restoring Lighthouse cache...');
19+
// Puppeteer relies on a global cache since v19.x, which otherwise would not be persisted in Netlify builds
20+
await utils?.cache.restore(puppeteerCacheDir);
21+
console.log('Lighthouse cache restored');
22+
};
23+
1224
export const onPostBuild = async ({ constants, utils, inputs } = {}) => {
25+
// Persist Puppeteer cache for subsequent builds/plugin runs
26+
console.log('Persisting Lighthouse cache resources...');
27+
await utils?.cache.save(puppeteerCacheDir);
28+
console.log('Lighthouse cache resources persisted');
29+
1330
const { failBuild, show } = getUtils({ utils });
1431
let errorMetadata = [];
1532

0 commit comments

Comments
 (0)