Introducing `jsr:` Support
Published on

Introducing `jsr:` Support

Authors

Introducing jsr: Support

We're excited to announce that you can now install JSR packages directly with the vlt client!

$ vlt install jsr:<scope>/<name>
$ vlt install jsr:<scope>/<name>@<version range>

For example, to install @luca/cases from the jsr: registry, you can do this:

$ vlt install jsr:@luca/cases@1

This will save the spec back to your package.json in the way you might expect:

{
  "dependencies": {
    "@luca/cases": "jsr:1"
  }
}

If you just wanna use JSR packages in your vlt projects, you can stop reading now. If you're curious about how it works and what kinds of things it opens up in the future, keep reading!

How Does It Work?

If you look closely at vlt's lockfile, you'll see a clue about what's actually going on under the hood:

$ cat vlt-lock.json
{
  "options": {},
  "nodes": {
    "·https%3A§§npm.jsr.io§·@jsr§[email protected]": [
      0,
      "@jsr/luca__cases",
      "sha512-h3nOT3+JVCXBsLd+st9cytZO+iqJYTTsm3rOrtZZXBgJ0nzBA5mDR9dI3k8wBDQ5AAqqJjD3UkhLxoRCEKwzgg==",
      "https://npm.jsr.io/~/11/@jsr/luca__cases/1.0.0.tgz"
    ]
  },
  "edges": {
    "file·. @luca/cases": "prod jsr:1 ·https%3A§§npm.jsr.io§·@jsr§[email protected]"
  }
}

The jsr: prefix uses a special new configuration, jsr-registries, which maps these prefixes to the URL serving the JSR style registry. The https://npm.jsr.io/ registry is hard coded as the jsr: prefix, but this is extensible with the expectation that some day you'll be able to host your own JSR registries elsewhere.

The vlt dependency specification parser translates this jsr: specifier to a normal registry specifier using JSR's npm compatibility layer. While this is arguably not ideal for cases where you want the uncompiled TypeScript, it offers the best trade-off in terms of compatibility with zero added configuration.

At some point in the future, we may add a way to tell vlt to fetch the raw un-transpiled TypeScript from your JSR registries, but for now, we went with the thing that Just Works™️ for all Node, Bun, and Deno projects.

Technically this jsr: prefix is an alias just like npm:, but with the added behavior of doing this name remapping to the compiled version of the package.

Try it out today!

What do you think of this feature? What would you like to see us support next?

Come join our Discord and let us know!

Join the waitlist

Curious to learn more about vlt? Join our waitlist and get early access.

Sign up