Opened 4 weeks ago
Last modified 4 weeks ago
#64222 new feature request
Improve the upgrade process for the Twemoji library
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | 2nd-opinion |
| Focuses: | javascript | Cc: |
Description
The current process for upgrading the Twemoji library is as follows:
- The new image assets from the Twemoji release must be uploaded to the wordpress.org CDN. This must be done before any testing occurs. Hitting the URL where a character is expected to be will prime the CDN's cache and should be viewed as having an indefinite lifespan.
- When only new files/Emoji are added, the previous folder can be used. Since only the new files need to be fetched, it can help to save requests refetching the same asset at a new URL.
- When old files/Emoji are modified and the modifications change the meaning or how the Emoji is interpreted, a new folder should be added to the CDN. For an example of this, see #51356 and the changes to the kneeling Emoji.
- When old files/Emoji are modified and the modifications do not change the meaning or interpretation of the character, a new folder is not always necessary.
- Update the
src/js/_enqueues/vendor/twemoji.jsfile to include the latest changes. There are WP specific changes in this file that must be preserved. - The values of
baseUrl,svgUrl, and$cdn_urlvariables insrc/wp-includes/formatting.phpand$png_cdn/$svg_cdnintests/phpunit/tests/formatting/emoji.phpshould be updated to reflect the new paths for thew.orgCDN locations. - The Twemoji version queried in the
replace:emoji-regexGrunt task found inGruntfile.jsshould be updated to ensure the correct list of characters is retrieved. - Run
npm run grunt precommit:emojito update the list of entities and partials insrc/wp-includes/formatting.php. - The
emojicase within browserSupportsEmoji()` should be updated to test for a character in the most recently supported version of Emoji to ensure all characters are properly displayed. - When a new flag is added or adjusted, the conditions used to the browser properly supports the latest version of Emoji in
src/js/_enqueues/lib/emoji-loader.js` should be examined.- When a new letter locale flag is added, there is a check that should be updated to replace the previous, most recent one (currently Sark as of Emoji 16/[60227]).
- There may be additional edge cases that warrant new checks. For example, England is a country within the United Kingdom and does not have a two letter locale. It's character sequence is represented by
(black flag emoji + [G] + [B] + [E] + [N] + [G]). - The transgender flag is the
(white flag emoji + transgender symbol)combined with either a ZWJ or zero-width space.
- The assertions performed in
Tests_Formatting_Emoji::test_wp_emoji_list_returns_dataare updated to reflect the update being applied.
Other notes:
- The Twemoji library was previously listed as an npm dependency. This changed in [55186] because of the addition of some WordPress specific code to ensure that Emoji replacement does not happen within any element containing the
wp-exclude-emojiclass. - Testing an update to Twemoji prior to the CDN can be done using the Local Twemoji plugin, or by changing the CDN paths to use the raw content URL from GitHub (ie. https://raw.githubusercontent.com/jdecked/twemoji/v17.0.2/assets/72x72/1f004.png provided the release has been tagged, or https://raw.githubusercontent.com/jdecked/twemoji/388f518b756404152f128a3539f5e7f9a6f1ebd6/assets/72x72/1f004.png using the full-length SHA value that points to the commit updating the library to the next version).
Some of the steps above can and should be automated using a build task to help prevent mistakes when upgrading the library. For example, logic can be added to the precommit:emoji task to insert the two WordPress specific changes from [55186] into the final version of the file that's shipped in WordPress. Then, the package can be re-added as to the list of dependencies in the package.json file, and a new emoji-upgrade Grunt task could:
- Update the library to the latest version (if there is one).
- Update the version reference in the
precommit:emojiGrunt task. - Perform the
precommit:emojiGrunt task.
Note: See
TracTickets for help on using
tickets.
I've gone and created a page in the Core Handbook that documents the steps listed above for upgrading the Twemoji library.