fix(api): import pdf-parse from lib path (avoid index.js auto-test mode in ESM)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,12 +4,12 @@ import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
import mammoth from 'mammoth';
|
||||
import * as pdfParseNs from 'pdf-parse';
|
||||
// pdf-parse имеет auto-test mode в index.js, ломающий ESM. Импортируем функцию напрямую из lib.
|
||||
// @ts-expect-error пакет без declaration на этом пути
|
||||
import pdfParseRaw from 'pdf-parse/lib/pdf-parse.js';
|
||||
|
||||
// pdf-parse в ESM экспортирует default или сам namespace — нормализуем.
|
||||
const pdfParse: (buf: Buffer) => Promise<{ text: string; numpages: number }> =
|
||||
// @ts-expect-error namespace shape varies between cjs/esm
|
||||
(pdfParseNs.default ?? pdfParseNs) as never;
|
||||
pdfParseRaw as unknown as (buf: Buffer) => Promise<{ text: string; numpages: number }>;
|
||||
|
||||
const execFileP = promisify(execFile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user