Git Product home page Git Product logo

Comments (8)

andywer avatar andywer commented on June 17, 2024

I like it! :)

Would be happy to review a PR introducing that.

from webpack-blocks.

andywer avatar andywer commented on June 17, 2024

And thanks for sharing your idea, @marcofugaro

from webpack-blocks.

vlad-zhukov avatar vlad-zhukov commented on June 17, 2024

Negations can happen anywhere in a pattern, how are we going to handle it? Is it going to be predictable?
And also glob-to-regexp doesn't support many glob features including negations.

from webpack-blocks.

andywer avatar andywer commented on June 17, 2024

Negations can happen anywhere in a pattern

Really? I was thinking about the negation of the whole pattern (! in the very front) only. Just as a nicer way to specify exclusions.

And also glob-to-regexp doesn't support (...) negations

True, but could quite easily be worked around by doing this, I think:

const negations = patterns.filter(pattern => pattern.startsWith('!')).map(pattern => pattern.substr(1))
match.test = patterns.filter(pattern => !pattern.startsWith('!')).map(regexify)
match.exclude = options.exclude.concat(negations.map(regexify))

(If it starts with a !, then strip it, regexify as usual, but append to match.exclude instead of match.test)

from webpack-blocks.

marcofugaro avatar marcofugaro commented on June 17, 2024

Yes, I think that's it's way too much overhead to support also negations anywhere in a pattern.
Probably not worth it since negations are always used at the start.

from webpack-blocks.

marcofugaro avatar marcofugaro commented on June 17, 2024

By the way, @andywer do you think we still need to support the options parameter (the second one) in the match()?

from webpack-blocks.

andywer avatar andywer commented on June 17, 2024

Good question. I would keep it, since it doesn't cost us anything except maintenance of a couple of LOC. There might still be scenarios where you want to pass a more elaborate include/exclude configuration.

But no hard feelings either way.

from webpack-blocks.

marcofugaro avatar marcofugaro commented on June 17, 2024

Alright, done it. It was a pain to handle all the cases.

from webpack-blocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.