-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @cypress-audit/lighthouse@1.4.2 for the project I'm working on.
I got an error when I upgraded lighthouse to version 12.x and the error was "lighthouseLib is not a function"
Here is the diff that solved my problem:
diff --git a/node_modules/@cypress-audit/lighthouse/src/task.js b/node_modules/@cypress-audit/lighthouse/src/task.js
index 72a6526..5553930 100644
--- a/node_modules/@cypress-audit/lighthouse/src/task.js
+++ b/node_modules/@cypress-audit/lighthouse/src/task.js
@@ -1,13 +1,8 @@
-const lighthouseLib = require("lighthouse/core/index.cjs").legacyNavigation;
-const {
- computeCategories,
- computeAudits,
- compareWithThresholds,
-} = require("./helpers");
+const { computeCategories, computeAudits, compareWithThresholds } = require('./helpers');
const lighthouse =
(callback) =>
- ({ url, thresholds, opts = {}, config }) => {
+ async ({ url, thresholds, opts = {}, config }) => {
if (global.cypress_audit_port) {
opts.port = global.cypress_audit_port;
@@ -19,10 +14,13 @@ const lighthouse =
opts.disableStorageReset = true;
}
- return lighthouseLib(url, opts, config).then((results) => {
- if (callback) {
- callback(results);
- }
+ // Use dynamic import for 'lighthouse'
+ const lighthouse = (await import('lighthouse')).default;
+
+ return lighthouse(url, opts, config).then((results) => {
+ if (callback) {
+ callback(results);
+ }
const computedAudits = computeAudits(results.lhr.audits);
const computedCategories = computeCategories(results.lhr.categories);This issue body was partially generated by patch-package.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels