Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: remove util.cjs #14703

Merged
merged 5 commits into from
Jan 25, 2023
Merged

core: remove util.cjs #14703

merged 5 commits into from
Jan 25, 2023

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Jan 24, 2023

(first attempt: #14378)

  • deleted core/util.cjs and accompanying file creation
  • moved report/renderer/util.js to shared/util.js, but kept some stuff in new report/renderer/report-utils.js
  • added report-globals.js, where we can be honest about our globals

@connorjclark connorjclark requested a review from a team as a code owner January 24, 2023 01:24
@connorjclark connorjclark requested review from brendankenny and removed request for a team January 24, 2023 01:24
shared/util.js Outdated Show resolved Hide resolved
shared/util.js Outdated
@@ -832,7 +449,7 @@ const UIStrings = {
/** Label indicating that Lighthouse throttled the page using custom throttling settings. */
runtimeCustom: 'Custom throttling',
};
Util.UIStrings = UIStrings;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings look specific to the report renderer. Would it make more sense for them to live in ReportUtils?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this change, but it required not initializing strings as a copy of UIStrings since that made a cyclic dependency between report-utils.js and report-globals.js. Only matter for test code, which had to be updated.

I then saw a nice cleanup to the globals to provide a apply function to set them all up.

shared/util.js Outdated Show resolved Hide resolved

const {document} = new jsdom.JSDOM().window;
dom = new DOM(document);
detailsRenderer = new DetailsRenderer(dom);
});

after(() => {
Util.i18n = undefined;
Globals.i18n = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about a Globals.clear()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it'd be just for tests - nah

shared/util.js Show resolved Hide resolved
shared/test/util-test.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants