npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sveltejs-adapter-ipfs

v0.4.12

Published

See the demo repo on why it is needed : https://github.com/bug-reproduction/svelte-kit-static-ipfs/tree/fixes#fixes

Downloads

183

Readme

sveltejs-adapter-ipfs

See the demo repo on why it is needed : https://github.com/bug-reproduction/svelte-kit-static-ipfs/tree/fixes#fixes

Adapter for Svelte apps that prerenders your entire site as a collection of static files with support for IPFS.

This is based on adapter-static but add a post-processing step that do the following :

It replace every absolute path to relative one based on the index.html position in the file system

Here are the values it prepend

  • for the root index.html, the value would be .
  • for the blog/index.html, the value would be ..
  • for the blog/1/index.html, the value would be ../..

this is done via ipfs_fixes/relativize_pages.cjs

We also need to also relativize call to server function, this is done by ipfs_fixes/relativize_js.cjs but is not full proof as some fetch call are renamed. Svelte kit need to ensure the base (from $app/paths) is prepended for every server route fetch

At runtime (after hydration), we are in a different context though and we want the base path (from $app/paths) to be absolute so it works past navigation. This applies to both base and assets. The way to achieve that is to simply set them at runtime, (the most early possible)

For that we use the following: window.BASE = location.pathname.split('/').slice(0, -"${RELBASE}".split('..').length).join('/');

This is done via ipfs_fixes/inject_base.cjs

This also inject the assets value via

  start({
    assets: window.BASE,
    env: {},
    ...
  });

We also then need to make use of window.BASE in the runtime for the base, which is hardocded in chunks/paths-....js or sometime chunks/singletons-....js

this is done via ipfs_fixes/inject_base_in_paths_file.cjs and ipfs_fixes/inject_base_in_singletons_file.cjs

link issues

now it would be great if we could still reference page link using absolute links like href="/about/" but if we have to do the following instead, that is ok : href={`${base}/about/`}

Unfortunately the latter is not sufficient as vite/sveltekit will hardcode the result at build time to /about/ because it detect that base is a constant.

To avoid that best is to use a function that trick the compiler that it might not always be the same and so we can get aroudn with

<a href={`pathname(/about/)`}>About></a>