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

Retry: Remove node's url from lib/i18n-utils #38683

Merged
merged 3 commits into from
Jan 7, 2020

Conversation

akirk
Copy link
Member

@akirk akirk commented Jan 7, 2020

Retry of #38560 with a workaround for the following Safari bug (see #38668).

result = new URL( 'http://__domain__.invalid' );
result.port = '';
console.log( result.port )

Safari 13.0.4 returns: "0", all other browsers return "".

This is an invalid implementation in Safari (almost 6 year old Webkit bug 127958) since the spec says:

If the given value is the empty string, then set context object's url's port to null.

The workaround it to simply only assign changed values, and not re-assign equal ones.

@akirk akirk requested a review from sgomes January 7, 2020 10:13
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Jan 7, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~1962 bytes removed 📉 [gzipped])

name                   parsed_size           gzip_size
entry-domains-landing      -9436 B  (-1.7%)    -3529 B  (-2.4%)
entry-main                 +2436 B  (+0.2%)     +770 B  (+0.2%)
entry-login                +2436 B  (+0.2%)     +797 B  (+0.3%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~164 bytes removed 📉 [gzipped])

name         parsed_size           gzip_size
post-editor       -551 B  (-0.0%)     -164 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@akirk
Copy link
Member Author

akirk commented Jan 7, 2020

Thanks @sgomes for taking it from here!

Now handles origin and searchParams appropriately, too.
Copy link
Contributor

@sgomes sgomes left a comment

Choose a reason for hiding this comment

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

Thank you for coming up with a fix, @akirk! 🙇

Your code looks good! I added some extra improvements as I wrote the tests and found bits missing.

const value = parts[ part ];
// Avoid some implementation bugs, e.g. https://bugs.webkit.org/show_bug.cgi?id=127958.
if ( value && value !== result[ part ] ) {
result[ part ] = value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that I had to move the value to a constant to make TypeScript happy, otherwise it would complain about it possibly being undefined, even though we were checking if ( parts[ part ] && ... ) 🤷‍♂

@sgomes sgomes added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 7, 2020
@sgomes
Copy link
Contributor

sgomes commented Jan 7, 2020

Adding Needs Review label to trigger tests.

@sgomes
Copy link
Contributor

sgomes commented Jan 7, 2020

(Deleted some comments meant for another PR)

@sgomes
Copy link
Contributor

sgomes commented Jan 7, 2020

The E2E failures appear to be unrelated, and the issue in #38668 does not appear to manifest in this version.

@sgomes sgomes merged commit 9adfbe4 into master Jan 7, 2020
@sgomes sgomes deleted the retry/update/remove-url-from-i18n-utils branch January 7, 2020 12:56
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 7, 2020
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