fix(build): keep music-metadata out of the web server bundle (#6699)

music-metadata 12.1.0 pulls in file-type 22, which loads strtok3 through a
webpackIgnore'd dynamic import. Webpack leaves a bare `import("strtok3")`
in the server chunk, and the OpenNext esbuild pass then fails with
`Could not resolve "strtok3"` because strtok3 is not a direct dependency.

music-metadata only parses user-picked audiobook files in the browser, so
alias it to false for the web server build, as jieba-wasm already is.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Huang Xin 2026-10-10 12:32:09 +08:00 • committed by GitHub
parent c307cfd79b
commit 6025a29c80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -84,8 +84,15 @@ const nextConfig = {
// can't find fflate (only installed in this app's node_modules).
fflate: path.resolve(__dirname, 'node_modules/fflate'),
...(appPlatform !== 'web' ? { '@readest/turso-database-wasm/webpack': false } : {}),
// music-metadata only parses user-picked files in the browser; its
// file-type dependency leaves a webpackIgnore'd `import('strtok3')` in
// the server bundle that the OpenNext esbuild pass cannot resolve.
...(isServer && appPlatform === 'web'
? { '@readest/turso-database-wasm/webpack': false, 'jieba-wasm': false }
? {
'@readest/turso-database-wasm/webpack': false,
'jieba-wasm': false,
'music-metadata': false,
}
: {}),
};
return config;