-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fix readJSFiles #143
Fix readJSFiles #143
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #143 +/- ##
===================================
Coverage 100% 100%
===================================
Files 1 1
Lines 2 2
===================================
Hits 2 2 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 😊
packages/workbox/lib/utils.js
Outdated
function readJSFiles (files) { | ||
return Array.from(files) | ||
return Array.from(isString(files) ? [files] : files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using Array.isArray here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
Since
3.x
specifying string paths forworkboxExtensions
,cachingExtensions
androutingExtensions
as per the docs causes an error to be thrown.The docs say that these fields should be a
String
that resolves to a file to load and inject into thesw.js
template:https://pwa.nuxtjs.org/modules/workbox.html#workboxextensions
...however, the new implementation of
readJSFiles
only supportsString[]
.The
readJSFiles
util that is called for each of the extensions fields usesArray.from(files)
. Whenfiles
is aString
it gets split into characters and the resolver borks since it cannot find a file.This PR adds a check to
readJSFiles
for string values and wraps them in an array—making it backwards compatible.I have also updated the workbox docs to reflect this.