Skip to content

Conversation

@adamraine
Copy link
Contributor

@adamraine adamraine commented Oct 7, 2021

Imports _formatMessage into the flow report.

format.js doesn't work in ESM because of shit like __dirname and fs. Luckily, the functions we need don't use any of that, so splitting them out into a separate file (message.js) works just fine. I'm not married to that name though. Other option would be to cut __dirname and fs out using rollup.

If these changes seem sane to everyone, I'll go ahead an finish translating the rest of the strings + test cases.

@connorjclark
Copy link
Collaborator

connorjclark commented Oct 7, 2021

We need rollup brfs to inline the fs stuff (existing brfs plugin doesnt work for esm).

You could do what build-viewer does to work around this for now.

@adamraine
Copy link
Contributor Author

We need rollup brfs to inline the fs stuff (existing brfs plugin doesnt work for esm).

We already include the localized strings in the flow report. If we inline the file we'll just be adding the again. _formatMessage doesn't access the localized strings on it's own so this method works, or we could shim 'fs'.

@adamraine adamraine marked this pull request as ready for review October 11, 2021 16:21
@adamraine adamraine requested a review from a team as a code owner October 11, 2021 16:21
@connorjclark
Copy link
Collaborator

connorjclark commented Oct 11, 2021

Oh, I meant just inlining the list of "CANONICAL_LOCALES", which flow report doesn't necessarily need anyhow, so you could also just not (there is an explicit check at runtime for whether fs exists).

If you shim locales.js to an empty object (see https://github.com/GoogleChrome/lighthouse/blob/master/build/build-viewer.js#L67) and replace __dirname, you should be able to avoid restructuring shared/localization.

cc @brendankenny on whether or not splitting up format.js makes sense.

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM! Exciting to get message formatting in a report.

Bundled output look ok?

@adamraine
Copy link
Contributor Author

Bundled output look ok?

Ya locales are included, but only once.

@adamraine adamraine deleted the flow-formatted-strings branch October 14, 2021 21:25
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.

3 participants