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

fix: omit moment-locales from precache #806

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

KaiVandivier
Copy link
Contributor

@KaiVandivier KaiVandivier commented Apr 27, 2023

Intended to help with https://dhis2.atlassian.net/browse/DHIS2-15097
Part of https://dhis2.atlassian.net/browse/LIBS-498

This saves approximately 140 files from the precache, which should speed up SW installation time significantly.

I noticed the moment locales are seldom fetched, and can be cached by the Network First strategy instead to save precaching time.

const restOfManifest = precacheManifest.filter((e) => {
return (
e !== indexHtmlManifestEntry &&
!e.url.startsWith('./static/js/moment-locales/')
Copy link
Member

@Birkbjo Birkbjo Apr 27, 2023

Choose a reason for hiding this comment

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

Would be nice to change this to a pattern-array to make it less hardcoded. Eg.

MANIFEST_EXCLUDE_URL_PATTERNS = [^\.\/static\/js\/moment-locales\/] 

// not sure if ^ (start of string) is necessary now it's a pattern though

return (e !== indexHtmlManifestEntry && 
  MANIFEST_EXCLUDE_URL_PATTERNS.some(p => p.test(e.url))
   )

const entryShouldBeExcluded = CRA_MANIFEST_EXCLUDE_PATTERNS.some(
(pattern) => pattern.test(e.url)
)
if (entryShouldBeExcluded) {
Copy link
Member

Choose a reason for hiding this comment

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

return !entryShouldBeExcluded?

@KaiVandivier KaiVandivier enabled auto-merge (squash) April 27, 2023 13:27
@KaiVandivier KaiVandivier merged commit c8d5494 into master Apr 27, 2023
@KaiVandivier KaiVandivier deleted the fix-omit-moment-locales-from-precache branch April 27, 2023 13:33
dhis2-bot added a commit that referenced this pull request Apr 27, 2023
## [10.3.7](v10.3.6...v10.3.7) (2023-04-27)

### Bug Fixes

* omit `moment-locales` from precache ([#806](#806)) ([c8d5494](c8d5494))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 10.3.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Aug 10, 2023
# [10.4.0-alpha.3](v10.4.0-alpha.2...v10.4.0-alpha.3) (2023-08-10)

### Bug Fixes

* move precache route to reenable navigation handler on login redirects [LIBS-473] ([#809](#809)) ([1ff29b6](1ff29b6))
* **pwa:** avoid crashing when SW is not available [LIBS-499] ([#807](#807)) ([b681022](b681022))
* omit `moment-locales` from precache ([#806](#806)) ([c8d5494](c8d5494))
* **cli:** fix envs to fix plugins in dev ([#799](#799)) ([ba29cea](ba29cea))
* **plugins:** omit launch paths when unused [LIBS-477] ([#791](#791)) ([e49a51f](e49a51f))
* **pwa:** bump ui version for headerbar connection status [LIBS-315] ([#797](#797)) ([61ff0a4](61ff0a4))
* make loading placeholders transparent ([#795](#795)) ([6e64756](6e64756))
* **plugins:** inject precache manifest correctly ([#792](#792)) ([c0d172e](c0d172e))
* **pwa:** add config option to omit files from precache [LIBS-482] ([#793](#793)) ([d089dda](d089dda))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 10.4.0-alpha.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants