Comments (5)
Thanks for the report, @AsaAyers
I personally do not use webpack-dev-server
, so there is a good change that offline-plugin
may not work with it.
About this particular warning, it's a bit complicated and in ideal world it should not happen. I thought it won't happen ever. It works this way:
To correctly work, ServiceWorker
creates fake entryั Every entry is actually a chunk, and chunks in webpack
by some reason has array files
instead of one file
. So it's possible that chunk may have more than one files and looking through webpack
's code, it seems that it used only for hot-reload. Probably some kind of hack. This is why that warning exists, I simply do not understand why there might be more than one files in output for one chunk, plus it shouldn't modified anyway for ServiceWorker
's fake entry. So, in case of hot reloading, it probably could be simply ignored since hot reloading shouldn't be embedded/used inside ServiceWorker
.
Anyway, I have in plans to improve offline-plugin
work with hot reloading, probably just disabling it in such mode. Btw, why you may need it with hot reloading? It's actually conflicting things since hot reloading is intended to load fresh files from server as soon as they changed, but offline-plugin
is intended to load them from cache.
from offline-plugin.
I'm not using hot reloading. I just have it setup so that when any files change it tells the browser to refresh and load the new version. It seems like that should be fine if offline-plugin
is using hash
mode, I'm not sure about the others.
from offline-plugin.
Does it need to be a 2nd entry in a chunk? Could the service worker just be it's own chunk?
from offline-plugin.
Does it need to be a 2nd entry in a chunk? Could the service worker just be it's own chunk?
SW has separate entry/chunk. It should be first and is first in files
array. But plugin expects only it to there, so when there is more things (some other plugin added files) you get a warning about it, warning means that something may not work as expected since unexpected thing happened. However, it's not an error, just a warning, this means that SW entry was successfully compiled.
I'm not using hot reloading. I just have it setup so that when any files change it tells the browser to refresh and load the new version. It seems like that should be fine if offline-plugin is using hash mode, I'm not sure about the others.
Should be problem in any more I think. To update cache, SW anyway needs to be reloaded or update function needs to be called. So on each reload, you need one more reload to update cache. This could work, but what is the reason then to use it in dev mode?
I actually do not want to use plugin dev mode myself since I had to reload page twice to get update version. Problem is that at them moment runtime.js
is a template and fails with systax error if plugin is not included, which I see as a right way to develop with offline-plugin
: develop with it disabled, then before releasing enable it and test offline support.
Here is issue for it #4 but I had no time yet for it yet. Would be good to fix anyway.
from offline-plugin.
Okay, fixed in 2.0.0
. Should work normal with Webpack Dev Server. No with Hot Reloading or Live Reloading of course. With lazy mode it won't work too. Those modes are simply incompatible with this plugin and there is no sense to support them (or probably no way).
To test if everything works fine with ServiceWorker
and AppCache
-- just run regular server (or webpack server with simple options) for your dev/prod envs. You do not need to do it offset since almost everything is handled by offline-plugin
for you.
from offline-plugin.
Related Issues (20)
- Question - SW caching all assets site-wide HOT 1
- In Angular 9, files inside directories are not being cached
- Ideas for Documentation to Help with Troubleshooting
- Some files missing in cache on SW first load/install HOT 1
- Caching subpath urls
- Caching fails to download assets in Chrome 85 HOT 1
- Issue with default path
- [question] Having Multiple runtime installations
- Problem with Webpack 5.0 HOT 17
- Micro Front-ends structure with single-spa
- Auto update doesn't work
- After removing redux-offline, how do we ensure that client's who have old versions get the latest update?
- `onInstalling` doesn't seem to be called, because `ignoreInstalling` is always true
- offline-plugin does not serve assets from service worker
- Webpack 5 compatibility HOT 3
- The "path" argument must be of type string. Received undefined HOT 4
- Cache Images from AWS S3
- Pass ServiceWorker version to the install events
- Terser Plugin issue while building with webpack-cli HOT 3
- upgrade ejs package | CVE-2022-29078 HOT 1
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 offline-plugin.