Skip to content

Can i run Svelte fully as a CDN? #15658

Answered by brunnerh
struckchure asked this question in Q&A
Discussion options

You must be logged in to vote

No, not for Svelte 5, which no longer bundles everything.
Resolving all the imports necessary is a huge pain.

Would probably look similar to this:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Svelte Live Compilation</title>
	<script type="importmap">
		{
			"imports": {
				"svelte": "https://cdn.jsdelivr.net/npm/[email protected]/src/index-client.js",
				[GIANT LIST OF MAPPINGS HERE]
			}
		}
	</script>
</head>
<body>
	<script type="module">
		import { mount } from 'svelte';
		import { compile } from 'svelte/compiler';

		const code = `
			<${''}script>
				let { name } = $props();

				let co…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@struckchure
Comment options

@brunnerh
Comment options

Answer selected by struckchure
@struckchure
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants