-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: leave code as-is #560
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not merge now. Still have issue with ESM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! Mostly asking questions as we're introducing a lot of new tools with this PR (so we should be aware of the risks).
There are some possibilities for us to publish this package: first is bundle vs no-bundle, and second is esm vs cjs. Bundle vs No-BundleThe issue with bundle llamaindex is it's too large, and if we bundle the whole llamaindex into one js file, that will cause many downstream problems. For example, in next.js, you have to set externals or server side packages externals to ensure next.js(webpack) would not bundle the code. // ./dist/index.js
import 'pg'
import 'mongo'
import 'openai'
import 'xxx'
// ...
export ... You can see tons of packages are included at the top of the entry; that's why. At the very first, I tried to use So from to beginning issue, we just want the user could control import so that it's possible for downstream to manually tree-shake and still not waste our members' too much time on this. ESM vs CJSFirst, llamaindex should be an ESM package, not because ESM is the future or something. More reasons are because the current TypeScript typecheck or modern bundler is more strict on ESM modules instead of CJS. It will be much easier for the analysis tool to check our code. For example, in this PR, I change the module to Also, change to ESM could help llamaindex support multiple environments like (Deno, Edge runtime, Bun, or even browsers) because ESM is the standard nowadays |
Co-authored-by: leehuwuj <[email protected]> (cherry picked from commit ea0331e)
(cherry picked from commit 68fc6e8)
Releases: [email protected] [skip ci] (cherry picked from commit b6ed679)
(cherry picked from commit 885fa31)
We don't bundle the code since it puts lots of effort, and I think bundling is the downstream issue (like next.js bundler or vite)
And we keep the file as is so that everyone can import it directly
Followup: #560 (comment)
Thanks for some TypeScript QA from @Jack-Works