Skip to content

Fix npm scoped package handling in libs command#593

Merged
tengstrand merged 3 commits intopolyfy:masterfrom
jxonas:fix/npm-scoped-package-names
Dec 4, 2025
Merged

Fix npm scoped package handling in libs command#593
tengstrand merged 3 commits intopolyfy:masterfrom
jxonas:fix/npm-scoped-package-names

Conversation

@jxonas
Copy link
Contributor

@jxonas jxonas commented Nov 26, 2025

Summary

  • Fix scoped npm packages (e.g., @mantine/core) showing incorrect latest versions in poly libs :outdated
  • Support npm/yarn workspaces when calculating package sizes

Problem

When using poly libs :outdated, npm packages with scoped names showed incorrect "latest" versions. For example:

library version latest
charts ^8.3.8 0.0.3
core ^8.3.8 1.0.113

The scope prefix was being stripped before querying the npm registry, causing lookups for unrelated packages (core instead of @mantine/core).

Additionally, package size lookups failed for workspaces where dependencies are nested under the workspace package directory.

Root Cause

In Clojure, keywords containing / are interpreted as namespaced keywords. When @mantine/core from package.json becomes :@mantine/core:

  • (namespace :@mantine/core)"@mantine"
  • (name :@mantine/core)"core"

Using clojure.core/name only returned the local name, dropping the scope.

Solution

  1. Added keyword->full-name helper that preserves the namespace for scoped packages
  2. Updated npm registry queries to use full package names
  3. Added fallback logic for npm/yarn workspaces that checks both:
    • Nested: node_modules/@poly/mantine/node_modules/@mantine/core
    • Hoisted: node_modules/@mantine/core

Files Changed

  • components/antq/src/polylith/clj/core/antq/npm.clj
  • components/lib/src/polylith/clj/core/lib/size_npm.clj
  • components/lib/src/polylith/clj/core/lib/core.clj

Fixes polyfy#592

Scoped npm packages (e.g., @mantine/core) were incorrectly parsed
because Clojure's `name` function only returns the local part of
namespaced keywords, stripping the scope prefix.

Added keyword->full-name helper to preserve the full package name
in both npm.clj (registry queries) and size_npm.clj (size lookups).
Check both nested (node_modules/@poly/pkg/node_modules/@lib/name) and
hoisted (node_modules/@lib/name) paths when calculating npm package
sizes, since workspace dependencies may be installed in either location.
Copy link
Collaborator

@tengstrand tengstrand left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

@tengstrand tengstrand merged commit ed56141 into polyfy:master Dec 4, 2025
3 checks passed
tengstrand added a commit that referenced this pull request Dec 4, 2025
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.

2 participants