From ec59acd329fbd72ab66be0abb2db686c3c5a95a6 Mon Sep 17 00:00:00 2001
From: Marcus Schiesser <mail@marcusschiesser.de>
Date: Mon, 22 Jul 2024 18:37:13 +0200
Subject: [PATCH] fix: bundling issue with pnpm (#1060)

Co-authored-by: Alex Yang <himself65@outlook.com>
---
 .changeset/perfect-pigs-decide.md | 5 +++++
 packages/llamaindex/src/next.ts   | 6 ++++++
 2 files changed, 11 insertions(+)
 create mode 100644 .changeset/perfect-pigs-decide.md

diff --git a/.changeset/perfect-pigs-decide.md b/.changeset/perfect-pigs-decide.md
new file mode 100644
index 000000000..f3567a512
--- /dev/null
+++ b/.changeset/perfect-pigs-decide.md
@@ -0,0 +1,5 @@
+---
+"llamaindex": patch
+---
+
+fix: bundling issue with pnpm
diff --git a/packages/llamaindex/src/next.ts b/packages/llamaindex/src/next.ts
index a5dac67d1..26d31735c 100644
--- a/packages/llamaindex/src/next.ts
+++ b/packages/llamaindex/src/next.ts
@@ -32,6 +32,12 @@ export default function withLlamaIndex(config: any) {
       "@google-cloud/vertexai": false,
       "groq-sdk": false,
     };
+    // Following lines will fix issues with onnxruntime-node when using pnpm
+    // See: https://github.com/vercel/next.js/issues/43433
+    webpackConfig.externals.push({
+      "onnxruntime-node": "commonjs onnxruntime-node",
+      sharp: "commonjs sharp",
+    });
     return webpackConfig;
   };
   return config;
-- 
GitLab