-
-
Notifications
You must be signed in to change notification settings - Fork 170
download packages directly from npm #1248
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@MartinKolarik thanks for the tip! made that change |
Okay I got very carried away here — the code was long overdue for a bit of an overhaul, and this makes some progress in that direction (merging |
I tried to test this on mobile where I'd be most worried about extra bytes and could never get the unpkg one to finish loading. The version for this PR was also quite good - admittedly on 5g, which is probably quite a bit better than 3g. But this PR was a clear winner for me. @PuruVJ you might want to give this a spin both as someone who has the least internet bandwidth among us and as someone who's worked on this in the past |
I can confirm that this is nearly as fast for me. On multiple hard reloads over VPN, I can't say the new version is faster, but since it does not feel slower either over VPN, I can say this is the right direction to go forward in |
(currently trying to diagnose an absolutely insane bug — was randomly trying out stuff from my |
Alternative to #1244. Rather than fetching files one at a time, we can just reuse the existing mechanism for downloading tarballs. This way, we download way fewer files, with fewer waterfalls and fewer opportunities for network flakiness.
In some cases it does mean downloading more bytes, because a) you might only be using one of several exposed entrypoints, and b) package authors can be lazy about what goes into their packages. But anecdotally the playground seems faster with this approach (though it'll be interesting to take a look at a preview deployment).
We do still need to use a package CDN, since the npm registry API doesn't seem to offer a way to resolve incomplete versions (e.g. you can't do
@1
or@1.2
, you have to do@1.2.3
), and the 'packument' (yes they really call it that) that contains details of all the published versions can be a very large file. So we fetch apackage.json
from a package CDN as a relatively cheap way to determine the exact version. This PR uses jsDelivr rather than unpkg.WIP:
imports
for the sake of downloadsversion=local
working (which I suspect will mean creating an endpoint that serves the local files as a tarball)packages/repl
) and compiler (inpackages/editor
)