Comments (7)
What I remember trying to do when we set up these templates was to leave out all of the Workbox dependencies, because the react-scripts
package.json
already depends on workbox-webpack-plugin
, which in turn depends on the individual Workbox libraries.
My recollection is that leaving out those explicitly dependencies led to warning messages during either install or build time... I think having to do with yarn
not being happy that the project relied on dependencies that were inherited instead of explicitly listed? This was a while ago so I'm afraid I'm foggy on some of the details as to what broke.
from pwa.
Hello @moltenice!
Can you provide some additional context about which version of c-r-a
you're using? Where are you seeing the error—during compilation, or in your editor?
c-r-a
v4.x should be using Workbox v5.1.4, and that project has ExpirationPlugin
defined as implementing WorkboxPlugin
. Workbox itself wouldn't compile if that weren't the case, so I'm not entirely sure how you're ending up with that error.
from pwa.
Hello @jeffposnick! Thanks for getting back to me.
Based on your response I did some digging, and it looks like this is the culprit: https://www.npmjs.com/package/workbox-expiration/v/6.1.5
This version is the current version at the time of this post.
Reverting back to 5.1.4 fixes it.
Example package.json to replicate the exact error I am getting in my original message:
{
"name": "typescript-example",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.23",
"@types/node": "^12.20.13",
"@types/react": "^16.14.6",
"@types/react-dom": "^16.9.13",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.2.4",
"web-vitals": "^0.2.4",
"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": "^6.1.5",
"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"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Hope that sheds some light :)
from pwa.
Yes, so that does explain what happened. You can't mix-and-match different versions of the Workbox libraries in the same service worker.
I'm going to close this, because I'm assuming that this isn't something that needs to be fixed in this project itself—there should be only v5.1.4
used across all of the Workbox libraries by default, which are pulled in via https://github.com/facebook/create-react-app/blob/7bdeced8495370b683c08b86bc84b66af83f2f0a/packages/react-scripts/package.json#L89
from pwa.
@jeffposnick as far as I know, when using npx create-react-app my-app --template pwa-typescript
, it doesn't use "workbox-webpack-plugin" but directly puts in the dependencies themselves.
That package.json I attached above was what was made using this command (and then I manually changed "workbox-expiration" to recreate the issue I was having)
Also, I think 5.1.4 got updated by itself because of an npm audit fix
run, but I could be wrong! Just letting you know in case there was a security fix done in v6 but v5 was left out!
from pwa.
Hello @moltenice—it's definitely possible that manually running npm audit fix
might have caused some of the dependencies to get out of sync. That's also mostly out of our control in this project, as far as I can tell. As long as doing the default npx create-react-app my-app --template pwa-typescript
led to an install that was internally consistent, I think that's about as good as we can get.
from pwa.
@jeffposnick do you reckon you could make the default npx
command use "workbox-webpack-plugin"? That would probably stop npm audit fix
from affecting anything!
I am assuming that plugin can be used as a dependency instead of:
"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"
from pwa.
Related Issues (20)
- Error: Unexpected token '<' after publishing new version HOT 10
- Updating the new version HOT 2
- Enable debugging mode of Workbox HOT 2
- Service worker is deleted immediately after successful registration
- Open to PR for Create React App PWA offline fallback page only? HOT 3
- Upgrading Workbox to v6 and above HOT 4
- Network First for non-standalone apps HOT 2
- Customize the name of the service-worker file? HOT 5
- `checkValidServiceWorker()` currently doesn't cover the case where I forget to start local server
- Service worker doesn't work out of the box HOT 3
- Typescript version of serviceWorkerRegistration refers to Javascript file HOT 1
- GET http://localhost:3000/service-worker.js returns index.html when using npm start HOT 1
- Cache Refresh Issue at a time new Release HOT 1
- Missing JSDOC
- caniuse-lite is outdated.
- Dependencies are out of date
- React 18 ReactDom.render HOT 1
- Service worker is not picking new build JS/CSS files
- Registered SW broken on iOS 16.4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pwa.