-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
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 |
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.
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-dependency
messages 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
dependency
messages, but please let me know if I can do anything in this regard.