Skip to content

Commit

Permalink
Recover from missing imports when reloading the design system
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Dec 11, 2024
1 parent 4c594db commit b9ce8c6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions packages/tailwindcss-language-server/src/util/v4/design-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,22 @@ export async function loadDesignSystem(
}),

loadStylesheet: async (id: string, base: string) => {
let resolved = resolveCssFrom(base, id)

return {
base: path.dirname(resolved),
content: await fs.readFile(resolved, 'utf-8'),
// Skip over missing stylesheets (and log an error) so we can do our best
// to compile the design system even when the build might be incomplete.
// TODO: Figure out if we can recover from parsing errors in stylesheets
// we'd want to surface diagnostics when we discover imports that cause
// parsing errors or other logic errors.

try {
let resolved = resolveCssFrom(base, id)

return {
base: path.dirname(resolved),
content: await fs.readFile(resolved, 'utf-8'),
}
} catch (err) {
console.error(`Unable to load stylesheet: ${id}`, err)
return { base, content: '' }
}
},

Expand Down

0 comments on commit b9ce8c6

Please sign in to comment.