Skip to content

Commit b9ce8c6

Browse files
committed
Recover from missing imports when reloading the design system
1 parent 4c594db commit b9ce8c6

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/tailwindcss-language-server/src/util/v4/design-system.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,22 @@ export async function loadDesignSystem(
129129
}),
130130

131131
loadStylesheet: async (id: string, base: string) => {
132-
let resolved = resolveCssFrom(base, id)
133-
134-
return {
135-
base: path.dirname(resolved),
136-
content: await fs.readFile(resolved, 'utf-8'),
132+
// Skip over missing stylesheets (and log an error) so we can do our best
133+
// to compile the design system even when the build might be incomplete.
134+
// TODO: Figure out if we can recover from parsing errors in stylesheets
135+
// we'd want to surface diagnostics when we discover imports that cause
136+
// parsing errors or other logic errors.
137+
138+
try {
139+
let resolved = resolveCssFrom(base, id)
140+
141+
return {
142+
base: path.dirname(resolved),
143+
content: await fs.readFile(resolved, 'utf-8'),
144+
}
145+
} catch (err) {
146+
console.error(`Unable to load stylesheet: ${id}`, err)
147+
return { base, content: '' }
137148
}
138149
},
139150

0 commit comments

Comments
 (0)