SukkaW / nolyfill

Speed up your package installation process, reduce your disk usage, and extend the lifespan of your precious SSD.
MIT License
995 stars 14 forks source link

Nolyfills for `@stdlib`? #79

Open hfhchan-plb opened 1 week ago

hfhchan-plb commented 1 week ago

I'm seeing huge graphs in stdlib with deps which are absolutely unreal.

Examples:

hfhchan-plb commented 1 week ago

On further inspection it looks like they have accidentally included @stdlib/cli-ctor and @stdlib/fs-read-file in dependencies instead of devDependencies (tracked at https://github.com/stdlib-js/stdlib/issues/2469), but assert-is-function / assert-s-array are still way overboard with poisonous dep chains.

SukkaW commented 1 week ago

I noticed that assert-is-function behaves differently than typeof, so probably we can't simplify it to typeof x === 'function'.

kgryte commented 6 days ago

assert-is-function / assert-is-array are still way overboard with poisonous dep chains.

@hfhchan-plb We don't need to litigate on this issue, but this is a mischaracterization. stdlib simply splits out requisite functionality into separate well-defined APIs. It does not bring in "poisonous" external dependencies. The reason for modularity is to allow code reuse across multiple packages. This, in turn, allows users who depend on more stdlib functionality to benefit from smaller, not larger, eventual bundle sizes, as utilities and helpers are not duplicated across packages.

If you want standalone modules without dependency chains, that is fine; we provide that. Just use our UMD builds (see https://github.com/stdlib-js/assert-is-function#installation).

hfhchan-plb commented 6 days ago

@kgryte Apologies.

While cleaning up deps in a project I am on, I found many packages from @stdlib, many with names looking suspiciously similar to other packages that nolyfill replaces.

This turns out to be due to @segment/tsub lib, which was included in our project recently, resulting in over 98 packages being imported from @stdlib, with many packages referencing each other. I couldn't even load the dep graph without the page lagging every time I scrolled on my mbp M1.

In my initial investigation, I believe some of these deps to be false positives, hence I opened the other issue https://github.com/stdlib-js/stdlib/issues/2469 instead.

Based on your response I believe the core issue is that @segments/tsub (coming from @segment/analytics-next) is pulling in severely outdated versions of libraries. I can confirm the newest version of @stdlib/math-base-special-ldexp no longer has deps on CLI tools.

Unfortunately it looks like segment has paused development for @segment/tsub, while still using it as a dep, and there is already an open ticket requesting the lib to be updated to 0.2.1 (https://github.com/segmentio/tsub-js/issues/45).

Based on that, I doubt upstream will be able to change to UMD builds in a short amount of time.

hfhchan-plb commented 6 days ago

@SukkaW

There are still a significant amount of indirect deps with the newest version of @stdlib/math-base-special-ldexp. E.g. @stdlib/assert-is-function, @stdlib/assert-is-plain-object, @stdlib/utils-get-prototype-of, @stdlib/math-base-assert-is-infinite etc still have huge chains.

Looking at assert-is-function, which is basically a thin wrapper over utils-type-of, behaviour is changed only to fix wrong behaviour from Chrome 1 - 12, Safari 8, and PhantomJS (see: https://github.com/stdlib-js/utils-type-of/blob/main/lib/check.js). All three of which are long dead, and deader than Node 12. I suppose it should be safe to replace this with `typeof x === 'function'.