Workbox throws warning but still caches it (was provided in your Workbox chunks config, but was not found in the compilation.)
See original GitHub issueLibrary 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)
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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
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.Iβm going to have to do a little research into
webpack
βs innards to see what the difference is betweencompilation.namedChunkgroups
andcompilation.namedChunks
, and we can potentially switich to usingcompilation.namedChunks
in this part of theworkbox-webpack-plugin
code if it seems like the right thing to do.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:
chunks
config, or the asset matches the criteria ininclude
.excludeChunks
config, and the asset does not match the criteria inexclude
.So yes, both
chunks
andinclude
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 anywebpack
condition, and those conditions could be RegExps or predicate functions. Under the hood, Workbox actually just calls the same code thatwebpack
uses:https://github.com/GoogleChrome/workbox/blob/2df5ce58bd74abd8da4ec90e427f0e4431a0cff2/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js#L15-L41