Skip to content

Commit

Permalink
core(lighthouse-logger): convert to ES modules (#13720)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Mar 7, 2022
1 parent 44cf433 commit 57c7fea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions build/build-bundle.js
Expand Up @@ -131,6 +131,9 @@ async function build(entryPath, distPath, opts = {minify: true}) {
// This package exports to default in a way that causes Rollup to get confused,
// resulting in MessageFormat being undefined.
'require(\'intl-messageformat\').default': 'require(\'intl-messageformat\')',
// Below we replace lighthouse-logger with a local copy, which is ES modules. Need
// to change every require of the package to reflect this.
'require(\'lighthouse-logger\');': 'require(\'lighthouse-logger\').default;',
// Rollup doesn't replace this, so let's manually change it to false.
'require.main === module': 'false',
// TODO: Use globalThis directly.
Expand Down
12 changes: 5 additions & 7 deletions lighthouse-logger/index.js
Expand Up @@ -5,11 +5,11 @@
*/
'use strict';

const process = require('process');
const debug = require('debug');
const marky = require('marky');
import process from 'process';
import debug from 'debug';
import * as marky from 'marky';
import {EventEmitter} from 'events';

const EventEmitter = require('events').EventEmitter;
const isWindows = process.platform === 'win32';

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

class Log {
export default class Log {
static _logToStdErr(title, argsArray) {
const log = Log.loggerfn(title);
log(...argsArray);
Expand Down Expand Up @@ -239,5 +239,3 @@ Log.takeTimeEntries = () => {
return entries;
};
Log.getTimeEntries = () => marky.getEntries();

module.exports = Log;
1 change: 1 addition & 0 deletions lighthouse-logger/package.json
@@ -1,4 +1,5 @@
{
"type": "module",
"name": "lighthouse-logger",
"version": "1.3.0",
"license": "Apache-2.0",
Expand Down

0 comments on commit 57c7fea

Please sign in to comment.