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 Chrome Launcher
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// lighthouse is ESM only, imported dynamically
|
||||
const chromeLauncher = require('chrome-launcher');
|
||||
// lighthouse & chrome-launcher are ESM only/compatible, imported dynamically
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
@@ -11,8 +10,9 @@ const { v4: uuidv4 } = require('uuid');
|
||||
* @returns {Promise<object>} - Test results
|
||||
*/
|
||||
async function runTest(url, options = {}) {
|
||||
// Dynamically import Lighthouse (ESM)
|
||||
// Dynamically import Lighthouse & Chrome Launcher (ESM)
|
||||
const { default: lighthouse } = await import('lighthouse');
|
||||
const { default: chromeLauncher } = await import('chrome-launcher');
|
||||
|
||||
const isMobile = options.isMobile ?? true; // Default to mobile
|
||||
const reportDir = path.join(__dirname, '..', 'reports');
|
||||
|
||||
Reference in New Issue
Block a user