@jsenv/lighthouse-impact 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -138,7 +138,7 @@ _report_lighthouse_impact.mjs_
138
138
  * This file is executed by lighthouse_impact.yml GitHub workflow.
139
139
  * - it generates lighthouse report before and after merging a pull request
140
140
  * - Then, it creates or updates a comment in the pull request
141
- * See https://github.com/jsenv/workflow/tree/main/packages/jsenv-performance-impact
141
+ * See https://github.com/jsenv/workflow/tree/main/packages/performance-impact
142
142
  */
143
143
 
144
144
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/lighthouse-impact",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "Package description",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -11,7 +11,7 @@
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "https://github.com/jsenv/workflow",
14
- "directory": "packages/jsenv-lighthouse-impact"
14
+ "directory": "packages/lighthouse-impact"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=16.13.0"
@@ -37,9 +37,9 @@
37
37
  "dependencies": {
38
38
  "@jsenv/abort": "4.2.4",
39
39
  "@jsenv/dynamic-import-worker": "1.1.0",
40
- "@jsenv/filesystem": "4.1.9",
41
- "@jsenv/github-pull-request-impact": "1.7.1",
42
- "@jsenv/log": "3.3.3",
43
- "lighthouse": "9.6.8"
40
+ "@jsenv/filesystem": "4.2.3",
41
+ "@jsenv/github-pull-request-impact": "1.7.2",
42
+ "@jsenv/log": "3.3.4",
43
+ "lighthouse": "10.2.0"
44
44
  }
45
45
  }
@@ -110,7 +110,7 @@ export const generateLighthouseReport = async (
110
110
  throw e
111
111
  }
112
112
 
113
- const lighthouseReport = reduceToMedianReport(reports)
113
+ const lighthouseReport = await reduceToMedianReport(reports)
114
114
  if (log) {
115
115
  logger.info(formatReportAsSummaryText(lighthouseReport))
116
116
  }
@@ -124,7 +124,7 @@ export const generateLighthouseReport = async (
124
124
  }
125
125
  if (htmlFileUrl) {
126
126
  assertAndNormalizeFileUrl(htmlFileUrl)
127
- const html = formatReportAsHtml(lighthouseReport)
127
+ const html = await formatReportAsHtml(lighthouseReport)
128
128
  writeFileSync(htmlFileUrl, html)
129
129
  if (htmlFileLog) {
130
130
  logger.info(`-> ${htmlFileUrl}`)
@@ -1,9 +1,5 @@
1
- import { createRequire } from "node:module"
2
-
3
- const require = createRequire(import.meta.url)
4
-
5
1
  export const runLighthouse = async (url, lighthouseOptions) => {
6
- const lighthouse = require("lighthouse")
2
+ const { default: lighthouse } = await import("lighthouse")
7
3
  const results = await lighthouse(url, undefined, lighthouseOptions)
8
4
  // use results.lhr for the JS-consumeable output
9
5
  // https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts
@@ -19,10 +15,8 @@ export const runLighthouse = async (url, lighthouseOptions) => {
19
15
  return lhr
20
16
  }
21
17
 
22
- export const reduceToMedianReport = (lighthouseReports) => {
23
- const {
24
- computeMedianRun,
25
- } = require("lighthouse/lighthouse-core/lib/median-run.js")
18
+ export const reduceToMedianReport = async (lighthouseReports) => {
19
+ const { computeMedianRun } = await import("lighthouse/core/lib/median-run.js")
26
20
  return computeMedianRun(lighthouseReports)
27
21
  }
28
22
 
@@ -39,8 +33,10 @@ export const formatReportAsJson = (lighthouseReport) => {
39
33
  return json
40
34
  }
41
35
 
42
- export const formatReportAsHtml = (lighthouseReport) => {
43
- const ReportGenerator = require("lighthouse/report/generator/report-generator.js")
36
+ export const formatReportAsHtml = async (lighthouseReport) => {
37
+ const { ReportGenerator } = await import(
38
+ "lighthouse/report/generator/report-generator.js"
39
+ )
44
40
  const html = ReportGenerator.generateReportHtml(lighthouseReport)
45
41
  return html
46
42
  }
@@ -109,7 +109,7 @@ export const reportLighthouseImpactInGithubPullRequest = async ({
109
109
  }
110
110
  },
111
111
  generatedByLink: {
112
- url: "https://github.com/jsenv/workflow/tree/main/packages/jsenv-lighthouse-impact",
112
+ url: "https://github.com/jsenv/workflow/tree/main/packages/lighthouse-impact",
113
113
  text: "@jsenv/lighthouse-impact",
114
114
  },
115
115
  runLink,