facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.71k stars 26.85k forks source link

upgrading react-scripts from 3.x to 4.x breaks pwa service workers #11058

Open Ognian opened 3 years ago

Ognian commented 3 years ago

Support for migrating old apps to the new scripts gets more and more complicated and less documented. It is NOT enough just to state that you have changed service workers implementation a small example how to migrate would show that you care about people using this tools in real apps...

Ognian commented 3 years ago

after loosing a couple of hours researching it looks like this is the solution: create a dummy app project somewhere

  1. npx create-react-app xxa --template cra-template-pwa
  2. copy service-worker.js to src
  3. add "workbox-background-sync": "^5.1.4", "workbox-broadcast-update": "^5.1.4", "workbox-cacheable-response": "^5.1.4", "workbox-core": "^5.1.4", "workbox-expiration": "^5.1.4", "workbox-google-analytics": "^5.1.4", "workbox-navigation-preload": "^5.1.4", "workbox-precaching": "^5.1.4", "workbox-range-requests": "^5.1.4", "workbox-routing": "^5.1.4", "workbox-strategies": "^5.1.4", "workbox-streams": "^5.1.4" to dependencies

now it should work

melodyWxy commented 3 years ago

this kind of support seems to require users to do too much that compared with previous versions.

So is there any plan to update the more friendly support for service worker in the future version? I mean, users can still use it out of the box.


It's like creating the file who named '/serviceWorker.js' and using them in '/index.js' ?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

ahmadi-akbar commented 2 years ago

same here