From fb54eaf1354530e864860f3832eacc3c74d25347 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 11 Jan 2025 15:09:33 +0900 Subject: [PATCH] fix(css): workaround tsx esModule interop of sass-embedded import --- packages/vite/src/node/plugins/css.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 12207db233b406..0cd0a63aef53cc 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -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