Skip to content
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

chore: replace unpkg with jsdelivr #10748

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sites/svelte-5-preview/src/lib/Repl.svelte
Expand Up @@ -13,7 +13,7 @@
import { get_full_filename } from './utils.js';
import Compiler from './Output/Compiler.js';

export let packagesUrl = 'https://unpkg.com';
export let packagesUrl = 'https://cdn.jsdelivr.net/npm';
export let svelteUrl = `${BROWSER ? location.origin : ''}/svelte`;
export let embedded = false;
/** @type {'columns' | 'rows'} */
Expand Down
7 changes: 3 additions & 4 deletions sites/svelte-5-preview/src/lib/workers/bundler/index.js
Expand Up @@ -48,8 +48,7 @@ self.addEventListener(
const { version } = await fetch(`${svelte_url}/package.json`).then((r) => r.json());
console.log(`Using Svelte compiler version ${version}`);

// unpkg doesn't set the correct MIME type for .cjs files
// https://github.com/mjackson/unpkg/issues/355
// .cjs files have an unhelpful MIME type
const compiler = await fetch(`${svelte_url}/compiler.cjs`).then((r) => r.text());
(0, eval)(compiler + '\n//# sourceURL=compiler.cjs@' + version);

Expand Down Expand Up @@ -308,7 +307,7 @@ async function get_bundle(uid, mode, cache, local_files_lookup) {
return await follow_redirects(url, uid);
}
} else {
// fetch from unpkg
// fetch from jsdelivr
self.postMessage({ type: 'status', uid, message: `resolving ${importee}` });

const match = /^((?:@[^/]+\/)?[^/]+)(\/.+)?$/.exec(importee);
Expand Down Expand Up @@ -343,7 +342,7 @@ async function get_bundle(uid, mode, cache, local_files_lookup) {
pkg_url_base
};
} catch (_e) {
throw new Error(`Error fetching "${pkg_name}" from unpkg. Does the package exist?`);
throw new Error(`Error fetching "${pkg_name}" from jsdelivr. Does the package exist?`);
}
};

Expand Down
3 changes: 1 addition & 2 deletions sites/svelte-5-preview/src/lib/workers/compiler/index.js
Expand Up @@ -29,8 +29,7 @@ self.addEventListener(
.then((r) => r.json())
.catch(() => ({ version: 'experimental' }));

// unpkg doesn't set the correct MIME type for .cjs files
// https://github.com/mjackson/unpkg/issues/355
// .cjs files have an unhelpful MIME type
const compiler = await fetch(`${svelte_url}/compiler.cjs`).then((r) => r.text());
(0, eval)(compiler + '\n//# sourceURL=compiler.cjs@' + version);

Expand Down