selfhosted-svelte-browser-import-pmb Svelte Themes

Selfhosted Svelte Browser Import Pmb

Let me use `svelte-browser-import` self-hosted (or offline) with less boilerplate code.



selfhosted-svelte-browser-import-pmb

Let me use svelte-browser-import self-hosted (or offline) with less boilerplate code.

Motivation

Svelte is a very promising web UI framework, and thanks to svelte-browser-import you can even compile your project directly inside your browser, avoiding a separate build step for local development.

Unfortunately, with default options, svelte-browser-import loads packages from a hard-coded URL independent from where it itself is loaded from. I want it to load its imports from where it itself was loaded, so I can easily self-host my entire app (the development version of it) to save internet traffic and also be able to efficiently develop it offline.

Fortunately, that is indeed possible, but you need to configure it to do so. This little package here does that config for me.

Usage

<div id="myCoolApp" class="svelteApp"></div>
<script type="module">import '/node_modules/selfhosted-svelte-browser-import-pmb/index.mjs';</script>
  • Make sure you have the peerDependencies installed.
  • Will load ./myCoolApp.svelte into that <div>.
    • You can change the filename by adding an attribute data-app-files="somethingElse.svelte". It's plural because you may give multiple filenames, separated by any combination of whitespace from the "Basic Latin" Unicode block.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes