Compare commits

...

4 Commits

Author SHA1 Message Date
Thuc Pham a492e0b3d9 fix: update externals config for chroma 2024-10-23 15:53:50 +07:00
Thuc Pham 59ecb2309a use nextRuntime to disable module resolution 2024-10-23 15:41:57 +07:00
Thuc Pham 4ffaec4101 Create funny-drinks-argue.md 2024-10-23 13:51:37 +07:00
Thuc Pham 52d436b4e9 fix: replicate deps warning in nextjs 2024-10-23 13:49:35 +07:00
2 changed files with 22 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
fix: replicate deps warning in nextjs
+17 -5
View File
@@ -24,7 +24,7 @@ export default function withLlamaIndex(config: any) {
"@xenova/transformers",
);
const userWebpack = config.webpack;
config.webpack = function (webpackConfig: any) {
config.webpack = function (webpackConfig: any, options: any) {
if (userWebpack) {
webpackConfig = userWebpack(webpackConfig);
}
@@ -32,14 +32,26 @@ export default function withLlamaIndex(config: any) {
...webpackConfig.resolve.alias,
"@google-cloud/vertexai": false,
};
// Disable modules that are not supported in vercel edge runtime
if (options?.nextRuntime === "edge") {
webpackConfig.resolve.alias["replicate"] = false;
}
// Following lines will fix issues with onnxruntime-node when using pnpm
// See: https://github.com/vercel/next.js/issues/43433
webpackConfig.externals.push({
const externals: Record<string, string> = {
"onnxruntime-node": "commonjs onnxruntime-node",
sharp: "commonjs sharp",
chromadb: "commonjs chromadb",
unpdf: "commonjs unpdf",
});
chromadb: "chromadb",
unpdf: "unpdf",
};
if (options?.nextRuntime === "nodejs") {
externals.replicate = "commonjs replicate";
}
webpackConfig.externals.push(externals);
return webpackConfig;
};
return config;