Skip to content

Commit

Permalink
Prettify postcss-selector-parser errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-rogerson committed Sep 19, 2022
1 parent 0358486 commit a1b438e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/core/getStyles.ts
Expand Up @@ -124,16 +124,28 @@ function getOrderedClassList(
color('Twin requires a newer version of tailwindcss, please update')
) // `getClassOrder` was added in tailwindcss@3.0.23

const orderedClassList = tailwindContext
.getClassOrder(convertedClassList)
.map(([className, order], index): [bigint, string, string] => [
order || 0n,
className,
classList[index],
])
.sort(([a], [z]) => bigSign(a - z))

return orderedClassList
let orderedClassList

try {
orderedClassList = tailwindContext
.getClassOrder(convertedClassList)
.map(([className, order], index): [bigint, string, string] => [
order || 0n,
className,
classList[index],
])
.sort(([a], [z]) => bigSign(a - z))
} catch (error: unknown) {
assert(
false,
({ color }) =>
`${color(error as string)}\n\nFound in:\n${convertedClassList.join(
' '
)}`
)
}

return orderedClassList as Array<[bigint, string, string]>
}

function getStyles(
Expand Down

0 comments on commit a1b438e

Please sign in to comment.