mirror of
https://github.com/lobehub/lobehub.git
synced 2026-09-20 04:56:13 +08:00
787b24de70
pdfjs-dist evaluates `const SCALE_MATRIX = new DOMMatrix()` at module scope, which was the only reason the @napi-rs/canvas Skia binary (25.1MB per platform) shipped. PdfLoader only calls `page.getTextContent()` and never renders, so the canvas surface was never reached — DOMPoint/DOMRect had zero references in pdfjs and Path2D was never instantiated at top level. Replace it with a dependency-free 2D DOMMatrix, checked against the native implementation for every API pdfjs touches. pdfjs is now loaded through a deferred import so the polyfill lands before its module body evaluates; a static import would hoist above any setup statement. The file-loaders test setup now blocks @napi-rs/canvas resolution for the whole suite, so a polyfill regression fails in CI rather than in a packaged app. That file was previously dead code — it was never registered as a setupFile. pdfjs still require()s the package unconditionally at load, so it prints three warnings once per process. They are expected: the call goes through a runtime createRequire() that no bundler can rewrite, and only rendering paths are affected.
26 lines
765 B
TypeScript
26 lines
765 B
TypeScript
import { defineConfig } from './src/libs/next/config/define-config';
|
|
|
|
const isVercel = !!process.env.VERCEL_ENV;
|
|
|
|
const vercelConfig = {
|
|
// Vercel serverless optimization: exclude musl binaries from all routes
|
|
// Vercel uses Amazon Linux (glibc), not Alpine Linux (musl)
|
|
// This saves ~16MB (sharp-musl) per serverless function
|
|
outputFileTracingExcludes: {
|
|
'*': [
|
|
'node_modules/.pnpm/@img+sharp-libvips-*musl*',
|
|
// Exclude SPA/desktop/mobile build artifacts from serverless functions
|
|
'public/_spa/**',
|
|
'dist/desktop/**',
|
|
'dist/mobile/**',
|
|
'apps/desktop/**',
|
|
'packages/database/migrations/**',
|
|
],
|
|
},
|
|
};
|
|
const nextConfig = defineConfig({
|
|
...(isVercel ? vercelConfig : {}),
|
|
});
|
|
|
|
export default nextConfig;
|