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

refactor(pwa): simplify registerSW code, fix ESLint errors #7579

Merged
merged 1 commit into from Jun 7, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Before we aggressively bump our browserslist to only support modern browsers, or before IE11 dies out from the default browserslist inclusion, we must not use async-await in the client bundle to reduce bundle size.

Floating promises are a problem if async-await is not used; however, this can be greatly remedied by using TS-ESLint's no-floating-promises rule. We are still not ready to enable type-aware lint rules in CI, but I'm already working with it locally.

As a side-fix, I've fixed some new ESLint errors as they emerged after the recent code changes.

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Jun 7, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 7, 2022
@netlify
Copy link

netlify bot commented Jun 7, 2022

[V2]

Name Link
🔨 Latest commit ac892eb
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/629f4f96857a360008a6a3a2
😎 Deploy Preview https://deploy-preview-7579--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 86 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 86 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

Size Change: -32 B (0%)

Total Size: 801 kB

Filename Size Change
website/build/assets/js/main.********.js 603 kB -32 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.6 kB
website/build/assets/css/styles.********.css 106 kB
website/build/index.html 38.9 kB

compressed-size-action

@Josh-Cena
Copy link
Collaborator Author

😨 Why only -62B... That seems like optimization elsewhere... I thought it would at least remove some regeneratorRuntime calls...

@Josh-Cena Josh-Cena changed the title refactor: avoid using async-await in client module, fix ESLint errors refactor(pwa): simplify registerSW code, fix ESLint errors Jun 7, 2022
@Josh-Cena
Copy link
Collaborator Author

Josh-Cena commented Jun 7, 2022

OK, it seems avoiding async-await does save bundle size, but very marginal, because minification is sufficient to reduce all the generator calls to a few bytes. Takeaway is don't try to take the job of the minifier.

Still going to merge it because of the ~70 line reduction in length.

@Josh-Cena Josh-Cena merged commit 7869e74 into main Jun 7, 2022
@Josh-Cena Josh-Cena deleted the jc/refactor branch June 7, 2022 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants