Skip to content

Refactored pack.js script to leverage pnpm utils - #29350

Merged
acburdine merged 1 commit into
mainfrom
feat/ghost-build
Jul 15, 2026
Merged

Refactored pack.js script to leverage pnpm utils#29350
acburdine merged 1 commit into
mainfrom
feat/ghost-build

Conversation

@acburdine

Copy link
Copy Markdown
Member

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

@acburdine
acburdine requested a review from 9larsons July 15, 2026 14:03
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The 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: 9larsons, evanhahn

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the packaging refactor around pack.js and pnpm-based utilities.
Description check ✅ Passed The description clearly matches the changes to minify-assets, pack.js, and the new pnpmfile.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ghost-build

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.

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
@nx-cloud

nx-cloud Bot commented Jul 15, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit e5eb044

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ghost/core/scripts/minify-assets.mjs (1)

95-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer asynchronous fs methods and add missing semicolon.

Since this script is now fully asynchronous, consider using fs.promises.mkdir to avoid blocking the event loop with synchronous I/O operations (fs.existsSync and fs.mkdirSync). With recursive: true, it automatically succeeds if the directory already exists.

Additionally, there is a missing semicolon at the end of the map callback 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a08e5d and e5eb044.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .pnpmfile.mjs
  • ghost/core/package.json
  • ghost/core/scripts/minify-assets.mjs
  • ghost/core/scripts/pack.js
  • ghost/core/scripts/pack.mjs
💤 Files with no reviewable changes (1)
  • ghost/core/scripts/pack.js

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.03%. Comparing base (5a08e5d) to head (e5eb044).

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     
Flag Coverage Δ
admin-tests 55.32% <ø> (-0.03%) ⬇️
e2e-tests 76.12% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@acburdine
acburdine merged commit 57699d7 into main Jul 15, 2026
49 checks passed
@acburdine
acburdine deleted the feat/ghost-build branch July 15, 2026 14:32
@acburdine
acburdine restored the feat/ghost-build branch July 15, 2026 16:34
@acburdine
acburdine deleted the feat/ghost-build branch July 15, 2026 16:34
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.

1 participant