Skip to content

Commit

Permalink
fix(css): workaround tsx esModule interop of sass-embedded import
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jan 11, 2025
1 parent e690d8b commit fb54eaf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,10 @@ const makeModernCompilerScssWorker = (
async run(sassPath, data, options) {
// need pathToFileURL for windows since import("D:...") fails
// https://github.com/nodejs/node/issues/31710
const sass: typeof Sass = (await import(pathToFileURL(sassPath).href))
.default
const sass_ = await import(pathToFileURL(sassPath).href)
// fallback for `default` to workaround tsx's __esModule interop
// https://github.com/privatenumber/tsx/issues/627
const sass: typeof Sass = sass_.default ?? sass_
compilerPromise ??= sass.initAsyncCompiler()
const compiler = await compilerPromise

Expand Down

0 comments on commit fb54eaf

Please sign in to comment.