Skip to content

Commit 57c7fea

Browse files
authoredMar 7, 2022
core(lighthouse-logger): convert to ES modules (#13720)
1 parent 44cf433 commit 57c7fea

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed
 

‎build/build-bundle.js

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ async function build(entryPath, distPath, opts = {minify: true}) {
131131
// This package exports to default in a way that causes Rollup to get confused,
132132
// resulting in MessageFormat being undefined.
133133
'require(\'intl-messageformat\').default': 'require(\'intl-messageformat\')',
134+
// Below we replace lighthouse-logger with a local copy, which is ES modules. Need
135+
// to change every require of the package to reflect this.
136+
'require(\'lighthouse-logger\');': 'require(\'lighthouse-logger\').default;',
134137
// Rollup doesn't replace this, so let's manually change it to false.
135138
'require.main === module': 'false',
136139
// TODO: Use globalThis directly.

‎lighthouse-logger/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
'use strict';
77

8-
const process = require('process');
9-
const debug = require('debug');
10-
const marky = require('marky');
8+
import process from 'process';
9+
import debug from 'debug';
10+
import * as marky from 'marky';
11+
import {EventEmitter} from 'events';
1112

12-
const EventEmitter = require('events').EventEmitter;
1313
const isWindows = process.platform === 'win32';
1414

1515
// @ts-expect-error: process.browser is set via Rollup.
@@ -55,7 +55,7 @@ const loggersByTitle = {};
5555
const loggingBufferColumns = 25;
5656
let level_;
5757

58-
class Log {
58+
export default class Log {
5959
static _logToStdErr(title, argsArray) {
6060
const log = Log.loggerfn(title);
6161
log(...argsArray);
@@ -239,5 +239,3 @@ Log.takeTimeEntries = () => {
239239
return entries;
240240
};
241241
Log.getTimeEntries = () => marky.getEntries();
242-
243-
module.exports = Log;

‎lighthouse-logger/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"type": "module",
23
"name": "lighthouse-logger",
34
"version": "1.3.0",
45
"license": "Apache-2.0",

0 commit comments

Comments
 (0)
Please sign in to comment.