sites icon indicating copy to clipboard operation
sites copied to clipboard

[REPL] Switch to jsDelivr

Open longnguyen2004 opened this issue 2 years ago • 11 comments

unpkg has been intermittent for ~6 months. jsDelivr is more resilient, (seems to) supports CORS and also hosts files from GitHub, so switching to it would fix #282 as well.

longnguyen2004 avatar Apr 04 '23 17:04 longnguyen2004

Let us know if the jsDelivr team can help with anything. jsDelivr is under active development and aims at production use-cases with multi-CDN logic https://www.jsdelivr.com/network/infographic

jimaek avatar Apr 04 '23 18:04 jimaek

JSDelivr has a helpful tool for converting an unpkg URL to their jsdelivr url here:

https://www.jsdelivr.com/unpkg

sean-mystyle avatar Apr 04 '23 19:04 sean-mystyle

In my related comment, I suggested using Skypack to help with package compatibility: https://github.com/sveltejs/sites/issues/137#issuecomment-1360763974

theetrain avatar Apr 09 '23 11:04 theetrain

jsDelivr also has esm.run, which does ESM conversion and minification as well.

longnguyen2004 avatar Apr 09 '23 12:04 longnguyen2004

@longnguyen2004 thanks for the suggestion (as well as the issues in Svelte itself - sorry we have a hard time keeping up with all the issues :smile:)

Let us know if the jsDelivr team can help with anything. jsDelivr is under active development and aims at production use-cases with multi-CDN logic https://www.jsdelivr.com/network/infographic

@jimaek, just curious, how were you made aware of this issue? Do you have a GitHub alert for jsDelivr always running or something?

benmccann avatar Apr 17 '23 22:04 benmccann

Yep I monitor jsDelivr mentions in case someone needs help

jimaek avatar Apr 18 '23 07:04 jimaek

Hi, I'm experimenting with jsDelivr in REPL(See #551). So far loving it, only issue is that it doesn't resolve barrel imports(https://cdn.jsdelivr.net/npm/radix-svelte/dist/components) while unpkg does(https://unpkg.com/radix-svelte/dist/components). Can be done manually in the REPL by resolving with different methods('.js', '.mjs', '.cjs', './index.js', 'index.cjs', 'index.mjs'), but that would require 7 fetch requests in worst case, which is too much to be doing on user's device.

That is something that would make transitioning very easy. Is this possible to implement on jsdelivr's end? cc @jimaek

PuruVJ avatar Dec 29 '23 10:12 PuruVJ

Hi, I'm experimenting with jsDelivr in REPL(See #551). So far loving it, only issue is that it doesn't resolve barrel imports(https://cdn.jsdelivr.net/npm/radix-svelte/dist/components) while unpkg does(https://unpkg.com/radix-svelte/dist/components). Can be done manually in the REPL by resolving with different methods('.js', '.mjs', '.cjs', './index.js', 'index.cjs', 'index.mjs'), but that would require 7 fetch requests in worst case, which is too much to be doing on user's device.

That is something that would make transitioning very easy. Is this possible to implement on jsdelivr's end? cc @jimaek

Hey, we support server-side resolving in ESM mode so this would generally work: https://cdn.jsdelivr.net/npm/radix-svelte@latest/dist/components/+esm but here the package declares exports and doesn't expose that directory, so it can't be accessed like that. For packages with no exports it works with all files.

MartinKolarik avatar Dec 29 '23 10:12 MartinKolarik

I am facing some weird problems with esm.run, where the output component code just doesn't work with esm.run, but does with regular old jsdelivr. Is there a way to configure the rollup and terser version esm.run uses?

PuruVJ avatar Jan 02 '24 17:01 PuruVJ

Is there a way to configure the rollup and terser version esm.run uses?

No, but if the files happen to be built using an older version, we might be able to update them to the version we use at this time.

MartinKolarik avatar Jan 07 '24 16:01 MartinKolarik

We gave up on esm.run because the bundling was causing issues with ending up with multiple versions of the Svelte runtime. jsdelivr would still be interesting though

benmccann avatar Feb 13 '24 15:02 benmccann