Refactored pack.js script to leverage pnpm utils - #29350
Conversation
WalkthroughThe PR adds pnpm packing hooks that remove development metadata and rewrite Ghost component dependencies for release tarballs. It replaces the archive packer with an ESM implementation that packs workspace components, generates standalone workspace metadata and a lockfile, validates the output, and creates the final archive. Asset minification now uses ESM imports and concurrent processing with aggregated failure handling. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
no ref - rewrite minify-assets to ESM to leverage top-level-await - rewrite pack.js to use `pnpm pack` exclusively for ghost + dependencies - add pnpmfile to standardize packaged pkg.json files
70a619a to
e5eb044
Compare
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run @tryghost/admin-x-settings:test:acceptance |
✅ Succeeded | 10m 9s | View ↗ |
nx run-many -t test:unit -p ghost,@tryghost/ada... |
✅ Succeeded | 9m 5s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 47s | View ↗ |
nx run ghost:test:integration |
✅ Succeeded | 2m 43s | View ↗ |
nx run ghost-monorepo:lint:boundaries |
✅ Succeeded | 19s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 3m 12s | View ↗ |
nx run-many -t lint -p ghost-monorepo,ghost,@tr... |
✅ Succeeded | 3m 48s | View ↗ |
nx run ghost-admin:test |
✅ Succeeded | 3m 26s | View ↗ |
Additional runs (11) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-15 14:16:52 UTC
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/scripts/minify-assets.mjs (1)
95-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer asynchronous
fsmethods and add missing semicolon.Since this script is now fully asynchronous, consider using
fs.promises.mkdirto avoid blocking the event loop with synchronous I/O operations (fs.existsSyncandfs.mkdirSync). Withrecursive: true, it automatically succeeds if the directory already exists.Additionally, there is a missing semicolon at the end of the
mapcallback on line 120.♻️ Proposed refactor
- // Ensure the destination directory exists - const destDir = path.dirname(destPath); - if (!fs.existsSync(destDir)) { - fs.mkdirSync(destDir, {recursive: true}); - } + // Ensure the destination directory exists + const destDir = path.dirname(destPath); + await fs.promises.mkdir(destDir, {recursive: true}); // Create build configuration by merging default options with file-specific options const buildConfig = { entryPoints: [srcPath], outfile: destPath, minify: true, platform: 'browser', // Apply file-specific options, with defaults ...file.options }; await esbuild.build(buildConfig); // Show bundling status in output const bundleStatus = buildConfig.bundle ? 'bundled + minified' : 'minified'; logging.debug(`✓ ${file.src} → ${file.dest} (${bundleStatus})`); } catch (error) { console.error(`✗ Error processing ${file.src}:`, error); throw error; } -}) +});🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ghost/core/scripts/minify-assets.mjs` around lines 95 - 120, Update the destination-directory setup in the asset-processing callback to use asynchronous fs.promises.mkdir with recursive mode, replacing the synchronous existsSync/mkdirSync checks. Add the missing semicolon after the map callback expression.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ghost/core/scripts/minify-assets.mjs`:
- Around line 95-120: Update the destination-directory setup in the
asset-processing callback to use asynchronous fs.promises.mkdir with recursive
mode, replacing the synchronous existsSync/mkdirSync checks. Add the missing
semicolon after the map callback expression.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ec05d810-51f2-49d1-83d7-f2b68ee013b9
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.pnpmfile.mjsghost/core/package.jsonghost/core/scripts/minify-assets.mjsghost/core/scripts/pack.jsghost/core/scripts/pack.mjs
💤 Files with no reviewable changes (1)
- ghost/core/scripts/pack.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #29350 +/- ##
=======================================
Coverage 74.03% 74.03%
=======================================
Files 1578 1578
Lines 137430 137430
Branches 16647 16652 +5
=======================================
+ Hits 101743 101746 +3
+ Misses 34642 34637 -5
- Partials 1045 1047 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

no ref
pnpm packexclusively for ghost + dependencies