Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Use with Webpack and other asset bundlers creates a bloated package #174

Closed
jwhazel opened this issue Nov 29, 2019 · 3 comments
Closed

Use with Webpack and other asset bundlers creates a bloated package #174

jwhazel opened this issue Nov 29, 2019 · 3 comments

Comments

@jwhazel
Copy link

jwhazel commented Nov 29, 2019

Issue:

When including Tabletop as an es6 module and using a build tool that bundles modules/assets like Webpack or ParcelJS, the compiled package ends up being way larger than it should be. The smallest example I can create clocks in at a whopping ~1.1 MB minified. This issue will also affect several popular frameworks like Create React App and Vue Cli since they use Webpack internally. The issue stems from using Request as a dependency for when Tabletop is used inside NodeJS.

Simple test case:

Tested with:

  • Mac OS 10.15.1
  • NodeJS 12.12.0
  • Tabletop 1.6.2
  • Webpack 4.41.2 and ParcelJS 1.12.4

Why this happens:

The offending code is here: https://github.com/jsoma/tabletop/blob/master/src/tabletop.js#L9
Despite the comment that says "Webpack will not include it" it still does. It's technically mostly the dependency chain in Request itself that causes the bloat. If you comment out this whole if statement, the compiled asset using the simple test case will drop to a much more reasonable ~10 KB (of course you can't use it in Node then).

How to fix:

I'm not sure the best way to fix this that satisfies all use cases. One idea would be to switch from using the Request package and instead use something like Axios which is fully compatible with Node https://github.com/axios/axios. I did a quick test by swapping axios for request in the require statement and it produced a bundle of ~26 KB. That's not a perfect fix since it's still bundling code that will never be used in the browser. But that's still 97% smaller than using Request. I can whip up a PR if you like, but thought someone else might have an even better idea.

@diegoliv
Copy link

I can confirm that this is also happening for me. I'm using Parcel as my bundler, and the bundle size is around 1.2Mb. Tabletop is easy to use, but if the bundle size is that big, then is a big no for me at the moment. Which is a shame because I can't make it google-spreadsheet package to work with Parcel, and the other options are too involved. Would be really nice to get this fixed.

@jsoma
Copy link
Owner

jsoma commented Mar 19, 2020

Happy to take a PR to switch it over to axios, or I'll go ahead and make the change myself tomorrow!

@jwhazel
Copy link
Author

jwhazel commented Mar 31, 2020

Sorry, forgot about this issue. It looks like the v3 feed api will start sunsetting at the end of May with a final cut off at Sept 30 2020 basically rendering Tabletop useless. I'm not sure a PR to fix this is really worth it at this point.

jsoma added a commit that referenced this issue Apr 21, 2020
@jsoma jsoma closed this as completed May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants