Conversation
📝 WalkthroughWalkthroughThe hover provider in src/providers/hover/npmx.ts was updated to better handle missing package metadata and JSR specifiers. New behaviour: when getPackageInfo(name) is falsy and the version is a JSR specifier, the hover now returns a jsr.io link and a not-on-npmx warning; otherwise it returns a generic "Unable to fetch package information" hover. Imports and URL helpers were changed: Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
9romise
left a comment
There was a problem hiding this comment.
Good job! I think we could also prompt users to visit https://jsr.io when a jsr:‑style specifier is detected.
|
@9romise wdyt?
|
| export function jsrPackageUrl(name: string, version: string): string { | ||
| const jsrVersionRange = version.replace(/^jsr:/, '') | ||
| const jsrVersion = extractVersion(jsrVersionRange) | ||
|
|
||
| return `https://jsr.io/${name}@${jsrVersion}` | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find the extractVersion function
rg -A 5 "function extractVersion|const extractVersion|export.*extractVersion" --type tsRepository: npmx-dev/vscode-npmx
Length of output: 674
🏁 Script executed:
# Locate the package.ts file mentioned in the comment
find . -name "package.ts" -type fRepository: npmx-dev/vscode-npmx
Length of output: 113
🏁 Script executed:
# Get the context around the jsrPackageUrl function
rg -B 5 -A 10 "jsrPackageUrl" --type tsRepository: npmx-dev/vscode-npmx
Length of output: 2596
🏁 Script executed:
# Look for test files related to extractVersion or jsrPackageUrl
find . -name "*.test.*" -o -name "*.spec.*" | head -20Repository: npmx-dev/vscode-npmx
Length of output: 1984
🏁 Script executed:
# Search for JSR specifier examples in the codebase
rg "jsr:" --type ts --type json -B 2 -A 2Repository: npmx-dev/vscode-npmx
Length of output: 757
🏁 Script executed:
# Check if there's any documentation or comments about JSR format
rg -i "jsr.*version|version.*jsr" --type ts -B 2 -A 2Repository: npmx-dev/vscode-npmx
Length of output: 1482
🌐 Web query:
JSR JavaScript Registry version specifier format semver ranges
💡 Result:
JSR specifier format
JSR module specifiers must be of the form: jsr:@<scope>/<name>@<version>/<path> (or with an optional extra slash after jsr:: jsr:/@<scope>/<name>@<version>/<path>). The /path part is optional if you’re importing the package entrypoint. [1]
Examples:
import { camelCase } from "jsr:@luca/cases@^1.0.1";[2]- Import map / install entries commonly look like
jsr:@std/path@^1.0.3. [3]
What <version> can be (SemVer ranges)
JSR resolves versions using Semantic Versioning and allows a semver range anywhere you can write a version (specifier, import maps, package.json dependencies). Tools then pick the latest version that satisfies all constraints. [2]
Common allowed forms include:
- Exact:
@1.2.3 - Major-only / minor-only partials:
@1or@1.0[2] - Caret / tilde:
@^1.0.1,@~1.2.0[2] - Comparators:
@>=1.0.0,@<2.0.0, etc. [4] - Hyphen ranges:
@1.2.3 - 2.3.4[4] - AND by whitespace:
@>=1.0.0 <2.0.0[4] - OR with
||:@<1.0.0 || >=2.0.0[4] - Wildcards / x-ranges:
@1.x,@1.*, etc. [4]
(That range syntax matches the semver range grammar used by Deno’s @std/semver implementation.) [4]
Sources: [1] JSR troubleshooting (invalid specifier format); [2] JSR “Using packages” docs; [3] Deno std docs showing JSR ranges in import maps; [4] @std/semver range grammar on JSR.
Minor: extractVersion handles only caret and tilde prefixes, not other semver range operators.
The extractVersion utility only strips ^ and ~ range prefixes. JSR specifiers can use other semver operators (e.g., jsr:>=0.189.1, jsr:<1.0.0, jsr:<1.0.0 || >=2.0.0), which would result in malformed URLs.
This is likely acceptable given that caret and tilde are the predominant range specifiers in practice, but worth noting for completeness.

Resolves #19.
Shows warning when package can't be found:
