Skip to content

Commit 039de91

Browse files
Build: avoid deprecated Sass default import and add configurable pool timeout
- Prefer namespace import for fallback to avoid default import deprecation - Add BUILD_POOL_TIMEOUT to override thread-loader production pool timeout Validated with prettier, eslint, and production build
1 parent df6371b commit 039de91

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

build.mjs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,18 @@ if (Number.isInteger(rawWorkers) && rawWorkers > 0) {
5353
}
5454
threadWorkers = cpuCount
5555
}
56-
// Thread-loader pool timeout constants
57-
const PRODUCTION_POOL_TIMEOUT_MS = 2000
56+
// Thread-loader pool timeout constants (allow override via env)
57+
let PRODUCTION_POOL_TIMEOUT_MS = 2000
58+
if (process.env.BUILD_POOL_TIMEOUT) {
59+
const n = parseInt(process.env.BUILD_POOL_TIMEOUT, 10)
60+
if (Number.isFinite(n) && n > 0) {
61+
PRODUCTION_POOL_TIMEOUT_MS = n
62+
} else {
63+
console.warn(
64+
`[build] Invalid BUILD_POOL_TIMEOUT="${process.env.BUILD_POOL_TIMEOUT}", keep default ${PRODUCTION_POOL_TIMEOUT_MS}ms`,
65+
)
66+
}
67+
}
5868
// Enable threads by default; allow disabling via BUILD_THREAD=0
5969
const enableThread = process.env.BUILD_THREAD === '0' ? false : true
6070

@@ -85,7 +95,9 @@ async function runWebpack(isWithoutKatex, isWithoutTiktoken, minimal, sourceBuil
8595
sassImpl = mod.default || mod
8696
} catch (e) {
8797
const mod = await import('sass')
88-
sassImpl = mod.default || mod
98+
// Prefer namespace import style to avoid deprecated default import warning
99+
// "import sass from 'sass'" is deprecated; use namespace instead
100+
sassImpl = mod
89101
}
90102

91103
const dirKey = path.basename(sourceBuildDir || outdir)

0 commit comments

Comments
 (0)