sveltejs / sites

Monorepo for the sites in the Svelte ecosystem
https://svelte.dev
MIT License
286 stars 123 forks source link

[REPL] Switch to jsDelivr #457

Open longnguyen2004 opened 1 year ago

longnguyen2004 commented 1 year ago

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.

jimaek commented 1 year ago

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

sean-mystyle commented 1 year ago

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

https://www.jsdelivr.com/unpkg

theetrain commented 1 year ago

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

longnguyen2004 commented 1 year ago

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

benmccann commented 1 year ago

@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?

jimaek commented 1 year ago

Yep I monitor jsDelivr mentions in case someone needs help

PuruVJ commented 6 months ago

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

MartinKolarik commented 6 months ago

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.

PuruVJ commented 6 months ago

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?

MartinKolarik commented 6 months ago

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.

benmccann commented 4 months ago

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