lockfileImportMap
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Use an import map to make sure your Val frontend and backend are always using the exact same versions.
We already track the versions of your https
imports in the Deno lockfile. Now you can expose those on the frontend as well using an import map.
Use it like so:
import { lockfileImportMap } from "https://esm.town/v/maxm/lockfileImportMap"
return new Response(`
<script type="importmap">${lockfileImportMap()}</script>
<script type="module" src="${import.meta.url}"></script>
`, { headers: {"content-type": "text/html"}});
Here's an example app I made with townie: https://www.val.town/v/maxm/emojiTodoListApp
You can see that the "https://esm.sh/react"
import imports the version directly without any redirects. Saving on network hops and also ensuring version stability!