Skip to content
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
Prev Previous commit
Next Next commit
render errors during migration
Moving the `error(…)` logic to where we are migrating the stylesheet
allows us to use the `sheet` available in the current scope to improve
the error messages.
  • Loading branch information
RobinMalfait committed Nov 19, 2024
commit 715fe76ab42d217a9d4142b6740d3a680499d644
36 changes: 17 additions & 19 deletions packages/@tailwindcss-upgrade/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,31 +181,29 @@ async function run() {
if (stylesheets.length > 0) {
info('Migrating stylesheets…')
}
let migrateResults = await Promise.allSettled(
stylesheets.map((sheet) => {
let config = configBySheet.get(sheet)!
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet)!

if (!config) {
for (let parent of sheet.ancestors()) {
if (parent.isTailwindRoot) {
config ??= configBySheet.get(parent)!
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent)!
break
await Promise.all(
stylesheets.map(async (sheet) => {
try {
let config = configBySheet.get(sheet)!
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet)!

if (!config) {
for (let parent of sheet.ancestors()) {
if (parent.isTailwindRoot) {
config ??= configBySheet.get(parent)!
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent)!
break
}
}
}
}

return migrateStylesheet(sheet, { ...config, jsConfigMigration })
await migrateStylesheet(sheet, { ...config, jsConfigMigration })
} catch (e: any) {
error(`${e} in ${highlight(relative(sheet.file!, base))}`)
}
}),
)

for (let result of migrateResults) {
if (result.status === 'rejected') {
error(`${result.reason}`)
}
}

// Split up stylesheets (as needed)
try {
await splitStylesheets(stylesheets)
Expand Down