Skip to content

Commit 3461eb9

Browse files
committed
remove ai from peerDependencies
- import unzipper dynamically and show error if not installed
1 parent 4744820 commit 3461eb9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,17 @@
5959
"mime-types": "^2.1.35",
6060
"pdf-ts": "^0.0.2",
6161
"turndown": "^7.2.0",
62-
"xlsx": "^0.18.5"
62+
"xlsx": "^0.18.5",
63+
"ai": "^4.0.22"
6364
},
6465
"peerDependencies": {
65-
"ai": "^4.0.22",
6666
"youtube-transcript": "^1.2.1",
6767
"unzipper": "^0.12.3"
6868
},
6969
"peerDependenciesMeta": {
7070
"youtube-transcript": {
7171
"optional": true
7272
},
73-
"ai": {
74-
"optional": true
75-
},
7673
"unzipper": {
7774
"optional": true
7875
}

src/converters/zip.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ConverterOptions, ConverterResult, DocumentConverter } from "../types";
22
import * as fs from "fs/promises";
33
import * as path from "path";
4-
import * as unzipper from "unzipper";
54

65
export class ZipConverter implements DocumentConverter {
76
async convert(
@@ -29,6 +28,15 @@ export class ZipConverter implements DocumentConverter {
2928
text_content: `[ERROR] Invalid zip file path: ${localPath}`
3029
};
3130
}
31+
let unzipper;
32+
try {
33+
unzipper = await import("unzipper").then((mod) => mod.default);
34+
} catch (error) {
35+
console.error(
36+
"Optional dependency 'unzipper' is not installed. Run `npm install unzipper` to enable this feature."
37+
);
38+
return null;
39+
}
3240
try {
3341
await fs.mkdir(newFolder, { recursive: true });
3442
const zip = await unzipper.Open.file(localPath);

0 commit comments

Comments
 (0)