Skip to content
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 @source #1030

Merged
merged 22 commits into from
Aug 16, 2024
Merged

Add support for @source #1030

merged 22 commits into from
Aug 16, 2024

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Aug 7, 2024

This PR does multiple things:

  1. It adds support for the @plugin and @source directive in the CSS language.
  2. We will now scan V4 config files for eventually defined @source rules and respect them similarly how we handled custom content paths in V3.
  3. Add support for the the Oxide API coming in Alpha 20 (Improve Oxide scanner API tailwindcss#14187)

For detecting the right content, we load the Oxide API installed in the user's Tailwind project. To do this in a backward compatible way, we now also load the package.json file of the installed Oxide version and support previous alpha releases for a limited amount of time.

@philipp-spiess philipp-spiess force-pushed the feat/at-plugin-at-source branch from ef3c51b to 7eab19f Compare August 9, 2024 10:57
@philipp-spiess philipp-spiess changed the title Add support for @plugin and @source Add support for @plugin and @content Aug 12, 2024
@philipp-spiess philipp-spiess changed the title Add support for @plugin and @content Add support for @plugin and @source Aug 12, 2024
@philipp-spiess philipp-spiess force-pushed the feat/at-plugin-at-source branch from a75348c to 446e6be Compare August 12, 2024 13:26
@philipp-spiess philipp-spiess changed the title Add support for @plugin and @source Add support for@source Aug 13, 2024
@philipp-spiess philipp-spiess force-pushed the feat/at-plugin-at-source branch from e1a28b2 to 52e7930 Compare August 13, 2024 08:00
@philipp-spiess philipp-spiess marked this pull request as ready for review August 13, 2024 08:15
Comment on lines 87 to 97
try {
resultV2 = oxide.scanDir({
base: options.basePath,
sources: options.sources,
})
} catch {
resultV1 = oxide.scanDir({
base: options.basePath,
globs: true,
})
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This raises the questions:

  • Should we properly version this API?
  • When can we deprecate support for an alpha release version? Should we even support older alpha releases? I worry that if we don't define a supported range right now, this will creep and become an unnecessary burden over time.

Maybe we can say all alphas are supported for now but once we release something more stable, we'll drop support for it and will expect our users to upgrade? WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the load path, maybe we could read the package.json file to see what version we are working with 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Should we properly version this API?
    Well… we can't do that exactly because it's already released so…

  2. When can we deprecate support for an alpha release version?

Good question — I think maybe once we're closer to a more stable API + a month or so we can drop stuff then.

Since we have the load path, maybe we could read the package.json file to see what version we are working with

Yeah that is an option 🤔

@philipp-spiess
Copy link
Member Author

Thanks for fixing this up @thecrypticace. Seems like this is good to go for now but I left a question regarding oxide version support.

I can't stamp my own PR so if you would do the honor :)

@philipp-spiess philipp-spiess changed the title Add support for@source Add support for @source Aug 16, 2024
@philipp-spiess philipp-spiess merged commit 3fc767b into main Aug 16, 2024
@philipp-spiess philipp-spiess deleted the feat/at-plugin-at-source branch August 16, 2024 13:51
philipp-spiess added a commit that referenced this pull request Aug 28, 2024
Fixes: #1033
Fixes: #1034 
Fixes: #1035 
Fixes: #1036 
Fixes: #1037 
Fixes: #1038 
Fixes: #1039 
Fixes: #1040
Fixes: #1041
Fixes: #1042 
Fixes: tailwindlabs/tailwindcss#14274

When we worked on #1030, we added a new `postcss` run inside the project
locator. Unfortunately this can crash (e.g. when non standard CSS
features are discovered like those in a `.sass` or `.scss` file) which
currently breaks the whole project locator step, making the extension
not work anymore as soon as such a file is detected.

The short term fix here is to handle this error. In the very future we
have to replace this postcss step anyways because now that Tailwind v4
supports plugins and JS config files, we need to be able to execute the
config to get the proper sources.

## Before

<img width="659" alt="before"
src="https://github.com/user-attachments/assets/8f86e70d-66c2-40a1-ba97-9f4b9b018c94">

## After

<img width="656" alt="after"
src="https://github.com/user-attachments/assets/bfd17b72-c748-4ea9-b73d-86c444cda16a">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants