cube-js / cube-js/cube

Reduce bundle size of @cubejs-client

Open
#960 9 comments 5 reactions 0 assignees View on GitHub
client:core help wanted
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 10h
Merged PRs (30d)
203

Description

**Is your feature request related to a problem? Please describe.**
The cube.js client is an awesome way to interact with the server. However, it's [rather large](https://bundlephobia.com/result?p=@cubejs-client/core@0.19.56) for a client side library, with the bulk of the size of it being comprised of dependencies, and half of which come from a single library (moment). There are also polyfills bundled with the library that could be deferred to the user's own browser support needs. This could lead to a large increase in the size of javascript apps that utilize the cube client.

**Describe the solution you'd like**
There are some smaller alternatives to moment that provide the same functionality. [dayjs](https://github.com/iamkun/dayjs) is one of the most popular and is 5% the size. Most of the usage of rambda could be replaced with native ES6 and polyfilled by the user depending on the browsers they support. There may also be value in re-arranging some of the code to allow for tree shaking.

**Describe alternatives you've considered**
The alternative to this would be to interact directly with the server through http. The cube client provides some really useful functionality and would be great to use if it was a little more lightweight. It seems that the core of the package has almost all of the logic and makes up a small percentage of the size.

**Additional context**
Any moment replacement would have to be strenuously tested to make sure that it can parse the same date formats, as users can pass arbitrary strings to moment. Even then, all of the above suggestions would probably be considered breaking. I wanted to see if others have the same concerns and if there was interest in a pull request before I try to create one. Let me know if I completely missed the mark with the above.

I'm really looking forward to working with cube. Reporting has always been a pain point for me and this seems like an excellent solution. Thanks in advance!

Contributor guide

Open the contributing guide

Research direction

Start with the @cubejs-client/core package and the bundlephobia result linked in the issue, then inspect which dependencies and polyfills dominate its bundle. Compare a smaller date-library approach and tree-shaking or native ES6 options, while checking compatibility with arbitrary date strings. Done means a materially smaller client bundle without breaking the existing client behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.