Skip to content

Add support for @source not and @source inline(…) #1262

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 15 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Allow test harness to force-enable additional features
  • Loading branch information
thecrypticace committed Mar 19, 2025
commit 58d3b613d889bf33d92272c79db6cabc40c3cdc4
15 changes: 15 additions & 0 deletions packages/tailwindcss-language-server/src/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ export async function createProjectService(
log(`supported features: ${JSON.stringify(features)}`)
state.features = features

if (params.initializationOptions?.testMode) {
state.features = [
...state.features,
...(params.initializationOptions.additionalFeatures ?? []),
]
}

if (!features.includes('css-at-theme')) {
tailwindcss = tailwindcss.default ?? tailwindcss
}
Expand Down Expand Up @@ -695,6 +702,14 @@ export async function createProjectService(
state.v4Fallback = true
state.jit = true
state.features = features

if (params.initializationOptions?.testMode) {
state.features = [
...state.features,
...(params.initializationOptions.additionalFeatures ?? []),
]
}

state.modules = {
tailwindcss: { version: tailwindcssVersion, module: tailwindcss },
postcss: { version: null, module: null },
Expand Down
10 changes: 10 additions & 0 deletions packages/tailwindcss-language-server/tests/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { clearLanguageBoundariesCache } from '@tailwindcss/language-service/src/
import { DefaultMap } from '../../src/util/default-map'
import { connect, ConnectOptions } from './connection'
import type { DeepPartial } from '@tailwindcss/language-service/src/types'
import type { Feature } from '@tailwindcss/language-service/src/features'

export interface DocumentDescriptor {
/**
Expand Down Expand Up @@ -170,6 +171,14 @@ export interface ClientOptions extends ConnectOptions {
* Settings to provide the server immediately when it starts
*/
settings?: DeepPartial<Settings>

/**
* Additional features to force-enable
*
* These should normally be enabled by the server based on the project
* and the Tailwind CSS version it detects
*/
features?: Feature[]
}

export interface Client extends ClientWorkspace {
Expand Down Expand Up @@ -394,6 +403,7 @@ export async function createClient(opts: ClientOptions): Promise<Client> {
workspaceFolders,
initializationOptions: {
testMode: true,
additionalFeatures: opts.features,
...opts.options,
},
})
Expand Down