mirror of
https://github.com/DeNNiiInc/Web-Page-Performance-Test.git
synced 2026-04-17 20:05:58 +00:00
Fix ERR_REQUIRE_ESM: Use dynamic import for uuid
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
// lighthouse & chrome-launcher are ESM only/compatible, imported dynamically
|
// lighthouse, chrome-launcher, uuid are ESM only/compatible, imported dynamically
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { v4: uuidv4 } = require('uuid');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a performance test using Lighthouse
|
* Run a performance test using Lighthouse
|
||||||
@@ -10,9 +9,10 @@ const { v4: uuidv4 } = require('uuid');
|
|||||||
* @returns {Promise<object>} - Test results
|
* @returns {Promise<object>} - Test results
|
||||||
*/
|
*/
|
||||||
async function runTest(url, options = {}) {
|
async function runTest(url, options = {}) {
|
||||||
// Dynamically import Lighthouse & Chrome Launcher (ESM)
|
// Dynamically import dependencies (ESM)
|
||||||
const { default: lighthouse } = await import('lighthouse');
|
const { default: lighthouse } = await import('lighthouse');
|
||||||
const { default: chromeLauncher } = await import('chrome-launcher');
|
const { default: chromeLauncher } = await import('chrome-launcher');
|
||||||
|
const { v4: uuidv4 } = await import('uuid');
|
||||||
|
|
||||||
const isMobile = options.isMobile ?? true; // Default to mobile
|
const isMobile = options.isMobile ?? true; // Default to mobile
|
||||||
const reportDir = path.join(__dirname, '..', 'reports');
|
const reportDir = path.join(__dirname, '..', 'reports');
|
||||||
|
|||||||
Reference in New Issue
Block a user