Skip to content

Conversation

@9romise
Copy link
Member

@9romise 9romise commented Feb 2, 2026

Close #14

# Conflicts:
#	src/providers/completion-item/version.ts
@9romise 9romise marked this pull request as ready for review February 3, 2026 06:49
# Conflicts:
#	src/providers/diagnostics/rules/vulnerability.ts
#	src/providers/hover/npmx.ts
# Conflicts:
#	src/providers/diagnostics/rules/replacement.ts
@hyoban
Copy link
Contributor

hyoban commented Feb 4, 2026

Regarding performance issues, I was thinking we could implement dependency-based caching. If the dependencies haven't changed (for example, if you only add whitespace characters), we shouldn't request them again.

We can also report issues as soon as possible instead of waiting until everything has been checked.

async function collectDiagnostics(document: TextDocument, extractor: Extractor) {
diagnosticCollection.delete(document.uri)
const root = extractor.parse(document)
if (!root)
return
const dependencies = extractor.getDependenciesInfo(root)
const diagnostics: Diagnostic[] = []
await Promise.all(
dependencies.map(async (dep) => {
try {
const pkg = await getPackageInfo(dep.name)
if (!pkg)
return
for (const rule of enabledRules.value) {
const diagnostic = await rule(dep, pkg)
if (diagnostic) {
diagnostics.push({
source: displayName,
message: diagnostic.message,
severity: diagnostic.severity,
code: diagnostic.code,
range: extractor.getNodeRange(document, diagnostic.node),
})
}
}
} catch (err) {
logger.warn(`Failed to check ${dep.name}: ${err}`)
}
}),
)
if (diagnostics.length > 0)
logger.info(`${diagnostics.length} diagnostic collected in ${document.fileName}.`)
diagnosticCollection.set(document.uri, diagnostics)
}

@9romise
Copy link
Member Author

9romise commented Feb 4, 2026

Regarding performance issues, I was thinking we could implement dependency-based caching. If the dependencies haven't changed (for example, if you only add whitespace characters), we shouldn't request them again.

We do cache the result currently, see https://github.com/npmx-dev/vscode-npmx/blob/main/src/utils/memoize.ts#L18.

But I think we can add a pre-validation to ensure the package name is legal.

We can also report issues as soon as possible instead of waiting until everything has been checked.

I'll check it out. Thanks for your feedback!

@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The PR migrates npm metadata fetching to fast-npm-meta and updates package.json and tsdown.config.ts. src/utils/api/package.ts now exposes a new PackageInfo (including a versionToTag Map) and getPackageInfo returns Promise<PackageInfo | null>. Call sites were adjusted to read version metadata from versionsMeta. Diagnostic rule types were updated to use PackageInfo. Hover provider link construction now uses new link helpers and the NPMJS_COM constant. The ModuleReplacement re-export was removed.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description 'Close #14' is minimal but directly related to the changeset, which implements a migration to fast-npm-meta as evidenced by changes across multiple files.
Linked Issues check ✅ Passed The PR successfully migrates the project to use fast-npm-meta by replacing npm package fetching logic with fast-npm-meta integration, updating all dependent code paths, and adjusting build configuration.
Out of Scope Changes check ✅ Passed All changes are aligned with the migration objective. Updates to constants, links, diagnostics, providers, and configuration all support the fast-npm-meta migration without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fast-npm-meta

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

@9romise
Copy link
Member Author

9romise commented Feb 4, 2026

Regarding performance issues, I was thinking we could implement dependency-based caching. If the dependencies haven't changed (for example, if you only add whitespace characters), we shouldn't request them again.

Oh, I see, do you mean caching Diagnostics based on the dependency name?

@9romise 9romise merged commit 048eee7 into main Feb 4, 2026
6 checks passed
@9romise 9romise deleted the fast-npm-meta branch February 4, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to fast-npm-meta

3 participants