-
Notifications
You must be signed in to change notification settings - Fork 830
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
Warn about options that are invalid for a given workbox-build mode #789
Conversation
*/ | ||
module.exports = (blacklist, fullConfig) => { | ||
const invalidConfig = Object.keys(fullConfig) | ||
.filter((configKey) => blacklist.indexOf(configKey) !== -1); |
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.
Could you use includes?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
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.
We're still aiming for Node 4 compatibility with these modules, so no Array.prototype.includes()
: http://node.green/#ES2016-features-Array-prototype-includes
* @param {Object<String,String>} fullConfig The configuration options to check. | ||
*/ | ||
module.exports = (blacklist, fullConfig) => { | ||
const invalidConfig = Object.keys(fullConfig) |
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.
Nit: Rename to invalidConfigKeys (Just reads better for if (invalidConfigKeys.length > 0)
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.
|
||
if (invalidConfig.length > 0) { | ||
logHelper.warn(`These Workbox configuration options are not valid for ` + | ||
`the current mode, and have been ignored: ${invalidConfig}`); |
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.
Nit: Swap "have been" with "will be" as I'm assuming this log will be at the start of the build task (whatever that will be).
Would also make sense to reword this slightly away from "These Workbox configuration options". It's more to highlight that in this context it won't be used, so maybe:
The configuration options '${invalidConfig.join(',')}' will be ignored by 'workbox-build.${methodName}'.
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.
Folks might end up calling the methods indirectly via the Webpack or CLI, so I don't want to put workbox-build.
in the message. But I'll reword along those lines.
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.
LGTM with a few comments that would just help developers understand that it is invalid depending on the specific method.
R: @addyosmani @gauntface
Fixes #708
The decision reached in that issue was to log a warning, but not fail the build.