Skip to content

Version Control

Vals are immutable, but you can publish new versions of vals. Versions start at 0 and go up from there. When you reference a val, you always get the most recent version. You can toggle which version you’re looking at via the dropdown menu next to the val’s name.

Imports & pinning

Vals are imported via esm.town URLs. If you leave off the version number, it’s an unpinned import, and you’ll always get the latest version. If you include a version number, it’s a pinned import, and you’ll always get that version.

Unpinned val importRun in Val Town ↗
import { myVal } from "https://esm.town/v/username/valname";
Pinned val importRun in Val Town ↗
import { myVal } from "https://esm.town/v/username/valname?v=7";

When you import one of your own vals, via the @ helper, it will be imported unpinned, so you will automatically get all new changes. When you import another user’s val via @, it will pin your import to the most recent version of that val (ie it will end it ?v=7 or whatever the current version number is), so if they change it, you won’t get automatic updates.

This makes your code more stable and protects you against code injection attacks. You can override this default behavior if you trust the user not to break your code: remove the v query param in the import statement, and your code will always use the latest version of that val.

Versions of external imports

You can also specify versions of NPM modules by using an @ symbol:

import { min } from "npm:lodash-es@4.17.21";
// Or you can specify a version range, like
// you would in a package.json file:
import { min } from "npm:lodash-es@4";

We highly recommend pinning imported modules because their APIs can change between versions and unexpectedly break your code.

Lockfiles

When you save a Val we generate a deno.lock lockfile. This pins all versions of your dependencies and also calculates hashes to verify that the content of a dependency does not change.

When you save a Val, we regenerate the lockfile from scratch, re-pinning your unpinned dependencies to whatever their current versions are at that new time.

Additionally, when you save a val, we find all the vals in your account that depend on that val and mark their lockfiles for regeneration. That way you can keep rapidly iterating and we’ll make sure to update dependency relationships in your vals.

Read more about how and why we use lockfiles here: https://blog.val.town/blog/lockfiles/