Add support for the tailwindcss/plugin export#14173
Merged
adamwathan merged 14 commits intonextfrom Aug 13, 2024
Merged
Conversation
thecrypticace
commented
Aug 13, 2024
| // without it we get a `.default` export when using `require` in CJS | ||
|
|
||
| // @ts-ignore | ||
| module.exports = require('./plugin.ts').default |
Contributor
Author
There was a problem hiding this comment.
There doesn't appear to be a way for tsup to compile a default export to module.exports in my testing so we came up with this + two separate entry points in the tsup config. I like this because it feels like it's more clear that it's a workaround. We might be able to do something like this for the postcss plugin too but would need to test.
RobinMalfait
approved these changes
Aug 13, 2024
| let pluginApi = buildPluginApi(designSystem, ast) | ||
|
|
||
| for (let plugin of plugins) { | ||
| if ('__isOptionsFunction' in plugin) { |
Member
There was a problem hiding this comment.
I wonder if this is better or not 🤔
Suggested change
| if ('__isOptionsFunction' in plugin) { | |
| if (Object.hasOwn(plugin, '__isOptionsFunction')) { |
Member
There was a problem hiding this comment.
The in one is cleaner if TypeScript is happy with it.
philipp-spiess
approved these changes
Aug 13, 2024
adamwathan
approved these changes
Aug 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for the
tailwindcss/pluginimport which has historically been used to define custom plugins:This also adds support for
plugin.withOptionswhich was used to define plugins that took optional initilization options when they were registered in yourtailwind.config.jsfile:We've stubbed out support for the
configargument but we're not actually doing anything with it at the time of this PR. The scope of this PR is just to allow people to create plugins that currently work using the raw function syntax but using thepluginandplugin.withOptionsAPIs. Support forconfigwill land separately.