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

Warn about options that are invalid for a given workbox-build mode #789

Merged
merged 6 commits into from
Sep 8, 2017

Conversation

jeffposnick
Copy link
Contributor

R: @addyosmani @gauntface

Fixes #708

The decision reached in that issue was to log a warning, but not fail the build.

*/
module.exports = (blacklist, fullConfig) => {
const invalidConfig = Object.keys(fullConfig)
.filter((configKey) => blacklist.indexOf(configKey) !== -1);

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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)

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)

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.


if (invalidConfig.length > 0) {
logHelper.warn(`These Workbox configuration options are not valid for ` +
`the current mode, and have been ignored: ${invalidConfig}`);
Copy link

@gauntface gauntface Sep 8, 2017

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}'.

Copy link
Contributor Author

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.

Copy link

@gauntface gauntface left a 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.

@jeffposnick jeffposnick merged commit 6f9c665 into master Sep 8, 2017
@jeffposnick jeffposnick deleted the warn-about-config branch September 8, 2017 20:56
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