Skip to content

Commit 865f2eb

Browse files
committed
use eval
1 parent 4916531 commit 865f2eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/api/constants.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ import { LIB_NAME, LIB_VERSION } from '@/src/version';
1616

1717
export const RAGSTACK_REQUESTED_WITH = (() => {
1818
try {
19-
// eslint-disable-next-line @typescript-eslint/no-var-requires
20-
const ragstack = require('@datastax/ragstack-ai');
19+
/**
20+
* Do not use require() here, it will break the build in some environments such as NextJS application^M
21+
* if @datastax/ragstack-ai is not installed (which is perfectly fine).
22+
*/
23+
const ragstack = eval(`require('@datastax/ragstack-ai')`);
2124
const version = ragstack['RAGSTACK_VERSION'] || "?";
2225
return `ragstack-ai-ts/${version}`
2326
} catch (e) {
2427
return '';
2528
}
2629
})();
30+
console.log("RAGSTACK_REQUESTED_WITH", RAGSTACK_REQUESTED_WITH)
2731

2832
/**
2933
* @internal

0 commit comments

Comments
 (0)