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

Change match() to pass all webpack rule options to context. #250

Merged
merged 6 commits into from
Feb 19, 2018

Conversation

vlad-zhukov
Copy link
Collaborator

Currently it's not possible to pass webpack rule options other than exclude and include to blocks. Also there is no way to remove default options from blocks (for example the exclude in the babel block).

This PR fixes both problems.

@@ -1,5 +1,9 @@
# @webpack-blocks/core - Changelog

## master

- Change `match()` to passes all [webpack rule options](https://webpack.js.org/configuration/module/) to context. ([#250](https://github.com/andywer/webpack-blocks/pull/250))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

passes -> pass

@vlad-zhukov
Copy link
Collaborator Author

Also there is no way to remove default options from blocks (for example the exclude in the babel block).

I was wrong, the exclude option can be removed with []. Anyway, I don't think it should be like that.

@@ -23,20 +21,13 @@ function match (test, options, configSetters) {

assertConfigSetters(configSetters)

const match = { test: createFileTypeMatcher(test) }
options.test = createFileTypeMatcher(test)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should print a warning if test was set in options.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, if options.test was set before this line 👍

@@ -10,8 +10,6 @@ module.exports = match
*
* @param {string|RegExp|Function|Array} test A glob like `*.css` or `{*.js, *.jsx}` or something else to use as `loader.test`.
* @param {object} [options] Optional advanced matching options.
* @param {string|Function|RegExp|Array|object} [options.include]
Copy link
Owner

Choose a reason for hiding this comment

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

If we remove those hints, then we definitely need to improve the documentation of the overall options parameter, since otherwise it's not clear anymore what kind of options can be passed here 😉

@@ -1,5 +1,9 @@
# @webpack-blocks/core - Changelog

## master
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

master -> Next version (like we used before)

@vlad-zhukov
Copy link
Collaborator Author

Updated

@@ -21,6 +21,10 @@ function match (test, options, configSetters) {

assertConfigSetters(configSetters)

if (options.test) {
console.warn(`match(): Setting 'test' in options is not supported and will be overriden with a 'test' argument.`)
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we should even throw! What do you think?

Seems useful to defuse the bomb instead of putting a warning sign on it.

andywer
andywer previously approved these changes Feb 9, 2018
Copy link
Owner

@andywer andywer left a comment

Choose a reason for hiding this comment

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

Thanks for this change, @vlad-zhukov!

Just left a comment to maybe turn the warning into a throw. But would be fine with merging either way.

@vlad-zhukov
Copy link
Collaborator Author

#253 unintentionally mostly covered this PR.

@andywer andywer merged commit d130547 into andywer:master Feb 19, 2018
@vlad-zhukov vlad-zhukov deleted the change-match branch February 19, 2018 09: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