Add support for PostCSS dir-dependency messages - #6299
Conversation
|
|
Thanks. Do you think we should also support a |
|
Hey @devongovett! I think there were a couple reasons that directory dependencies were prioritised over globs:
For the first point, I could see PostCSS documenting an additional let pattern = '/src/**/*.html'
if (supportsGlobDependencies) {
messages.push({ type: 'glob-dependency', glob: pattern })
} else if (supportsDirectoryDependencies) {
messages.push({ type: 'dir-dependency', dir: getBase(pattern) })
} else {
throw Error('Runner does not support glob or directory dependencies.')
}(I actually like the idea of runners declaring the types they support even with just The second point is trickier though, I think. What if one runner uses |
|
Yeah a way to indicate which dependency types are supported sounds like a great idea. As for what glob syntax should be supported, I guess I'd just keep it simple. 99% of globs will just be |
|
Hey @devongovett. I think you've seen my pull request over on the PostCSS repository. There are some (I think valid) concerns about runners that don't support dependencies at all (because they don't need to). Would you consider adding support (via this PR) for |
|
@bradlc Maybe you could merge the glob and dir dependency message into a singular dir-dependency message? This would probably simplify the logic quite a bit and not require any type of registering which dependency types are supported: Currently { "type": "dir-dependency", "dir": "/src/" }with glob (glob is relative to dir) - the glob would be optional so plugins can choose to add it or leave it out { "type": "dir-dependency", "dir": "/src/", "glob": "**/*.html" } |
|
@DeMoorJasper I like it! 🙌 I have opened a new pull request over on the PostCSS repo for this |
|
@devongovett @DeMoorJasper That PR was merged so I have updated this one to read the optional |
DeMoorJasper
left a comment
There was a problem hiding this comment.
Awesome, thanks for adding this and getting the glob property into postcss
|
Thanks @bradlc! Added an integration test. Hope you don't mind me pushing to your branch. 😄 |
↪️ Pull Request
This PR updates the PostCSS transformer, adding support for
dir-dependencymessages specified by PostCSS plugins (documentation). The implementation is very similar to part of the Stylus transformer.💻 Examples
Example project with instructions in readme: https://github.com/bradlc/parcel-dir-dependency
🚨 Test instructions
I can't see any tests for the existing
dependencymessages, but please let me know if I can do anything in this regard.