Skip to content

Conversation

@OrbisK
Copy link
Contributor

@OrbisK OrbisK commented Feb 1, 2026

I think it is not an easy change to refactor all npm requests to useNpmRegistry (yet). As a first step, we could migrate all npm requests to $npmRegistry and $npmApi. Wdyt?

@vercel
Copy link

vercel bot commented Feb 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 3, 2026 11:37am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 3, 2026 11:37am
npmx-lunaria Ignored Ignored Feb 3, 2026 11:37am

Request Review

…ests

# Conflicts:
#	app/composables/useNpmRegistry.ts
#	app/utils/package-name.ts
@OrbisK OrbisK changed the title wip: proof of concept unifying all registry requests feat: unifying npm registry requests with caching Feb 1, 2026
@danielroe
Copy link
Member

this looks good!

would you investigate why the browser tests might be failing?

@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 1, 2026

this looks good!

would you investigate why the browser tests might be failing?

Working on it. Maybe you know what the issue is. e.g. the org page is broken.

https://npmxdev-git-fork-orbisk-feat-concept-npm-requests-poetry.vercel.app/@nuxt

image

Here: https://github.com/npmx-dev/npmx.dev/pull/641/changes#diff-93fe589cec6bc2b865b353a91ba90b4407706ff4baf16189a4c2c538351aa26aR523

@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 1, 2026

I think the problem is that cachedFetch from the plugin uses the server side fetch on the client 🤷🏽‍♂️

I think I have a fix.

@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 1, 2026

I am super confused. Are $npmRegistry request meant to run client side? Because there are cors issues when requesting the orgs

@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 1, 2026

Okay. The request returns the data and 200 but cors is still blocking it 🤔

@danielroe
Copy link
Member

danielroe commented Feb 1, 2026

$npmRegistry should be idempotent, yes. (it should be safe to call in either case)

if there's stale data (or missing data) from the server, then it will refetch on the client

@danielroe danielroe self-requested a review February 1, 2026 17:24
@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 1, 2026

Progress: I have fixed it locally. But i am not sure how...

Comment on lines 33 to 34
const { $npmApi } = useNuxtApp()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danielroe this line seems to be the problem.

replacing it by a simple mock "fixes" the issue. Any ideas 😅

 const $npmApi = ()=>{
  return Promise.resolve({data: null,})
 }

@codecov
Copy link

codecov bot commented Feb 3, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This pull request replaces direct NPM registry/API usage with Nuxt-injected runtime helpers ($npmRegistry, $npmApi) wired by a new plugin. Multiple npm-related composables and utilities were updated to call the injected helpers instead of hard-coded constants or useCachedFetch directly. useCachedFetch was modified to merge default fetch options using defu (new dependency). NPM constants were consolidated into shared constants, tests updated to expect relative API paths, and a vitest browser headless flag was made explicit.

Possibly related PRs

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description directly relates to the changeset, describing the migration of npm requests to $npmRegistry and $npmApi.

✏️ 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

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

@43081j
Copy link
Collaborator

43081j commented Feb 3, 2026

caught it up from main for you @OrbisK (lots of conflicts)

code has moved around a fair bit so can you have a read through again to be sure its all good?

@OrbisK
Copy link
Contributor Author

OrbisK commented Feb 3, 2026

caught it up from main for you @OrbisK (lots of conflicts)

code has moved around a fair bit so can you have a read through again to be sure its all good?

looks good. 👍🏽 Not sure how to fix the Nuxt instance issue though. I think this might be a Nuxt bug.

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.

3 participants