question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Workbox throws warning but still caches it (was provided in your Workbox chunks config, but was not found in the compilation.)

See original GitHub issue

Library Affected: workbox-webpack-plugin: ^6.0.2

Issue or Feature Request Description: Currently, I’m upgrading from workbox-webpack-plugin: ^4.3.1 to ^6.0.2, but I noticed a warning that I’m not sure how I should solve it.

It says: `WARNING in The chunk β€˜/js/manifest’ was provided in your Workbox chunks config, but was not found in the compilation``

The weird part is that the manifest.js file is still cached by the SW (this same warning happens for vendor.js as well and is cached too)

image

Why does it still cache it when it says it couldn’t find it?

Besides that, I’m struggling to find out what exactly my chunk name for manifest is. I know this is an issue from another plugin, however since using Laravel Mix v6.*, I cannot see the chunk names. It only outputs this in the terminal:

Laravel Mix v6.0.8   
                        

βœ” Compiled Successfully in 38735ms
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ File                              β”‚ Size       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ /js/vendor.js                     β”‚ 4.05 MiB   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ css/app.css                       β”‚ 246 KiB    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ /js/app.js                        β”‚ 104 KiB    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ images/vendor/intl-tel-input/bui… β”‚ 69.2 KiB   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ service-worker.js                 β”‚ 22.8 KiB   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ js/6231.9b6787592e9af06465aa.js   β”‚ 6.46 KiB   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ js/1901.f3d670a3cfb776389054.js   β”‚ 6.17 KiB   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ /js/manifest.js                   β”‚ 6.15 KiB   β”‚

But this clearly shows how /js/manifest.js is written.

In the webpack.mix.js file I wrote this:

      new InjectManifest({
           swSrc: './resources/js/sw.js',
           swDest: 'service-worker.js',
           // precaching only these.
           chunks: [
               'routes-settings', 'routes-sell-food', 'routes-checkout',
               '/js/app', '/js/moment', '/js/canvas', '/js/manifest',
               '/js/vendor',
           ],
           maximumFileSizeToCacheInBytes: 5000000,
       }),

Everything in the chunks array worked well besides the /js/manifest and /js/vendor.

p.S. I hope there are no misunderstandings, I want to cache those two files, but I’m just curious why the warnings are still there

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffposnickcommented, Jan 14, 2021

Thanks for that clean reproduction!

From examining that while debugging, I can see that compilation.namedChunkgroups, which is what Workbox is currently using, only has one entry (for the /js/app chunk). compilation.namedChunks, however, has four entries, including the chunks that you’re trying to use.

Screen Shot 2021-01-14 at 12 50 30 PM

I’m going to have to do a little research into webpack’s innards to see what the difference is between compilation.namedChunkgroups and compilation.namedChunks, and we can potentially switich to using compilation.namedChunks in this part of the workbox-webpack-plugin code if it seems like the right thing to do.

1reaction
jeffposnickcommented, Jan 11, 2021

The underlying code in question is https://github.com/GoogleChrome/workbox/blob/2df5ce58bd74abd8da4ec90e427f0e4431a0cff2/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js#L62-L141

That code should add an asset to the precache manifest if both of these compound conditions are true:

  • The asset is a member of a chunk that’s allowed via the chunks config, or the asset matches the criteria in include.
  • The asset is NOT a member of a chunk that’s listed in the excludeChunks config, and the asset does not match the criteria in exclude.

So yes, both chunks and include can be used at the same time.

If you’re still seeing warnings like The chunk β€˜/js/app’ was provided in your Workbox chunks config, but was not found in the compilation, it’s because those aren’t the names of chunks that exist in your webpack configuration. Workbox can’t do much else beyond warn if you provide an name for a chunk that doesn’t exist.

Based on your elaboration of the problem, if you’re looking for more flexibility to support asset names that include hashes, your best bet would be to use include and pass in something other than strings as the parameters. include, as mentioned in the Workbox docs, supports any webpack condition, and those conditions could be RegExps or predicate functions. Under the hood, Workbox actually just calls the same code that webpack uses:

https://github.com/GoogleChrome/workbox/blob/2df5ce58bd74abd8da4ec90e427f0e4431a0cff2/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js#L15-L41

Read more comments on GitHub >

github_iconTop Results From Across the Web

Workbox seemingly not pre-caching chunks from webpack build
js generated from Workbox, it is importing a manifest which does contain references to the correct chunks. But they're just not being loadedΒ ......
Read more >
Untitled
Workbox is a set of javascript libraries that add support for caching and ... The vite-plugin-pwa plugin will compile your custom service worker...
Read more >
Code Splitting - webpack
Entry Points: Manually split code using entry configuration. Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks.
Read more >
service workers – CSS-Tricks
The only difference is that you are the browser and your friend is the server. ... Look in the generated sw.js to see...
Read more >
How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found