Skip to content

fix(scripts): normalize npm pack json output to support npm v12+ - #253

Merged
avivkeller merged 1 commit into
webpack:mainfrom
moshams272:fix/npm-pack-json-output
Aug 21, 2026
Merged

fix(scripts): normalize npm pack json output to support npm v12+#253
avivkeller merged 1 commit into
webpack:mainfrom
moshams272:fix/npm-pack-json-output

Conversation

@moshams272

@moshams272 moshams272 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

This PR normalizes npm pack json output. In newer versions of npm v12+, the output structure of the npm pack --json command changed from an array of objects to a flat object. This broke our JSON parser which strictly expected an array via destructuring. So this PR lets us support both ways.

Summary by CodeRabbit

  • Bug Fixes
    • Improved package preparation compatibility by supporting both array and single-object results from package metadata commands.
    • Preserved existing package extraction and cleanup behavior.

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
webpack-doc-kit Ready Ready Preview Aug 20, 2026 7:33pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Updated fetchWebpack to parse the npm pack --json result once. The code now extracts filename from either the first array element or a direct object. Existing extraction and cleanup behavior remains unchanged.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the npm pack JSON compatibility fix for npm v12 and newer.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/prepare/index.mjs (1)

17-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for both npm pack --json shapes.

The normalization handles the legacy array and the npm v12 object form. The provided cohort includes no test for either branch. Add focused coverage with mocked execFileSync output for both shapes, and verify the resulting archive path before extraction. npm’s official changelog records this output-format change, so keep both fixtures to prevent parser regressions. (github.com)


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e0d4f4a-0ac4-43c8-abf3-5552ebe7dc1b

📥 Commits

Reviewing files that changed from the base of the PR and between cf3555c and b60d3c4.

📒 Files selected for processing (1)
  • scripts/prepare/index.mjs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • webpack/webpack (auto-detected)

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@avivkeller
avivkeller merged commit 828ce09 into webpack:main Aug 21, 2026
14 checks passed
@moshams272
moshams272 deleted the fix/npm-pack-json-output branch August 21, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants