[Proposal] Add supportedDependencyTypes documentation#1585
[Proposal] Add supportedDependencyTypes documentation#1585bradlc wants to merge 1 commit intopostcss:mainfrom
supportedDependencyTypes documentation#1585Conversation
|
I do not like the idea that a plugin should throw an error. There are a lot of use case, when we do not have watch mode and I can accept it only if we will find a better UX for plugins. But I am not sure that we need it. |
What do you recommend a plugin do if it can't run in the user's environment?
I do not think that is the case when a runner has persistent caching like webpack 5 does. The cache is maintained across separate builds so the dependencies are taken into account. |
What plugin requires
Don’t forget about |
Any plugin, when using a runner that uses persistent caching, like webpack 5 (with opt-in). Here's an example with instructions: https://github.com/bradlc/postcss-webpack5 |
I am asking about the opposite question. If we run PostCSS plugin with |
|
Ah sorry. So the problem would be that if my plugin reads the content from files in the |
|
But |
| }) | ||
| ``` | ||
|
|
||
| ### 3.2. Detect available dependency types |
There was a problem hiding this comment.
I suggest to not do it mandatory and only add supportedDependencyTypes to types
Ooh I see what you mean now I think! So |
|
Would it make sense to not throw when no dependency types are supported but just not emit anything? In that case, there's no watcher anyway, so there's no reason it should break. |
|
Yeap, let's be remove the error from examples. I think we should not add any rules to plugin guidelines. Only to runner guidelines. |
|
Mentioned an alternative to the glob/dir dependency in the Parcel PR that might remove the need for the functionality proposed in this PR
|
|
I like |
|
@DeMoorJasper I like it! 🙌 Opened a new pull request for that as an alternative to this one 👍 |
This pull request adds documentation for a way that PostCSS runners can specify which dependency types they support. Now that we have more than one dependency type, I think it is important that plugins are aware of which dependency types are available to them, and which aren't.
My proposal is for runners to define a
supportedDependencyTypesoption when running PostCSS:Then, plugins can read this from
result.opts:This provides a better experience for PostCSS users, because plugins can present clear errors when required dependency types are not available. It also allows plugins to register dependencies with confidence, knowing that they will be handled by the runner. Currently there is no way to know that a
dir-dependencymessage has been handled. This can lead to plugins silently not working correctly and frustrated users.Here's another concrete example: if we added a new
glob-dependencytype (as discussed over on the Parcel repo) plugins could make a decision about which dependencies to register, based on which types the runner supports:Some runners may not be able to support glob dependencies at all, and this would allow plugins to maximise compatibility.
This is just one idea and I am curious to hear what you think of it. Feedback and suggestions welcome, thanks!