Skip to content

Commit 1b82b76

Browse files
Fix Sass fallback and zip finalization
Ensure sass-loader receives correct implementation by using mod.default || mod when falling back to 'sass'. Resolve zip completion on 'finish' and handle errors via stream events to avoid truncated archives.
1 parent 4126a4f commit 1b82b76

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

build.mjs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,13 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, sourceBuil
8787
]
8888
if (isWithoutKatex) shared.push('./src/components')
8989

90-
// Use the default export from sass-embedded; sass-loader expects the implementation object.
91-
// Fallback to `sass` if sass-embedded is unavailable.
9290
let sassImpl
9391
try {
9492
const mod = await import('sass-embedded')
9593
sassImpl = mod.default || mod
9694
} catch (e) {
9795
const mod = await import('sass')
98-
// Prefer namespace import style to avoid deprecated default import warning
99-
// "import sass from 'sass'" is deprecated; use namespace instead
100-
sassImpl = mod
96+
sassImpl = mod.default || mod
10197
}
10298

10399
const dirKey = path.basename(sourceBuildDir || outdir)
@@ -426,14 +422,10 @@ async function zipFolder(dir) {
426422
const onError = (err) => reject(err)
427423
output.on('error', onError)
428424
archive.on('error', onError)
429-
output.on('close', resolve)
425+
output.on('finish', resolve)
430426
archive.pipe(output)
431427
archive.directory(dir, false)
432-
try {
433-
archive.finalize()
434-
} catch (err) {
435-
onError(err)
436-
}
428+
archive.finalize()
437429
})
438430
}
439431

0 commit comments

Comments
 (0)