Skip to content
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

build error with workbox-webpack-plugin 6.2.0 #2901

Closed
QueridaChin opened this issue Aug 6, 2021 · 4 comments · Fixed by #2903
Closed

build error with workbox-webpack-plugin 6.2.0 #2901

QueridaChin opened this issue Aug 6, 2021 · 4 comments · Fixed by #2903
Labels
Bug An issue with our existing, production codebase. workbox-build workbox-webpack-plugin

Comments

@QueridaChin
Copy link

Library Affected:workbox-webpack-plugin

Browser & Platform:all browsers

Issue or Feature Request Description:after upgrade my workbox-webpack-plugin to 6.2.0 automatically, I got an error without any configuration modified like this: ERROR in Please check your GenerateSW plugin configuration:
[WebpackGenerateSW.runtimeCaching.1.options.plugins.0.cachedResponseWillBeUsed] 'cachedResponseWillBeUsed' property type must be object.
And my workbox configuration is like:
{cachedResponseWillBeUsed: async({cacheName, request, matchOptions, cachedResponse, event}) => {...}}
I've checked the official document but get nothing useful.
The document relavant to cachedResponseWillBeUsed didn't update at all.

When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced.

@QueridaChin
Copy link
Author

I've checked the source code and tried to fix this problem, and I find that there are some problems with definition in workbox-build/build/schema/WebpackGenerateSWOptions .
In ajv ,functions is not validate for type:object.
I tried to modify the scheme and succeed to compile.
here is my attempt:
"CachedResponseWillBeUsedCallback": { "instanceof": "Function", "additionalProperties": false },
and in workbox-build/build/lib/validate-options.js:
const CLASSES = { Function: Function}; const ajv = new ajv_1.default({ useDefaults: true, }); ajv.addKeyword('instanceof', { compile: schema => data => data instanceof CLASSES[schema] });
hope to be useful.

@jeffposnick
Copy link
Contributor

Thanks for catching this—it's an inadvertent change introduced due to the new validation logic in v6.2.0 that unfortunately wasn't identified in our alpha releases.

We'll push out v6.2.1 to deal with it, and in the meantime, you can stick with v6.1.5.

@QueridaChin
Copy link
Author

I'm sorry but the dependency of workbox-build in workbox-webpack-plugin is ^6.1.5 which leads to the same result even if I stick with v6.1.5

@jeffposnick
Copy link
Contributor

This should now be fixed in https://github.com/GoogleChrome/workbox/releases/tag/v6.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An issue with our existing, production codebase. workbox-build workbox-webpack-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants