stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

npm package too big for jsDelivr

Open domoritz opened this issue 3 years ago • 9 comments

I'm trying to load this package from jsDelivr CDN but it fails because the package is over 100 MB. Are there any files that could be removed to reduce the package size?

domoritz avatar Mar 02 '21 09:03 domoritz

Probably related to https://github.com/stdlib-js/stdlib/issues/373

domoritz avatar Mar 02 '21 09:03 domoritz

A local installation also is hundreds of MBs.

domoritz avatar Mar 02 '21 10:03 domoritz

Thanks for reaching out! Indeed, the project is currently not as easily consumable as it should be. One of our next steps is to finish the tooling to publish individual namespace packages to npm (e.g., all of @stdlib/assert or all of @stdlib/random). Will keep you posted.

However, we do have distributable UMD bundles of the project that you might want to look at. They are also available via the jsDelivr CDN:

https://github.com/stdlib-js/stdlib/tree/develop/dist#usage

Planeshifter avatar Mar 02 '21 17:03 Planeshifter

@domoritz Beside using one of the UMD bundles, you can also do one of the following:

  1. If your target environment supports ESM, you could consider our experimental ESM build.

  2. Install locally, vendor, and host.

  3. Use project tooling, similar to how we do here, to create your own UMD bundle.

Would any of the above possibly work?

kgryte avatar Mar 02 '21 17:03 kgryte

Awesome to hear that improvements are in the works.

I wanted to play with stdlib in observable and was hoping to have a simple import of the library. I saw https://observablehq.com/@kgryte/stdlib?collection=@kgryte/stdlib uses a specific import from https://unpkg.com/@stdlib/[email protected]/dist/stdlib-flat.min.js but it would be nice to use the standard require or import syntax from Observable.

The ESM bundle doesn't seem to work on Observable yet, btw. Screen Shot 2021-03-02 at 19 03 56

domoritz avatar Mar 02 '21 18:03 domoritz

@domoritz Here is an example of loading individual ESM modules into Observable.

kgryte avatar Mar 02 '21 18:03 kgryte

🙌 thanks for the link. stdlib = require('@stdlib/dist-tree') is perfect for experimenting and the esm imports for individual packages are perfect once you know what you need.

domoritz avatar Mar 02 '21 18:03 domoritz

Awesome. Let us know if we can be of any further help. :)

kgryte avatar Mar 02 '21 18:03 kgryte

Update: individual packages are now consumable. While the individual packages do not expose UMD bundles atm, one can locally install and then bundle for use in web applications.

kgryte avatar Aug 14 '21 00:08 kgryte

Every standalone package currently contains UMD bundles, along with instructions as to how to use in, e.g., Observable.

@Planeshifter Is there anything more we can do here?

kgryte avatar Nov 11 '23 10:11 kgryte

Posting a final update here. I've updated an Observable notebook, which demonstrates how to perform benchmarks, to use standalone package UMD bundles.

I've further created a test notebook, which attempts to load the various UMD bundles across (almost) all standalone repositories. Note that this notebook takes several minutes to run. In short, all UMD bundles for those packages which are browser-compatible are able to be loaded into Observable via jsDelivr.

Accordingly, I will go ahead and close this issue. If further issues arise, we can revisit by either reopening this issue or opening a new issue.

kgryte avatar Nov 23 '23 10:11 kgryte