perf: lazily load README when embedding publish manifest#12278
Conversation
Code Review by Qodo
1. Removed readmeFile option
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughREADME embedding is refactored so ChangesREADME Embedding Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
There was a problem hiding this comment.
Pull request overview
This PR refactors README embedding during publish-manifest creation to reduce unnecessary filesystem reads by only loading README content when needed (and moving the README-loading logic into @pnpm/releasing.exportable-manifest).
Changes:
- Replace
readmeFileoption withembedReadme+ project directory based README loading increateExportableManifest. - Remove the local README-reading helper from the pack command and delegate to
createExportableManifest. - Update exportable-manifest tests to exercise README embedding via a temporary project directory/README file.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| releasing/exportable-manifest/src/index.ts | Adds README discovery/reading and embeds it into the exportable manifest when configured. |
| releasing/commands/src/publish/pack.ts | Removes in-file README reading and passes embed configuration through to exportable-manifest. |
| releasing/exportable-manifest/test/index.test.ts | Updates tests to use temp project README files and the new embed options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@releasing/exportable-manifest/src/index.ts`:
- Around line 39-40: The README discovery should match the exact filename and
ensure the entry is a file; replace the loose predicate in files.find with a
check like path.basename(name).toLowerCase() === 'readme.md' (referencing
readmePath and files.find) and before reading (readmeFile creation using
fs.promises.readFile and path.join) verify the entry is a file via
fs.promises.lstat(path.join(projectDir, readmePath)).then(stat => stat.isFile())
— only call fs.promises.readFile when isFile() is true, otherwise treat
readmeFile as undefined.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d2dda2ae-5283-493c-a725-1bea6f6224ce
📒 Files selected for processing (3)
releasing/commands/src/publish/pack.tsreleasing/exportable-manifest/src/index.tsreleasing/exportable-manifest/test/index.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: copilot-pull-request-reviewer
- GitHub Check: Analyze (javascript)
- GitHub Check: Compile & Lint
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: Use Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (relying on hoisting), limit functions to no more than two or three arguments, and use a single options object for functions needing more parameters
Follow import order: standard libraries first, then external dependencies (sorted alphabetically), then relative imports
Do not write comments that restate what the code already says; rename variables, split helpers, or move checks to more obvious places instead
Do not repeat documentation at call sites that already lives on the callee; update the JSDoc once and let every call site benefit
Use JSDoc for the function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the function body
Do not record past implementation shape, refactor history, or removed code in comments; use git log and git blame for that information instead
Write comments only when the reason for code is non-obvious, a hidden invariant exists, a workaround for a known bug is needed, or an exception to surrounding pattern is deliberate
Files:
releasing/exportable-manifest/test/index.test.tsreleasing/exportable-manifest/src/index.tsreleasing/commands/src/publish/pack.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Do not use
instanceof Errorfor checking if a caught error is an Error object in Jest tests; useutil.types.isNativeError()instead to work across realms
Files:
releasing/exportable-manifest/test/index.test.ts
🧠 Learnings (3)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.
Applied to files:
releasing/exportable-manifest/test/index.test.tsreleasing/exportable-manifest/src/index.tsreleasing/commands/src/publish/pack.ts
📚 Learning: 2026-06-05T13:47:05.929Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/test/install/frozenStore.ts:2-17
Timestamp: 2026-06-05T13:47:05.929Z
Learning: In the pnpm/pnpm repository, the shared Jest preset keeps `injectGlobals` at its default (`true`), so `test` and `expect` are available as Jest globals. Therefore, reviewers should not flag (or treat as TypeScript/compilation errors) missing `import { test, expect } from 'jest/globals'` when a test file uses `test`/`expect` without importing them. Importing from `jest/globals` may still be used for consistency with sibling files, but it is not required for execution in this repo unless a Jest preset is explicitly configured with `injectGlobals: false`.
Applied to files:
releasing/exportable-manifest/test/index.test.ts
📚 Learning: 2026-06-05T13:47:26.046Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/src/install/index.ts:2337-2343
Timestamp: 2026-06-05T13:47:26.046Z
Learning: In the pnpm/pnpm codebase, `PnpmError` automatically prefixes `err.code` with `ERR_PNPM_` when you pass a code that does not already start with `ERR_PNPM_` (it normalizes `this.code` via `code.startsWith('ERR_PNPM_') ? code : `ERR_PNPM_${code}``). Therefore, during code review you should NOT flag `new PnpmError(...)` call sites for passing a bare error code (e.g., `new PnpmError('FROZEN_STORE_INCOMPATIBLE_WITH_PNPR', ...)`); the resulting `err.code` will still be `ERR_PNPM_FROZEN_STORE_INCOMPATIBLE_WITH_PNPR`.
Applied to files:
releasing/exportable-manifest/test/index.test.tsreleasing/exportable-manifest/src/index.tsreleasing/commands/src/publish/pack.ts
🔇 Additional comments (2)
releasing/commands/src/publish/pack.ts (1)
403-404: LGTM!releasing/exportable-manifest/test/index.test.ts (1)
2-3: LGTM!Also applies to: 124-135, 148-160, 164-172
|
Code review by qodo was updated up to the latest commit f444962 |
f444962 to
7817f29
Compare
|
Code review by qodo was updated up to the latest commit 7817f29 |
|
Code review by qodo was updated up to the latest commit f7925b7 |
|
Code review by qodo was updated up to the latest commit 9aad19e |
PR Summary by Qodo
Perf: lazily read README only when embedding publish manifest needs it
✨ Enhancement🧪 Tests🕐 10-20 MinutesWalkthroughs
User Description
Even with the embedReadme configuration enabled, unnecessary file read operations are reduced.
AI Description
Diagram
graph TD Pack["publish/pack.ts"] --> Exportable["createExportableManifest"] --> Gate{"Embed README needed?"} Gate -->|"no"| Out["Exported manifest"] Gate -->|"yes"| Readme["readReadmeFile"] --> Disk["README.md (projectDir)"] --> OutHigh-Level Assessment
The following are alternative approaches to this PR:
1. Keep caller-side reading but make it conditional on manifest contents
2. Pass a lazy loader callback (e.g. getReadme(): Promise)
Recommendation: The chosen approach (move README reading into createExportableManifest and gate it with
publishManifest.readme ??=) is the simplest and most robust: it performs I/O only when the manifest actually needs a readme and keeps the decision co-located with publish-manifest construction. Ensure all callers that setembedReadmealso provideprojectDir(or consider defaultingprojectDirto thedirparameter internally if they’re intended to match).File Changes
Enhancement (2)
Tests (1)
Summary by CodeRabbit
embedReadmeoption, and when enabled it is discovered fromREADME.mdin the provided project directory.readmevalue.README.md, enableembedReadme, and verify the embeddedreadmeis present in the resulting manifest.