Skip to content

feat: add WASM label#2154

Open
gameroman wants to merge 14 commits intonpmx-dev:mainfrom
gameroman:analysis-wasm
Open

feat: add WASM label#2154
gameroman wants to merge 14 commits intonpmx-dev:mainfrom
gameroman:analysis-wasm

Conversation

@gameroman
Copy link
Contributor

🔗 Linked issue

Closes #2117

📚 Description

Adds a tag if a package is WASM only

@vercel
Copy link

vercel bot commented Mar 19, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 20, 2026 1:52am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 20, 2026 1:52am
npmx-lunaria Ignored Ignored Mar 20, 2026 1:52am

Request Review

@github-actions
Copy link

github-actions bot commented Mar 19, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
shared/utils/package-analysis.ts 0.00% 2 Missing and 1 partial ⚠️
app/components/Package/MetricsBadges.vue 93.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds WebAssembly support: introduces a new wasm ModuleFormat and updates detectModuleFormat to return wasm when a package main ends with .wasm; updates Package/MetricsBadges.vue to render a WASM badge when detected (adjusting ESM/CJS badge rendering and loading states); adds package.metrics.wasm to English locales and the i18n schema; adds a unit test for .wasm detection; updates CONTRIBUTING.md i18n command examples to prefix scripts with pnpm vp run.

Possibly related PRs

Suggested reviewers

  • danielroe
  • ghostdevv
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is related to the changeset, providing context about adding a WASM badge label.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #2117: detects WASM-only packages, adds WASM badge rendering logic, updates i18n translations, and includes unit tests.
Out of Scope Changes check ✅ Passed All changes are directly related to adding WASM label support; the CONTRIBUTING.md update reflects standard documentation maintenance and is minimal in scope.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Tip

CodeRabbit can use oxc to improve the quality of JavaScript and TypeScript code reviews.

Add a configuration file to your project to customize how CodeRabbit runs oxc.

Copy link
Contributor

@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: 3

🧹 Nitpick comments (2)
CONTRIBUTING.md (1)

463-466: Query: Are these documentation changes within scope?

These changes simplify the i18n commands table by removing several entries and shortening descriptions. Whilst this may improve readability, it seems unrelated to the PR's stated objective of adding a WASM label. Were these changes intentional cleanup work, or were they made accidentally?

If intentional, consider moving documentation-focused changes to a separate PR to maintain clear change history and make reviews more focused.

test/unit/shared/utils/package-analysis.spec.ts (1)

126-128: Add an exports-only WASM test case to lock expected behaviour.

The new test covers main, but not packages that declare only exports with a .wasm entrypoint.

🧪 Suggested additional test
   it('detects WASM from main field', () => {
     expect(detectModuleFormat({ main: 'main.wasm' })).toBe('wasm')
   })
+
+  it('detects WASM from exports-only entrypoint', () => {
+    expect(
+      detectModuleFormat({
+        exports: {
+          '.': './main.wasm',
+        },
+      }),
+    ).toBe('wasm')
+  })

As per coding guidelines: **/*.{test,spec}.{ts,tsx}: Write unit tests for core functionality using vitest.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 997eac39-0654-4a11-b8cb-a98fb06c3f32

📥 Commits

Reviewing files that changed from the base of the PR and between 230b7c7 and 50bc140.

📒 Files selected for processing (6)
  • CONTRIBUTING.md
  • app/components/Package/MetricsBadges.vue
  • i18n/locales/en.json
  • i18n/schema.json
  • shared/utils/package-analysis.ts
  • test/unit/shared/utils/package-analysis.spec.ts

@gameroman
Copy link
Contributor Author

@coderabbitai should I add an e2e test?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me check the existing e2e tests to give you a concrete recommendation.


🏁 Script executed:

#!/bin/bash
# List all e2e test files
fd -e ts -e tsx --full-path 'e2e' .

# Check for any existing badge or metrics-related e2e tests
rg -n "badge|metrics|esm|cjs|MetricsBadge" --type=ts -l

# Show one example e2e test for context
fd -e ts -e tsx --full-path 'e2e' . --exec head -60 {}

Length of output: 29914


@gameroman: It's not strictly necessary for this PR, but it depends on how far you want to go. Here's the breakdown:

Why you probably don't need one right now:

  • The core detection logic (detectModuleFormat'wasm') is already covered by the new unit test in test/unit/shared/utils/package-analysis.spec.ts.
  • Looking at the existing e2e suite, no e2e test currently covers the metrics badges UI (ESM / CJS / Types) in MetricsBadges.vue — so adding one exclusively for WASM would be inconsistent with the current testing strategy.
  • test/e2e/badge.spec.ts tests the SVG API badge endpoints, not the UI component.

Why you might want one anyway:

  • An e2e test would validate the full rendering pipeline — that isWasm correctly drives the conditional v-if/v-else in the template, the tooltip text renders, and the i18n key (package.metrics.wasm) resolves correctly.
  • It would catch regressions that a unit test won't (e.g. a broken analysis composable wiring in the component).

If you do add one, it would go in test/e2e/ using Playwright + nuxt/test-utils, and you'd need a new fixture for a known WASM-only package (like the example from issue #2117) in test/fixtures/. A minimal test might look like:

// test/e2e/metrics-badges.spec.ts
import { expect, test } from './test-utils'

test.describe('MetricsBadges – WASM', () => {
  test('/package/<wasm-pkg> → shows WASM badge', async ({ page, goto }) => {
    await goto('/package/<wasm-pkg>', { waitUntil: 'domcontentloaded' })

    // WASM badge should be visible
    await expect(page.locator('[data-testid="wasm-badge"]')).toBeVisible()

    // ESM / CJS badges should NOT be shown alongside WASM
    await expect(page.locator('[data-testid="esm-badge"]')).not.toBeVisible()
  })
})

(You'd need to add data-testid attributes to the badges in MetricsBadges.vue and create the fixture.)

Bottom line: skip it for now unless the team has a policy of e2e-testing new badge types. The unit test is the right place for the detection logic, and a component-level Nuxt test (test/nuxt/) would be a lighter-weight middle ground if you want UI rendering coverage without a full fixture.


🧠 Learnings used
Learnt from: CR
Repo: npmx-dev/npmx.dev PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-03T10:09:38.777Z
Learning: Applies to **/e2e/**/*.{test,spec}.{ts,tsx} : Write end-to-end tests using Playwright and `nuxt/test-utils`

Copy link
Contributor

@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.

🧹 Nitpick comments (1)
test/nuxt/components/Package/MetricsBadges.spec.ts (1)

18-32: Tighten the dual-format assertion set.

Consider also asserting that WASM is not rendered in this case, so the test verifies both presence and exclusion paths.

Suggested tweak
   const text = wrapper.text()
   expect(text).toContain('Types')
   expect(text).toContain('ESM')
   expect(text).toContain('CJS')
+  expect(text).not.toContain('WASM')

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d29b9cc-86a7-4471-b243-1e1aaa331054

📥 Commits

Reviewing files that changed from the base of the PR and between e7e433a and 6f43544.

📒 Files selected for processing (5)
  • test/nuxt/components/Package/LikeCard.spec.ts
  • test/nuxt/components/Package/MetricsBadges.spec.ts
  • test/nuxt/components/Package/Sidebar.spec.ts
  • test/nuxt/components/Package/Versions.spec.ts
  • test/nuxt/components/Package/WeeklyDownloadStats.spec.ts

Copy link
Contributor

@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

🧹 Nitpick comments (2)
test/nuxt/components/Package/MetricsBadges.spec.ts (2)

13-16: Consider adding mock cleanup between tests.

The mockUsePackageAnalysis mock is not being reset between tests, which could lead to test pollution if additional tests are added. Consider clearing the mock in the afterEach hook.

🧹 Suggested improvement for mock cleanup
-  afterEach(() => wrapper?.unmount())
+  afterEach(() => {
+    wrapper?.unmount()
+    vi.clearAllMocks()
+  })

18-46: Good test coverage for the new WASM feature.

The tests effectively validate both the existing badge rendering (Types, ESM, CJS) and the new WASM badge. The test structure is clear and follows Vitest best practices.

For more comprehensive coverage, you could optionally consider adding tests for:

  • Loading states (when status is 'pending' or 'error')
  • Other module formats ('esm', 'cjs', 'none')
  • The types property variations (e.g., kind: 'external', kind: 'none')

However, the current tests adequately cover the primary objective of this PR.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf8fca50-d32a-4911-9258-0abad7558174

📥 Commits

Reviewing files that changed from the base of the PR and between 6f43544 and 6c9ad6f.

📒 Files selected for processing (1)
  • test/nuxt/components/Package/MetricsBadges.spec.ts

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.

Wasm only label

2 participants