Skip to content

Fix content detection in later Oxide versions #1280

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

Merged
merged 2 commits into from
Mar 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix content detection in later Oxide versions
thecrypticace committed Mar 22, 2025
commit 1b5d0eb407cd0d25ba477a9b69abeb84f9b9e4ed
2 changes: 1 addition & 1 deletion packages/tailwindcss-language-server/package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
"@tailwindcss/forms": "0.5.3",
"@tailwindcss/language-service": "workspace:*",
"@tailwindcss/line-clamp": "0.4.2",
"@tailwindcss/oxide": "^4.0.0-alpha.19",
"@tailwindcss/oxide": "^4.0.15",
"@tailwindcss/typography": "0.5.7",
"@types/braces": "3.0.1",
"@types/color-name": "^1.1.3",
4 changes: 2 additions & 2 deletions packages/tailwindcss-language-server/src/oxide.ts
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ async function loadOxideAtPath(id: string): Promise<Oxide | null> {
let oxide = await import(id)

// This is a much older, unsupported version of Oxide before v4.0.0-alpha.1
if (!oxide.scanDir) return null
if (!oxide.scanDir && !oxide.Scanner) return null

return oxide
}
@@ -101,7 +101,7 @@ interface ScanResult {
* For example, the `sources` option is ignored before v4.0.0-alpha.19.
*/
export async function scan(options: ScanOptions): Promise<ScanResult | null> {
const oxide = await loadOxideAtPath(options.oxidePath)
let oxide = await loadOxideAtPath(options.oxidePath)
if (!oxide) return null

// V1
45 changes: 18 additions & 27 deletions packages/tailwindcss-language-server/src/project-locator.test.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { css, defineTest, js, json, scss, Storage, TestUtils } from './testing'
let settings: Settings = {
tailwindCSS: {
files: {
exclude: [],
exclude: ['**/.git/**', '**/node_modules/**', '**/.hg/**', '**/.svn/**'],
},
},
} as any
@@ -114,10 +114,7 @@ testFixture('v4/workspaces', [
{
config: 'packages/admin/app.css',
selectors: [
'{URL}/node_modules/tailwindcss/**',
'{URL}/node_modules/tailwindcss/index.css',
'{URL}/node_modules/tailwindcss/theme.css',
'{URL}/node_modules/tailwindcss/utilities.css',
'{URL}/packages/admin/*',
'{URL}/packages/admin/**',
'{URL}/packages/admin/app.css',
'{URL}/packages/admin/package.json',
@@ -126,15 +123,12 @@ testFixture('v4/workspaces', [
{
config: 'packages/web/app.css',
selectors: [
'{URL}/node_modules/tailwindcss/**',
'{URL}/node_modules/tailwindcss/index.css',
'{URL}/node_modules/tailwindcss/theme.css',
'{URL}/node_modules/tailwindcss/utilities.css',
'{URL}/packages/style-export/**',
'{URL}/packages/style-export/lib.css',
'{URL}/packages/style-export/theme.css',
'{URL}/packages/style-main-field/**',
'{URL}/packages/style-main-field/lib.css',
'{URL}/packages/web/*',
'{URL}/packages/web/**',
'{URL}/packages/web/app.css',
'{URL}/packages/web/package.json',
@@ -147,28 +141,24 @@ testFixture('v4/auto-content', [
{
config: 'src/app.css',
content: [
'{URL}/*',
'{URL}/package.json',
'{URL}/src/index.html',
'{URL}/src/components/example.html',
'{URL}/src/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
],
},
])

testFixture('v4/auto-content-split', [
//
{
// TODO: This should _probably_ not be present
config: 'node_modules/tailwindcss/index.css',
content: [],
},
{
config: 'src/app.css',
content: [
'{URL}/*',
'{URL}/package.json',
'{URL}/src/index.html',
'{URL}/src/components/example.html',
'{URL}/src/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
],
},
])
@@ -178,23 +168,23 @@ testFixture('v4/custom-source', [
{
config: 'admin/app.css',
content: [
'{URL}/admin/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/admin/**/*.bin',
'{URL}/*',
'{URL}/admin/foo.bin',
'{URL}/admin/{**/*.bin,**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}}',
'{URL}/package.json',
'{URL}/shared.html',
'{URL}/web/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/web/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
],
},
{
config: 'web/app.css',
content: [
'{URL}/admin/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/web/*.bin',
'{URL}/web/bar.bin',
'{URL}/*',
'{URL}/admin/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
'{URL}/package.json',
'{URL}/shared.html',
'{URL}/web/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/web/bar.bin',
'{URL}/web/{**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue},*.bin}',
],
},
])
@@ -203,7 +193,7 @@ testFixture('v4/missing-files', [
//
{
config: 'app.css',
content: ['{URL}/package.json'],
content: ['{URL}/*', '{URL}/package.json'],
},
])

@@ -212,8 +202,9 @@ testFixture('v4/path-mappings', [
{
config: 'app.css',
content: [
'{URL}/*',
'{URL}/package.json',
'{URL}/src/**/*.{py,tpl,js,vue,php,mjs,cts,jsx,tsx,rhtml,slim,handlebars,twig,rs,njk,svelte,liquid,pug,md,ts,heex,mts,astro,nunjucks,rb,eex,haml,cjs,html,hbs,jade,aspx,razor,erb,mustache,mdx}',
'{URL}/src/**/*.{aspx,astro,cjs,cts,eex,erb,gjs,gts,haml,handlebars,hbs,heex,html,jade,js,jsx,liquid,md,mdx,mjs,mts,mustache,njk,nunjucks,php,pug,py,razor,rb,rhtml,rs,slim,svelte,tpl,ts,tsx,twig,vue}',
'{URL}/src/a/my-config.ts',
'{URL}/src/a/my-plugin.ts',
'{URL}/tsconfig.json',
@@ -225,7 +216,7 @@ testFixture('v4/invalid-import-order', [
//
{
config: 'tailwind.css',
content: ['{URL}/package.json'],
content: ['{URL}/*', '{URL}/package.json'],
},
])

100 changes: 55 additions & 45 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.