From 3dc3ab8100f1d3ce0e290cefbc8caa1b4deee60e Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Sun, 8 Mar 2026 23:33:17 +0800 Subject: [PATCH] Fix Sass ESM deprecation handling in build Resolve the Sass implementation from the ESM module namespace before falling back to the default export. This avoids triggering the deprecated default-export access in sass and sass-embedded while preserving the existing fallback order and build behavior. --- build.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build.mjs b/build.mjs index ea2a63995..a76858a42 100644 --- a/build.mjs +++ b/build.mjs @@ -85,16 +85,22 @@ const resolveSymlinks = getBooleanEnv(process.env.BUILD_RESOLVE_SYMLINKS, false) // Cache and resolve Sass implementation once per process let sassImplPromise +function resolveSassImplementation(mod) { + if (mod && typeof mod.info === 'string') return mod + if (mod?.default && typeof mod.default.info === 'string') return mod.default + return mod +} + async function getSassImplementation() { if (!sassImplPromise) { sassImplPromise = (async () => { try { const mod = await import('sass-embedded') - return mod.default || mod + return resolveSassImplementation(mod) } catch (e1) { try { const mod = await import('sass') - return mod.default || mod + return resolveSassImplementation(mod) } catch (e2) { console.error('[build] Failed to load sass-embedded:', e1) console.error('[build] Failed to load sass:', e2)