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

Fix readJSFiles #143

Merged
merged 6 commits into from
Feb 16, 2019
Merged

Fix readJSFiles #143

merged 6 commits into from
Feb 16, 2019

Conversation

wagerfield
Copy link
Contributor

Since 3.x specifying string paths for workboxExtensions, cachingExtensions and routingExtensions 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 the sw.js template:

https://pwa.nuxtjs.org/modules/workbox.html#workboxextensions

...however, the new implementation of readJSFiles only supports String[].

The readJSFiles util that is called for each of the extensions fields uses Array.from(files). When files is a String 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.

@codecov
Copy link

codecov bot commented Feb 16, 2019

Codecov Report

Merging #143 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff         @@
##            dev   #143   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files         1      1           
  Lines         2      2           
===================================
  Hits          2      2

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d9bec5...4989aa4. Read the comment docs.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😊

function readJSFiles (files) {
return Array.from(files)
return Array.from(isString(files) ? [files] : files)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@pi0 pi0 merged commit 4f06479 into nuxt-community:dev Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants