-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
*.runtime.*.js is not added to Service Worker manifest #9309
Comments
This is the case on If a web app has already been cached by a client browser through the service-worker and a new deployment occurs, client browser fails to start the app as the cached Thank you for your help. |
Indeed. We also found it on 2.9.3 (which was before "runtime" was added to the name) and were mystified as to what the file was. As a hack, we added logic in the sw install event to parse the html file and look for any rogue js files (ie. missing from the manifest), so that it could dynamically add them to manifest and then cache them. |
Thank you @alewcock for your help. I did as you explained, and after many changes it finally works. This workaround is a good solution but can require many changes, as in my case. |
This looks to have been broken in With the following {
"@parcel/packager-raw-url": "2.8.3",
"@parcel/reporter-bundle-analyzer": "2.8.3",
"@parcel/service-worker": "2.8.3",
"@parcel/transformer-sass": "2.8.3",
"@parcel/transformer-webmanifest": "2.8.3",
"parcel": "2.8.3"
} Every file (apart from the service-worker obviously) outputted for my build makes it into the manifest, where manifest comes from If I update to Moving on to So you can fix this by moving back to |
So this looks like the code that generates the service worker manifest: https://github.com/parcel-bundler/parcel/blob/v2/packages/runtimes/service-worker/src/ServiceWorkerRuntime.js My attempt to replicate its logic: import { Parcel } from '@parcel/core';
const bundler = new Parcel({
entries: ['.'],
defaultConfig: "@parcel/config-default",
targets: ["frontend"],
mode: "production"
});
const res = await bundler.run();
const manifest = [];
res.bundleGraph.traverseBundles(b => {
console.log({
id: b.id,
name: b.name,
bundleBehavior: b.bundleBehavior,
publicUrl: b.target.publicUrl
})
if (b.bundleBehavior === 'inline') {
return;
}
manifest.push([b.target.publicUrl, b.name]);
});
console.log({ manifest }) does output a Though the whole thing is kind of confusing, my actual build ( I'm wondering if the runtime stuff happens in some later step? So when the service worker is being compiled the runtime file creation hasn't happened yet? |
So I looked into this more: I'm not technically deep on either parcel or service workers, so I might just be holding it wrong, but AFAICT the service worker addon looks to be generally scuffed. I ended up writing my own post processor to inject stuff after Parcel is done, allowing me to stay on the latest parcel version. If think if someone wanted to work out where the runtime stuff gets injected and how to get a plugin running after that point they could build one that works? Here are things I think are problems:
The way I solved it was:
|
FWIW: we discovered that if you add the following to your
So, the issue here seems to have something to do with Cascading Invalidation: https://parceljs.org/features/production/#cascading-invalidation |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
🐛 bug report
The runtime js auto-generated file is not added to the Service Worker manifest, so it is not cached when installing a Service Worker update.
🤔 Expected Behavior
Expected it to be in the manifest.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: