Repository navigation
feat: add fullTraceInclude option - #4
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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 unit tests (beta)
📝 Coding Plan
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 |
pi0
left a comment
There was a problem hiding this comment.
Thanks for PR ❤️ I have applied some changes.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/trace.ts`:
- Around line 101-107: The current glob call inside the opts.fullTraceInclude
branch uses glob("**/*") which omits dot-prefixed files by default; update the
call in the block that references opts.fullTraceInclude / tracedFile.pkgPath /
tracedPackageVersion.files to pass the option { dot: true } (alongside the
existing cwd and ignore) so hidden files and directories are included in
allFiles before pushing into tracedPackageVersion.files.
In `@test/trace.test.ts`:
- Line 6: The test in trace.test.ts reuses the outDir (dist/trace) so stale
files can make assertions pass; before exercising the code that generates
artifacts (the section around the assertions at lines 43-46), wipe or recreate
the outDir: use Node fs (e.g., fs.rm with { recursive: true, force: true } and
then fs.mkdir) to remove dist/trace and recreate it, then run the build/trace
generation that uses fullTraceInclude and perform the assertions — ensure you
reference and clear the exact outDir used by the test (dist/trace) so README.md
cannot persist across runs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c8c1b8b4-aacf-4b47-82ec-8eac932097a5
⛔ Files ignored due to path filters (2)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamltest/fixture/node_modules/@fixture/nitro-utils/README.mdis excluded by!**/node_modules/**
📒 Files selected for processing (4)
package.jsonsrc/trace.tssrc/types.tstest/trace.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/trace.ts (1)
104-107:⚠️ Potential issue | 🟠 Major
fullTraceIncludeskips dotfiles by default.The
glob("**/*")call doesn't include thedot: trueoption. Node.jsfs.promises.globdefaults todot: false, so hidden files/directories (e.g.,.bin, config files) won't be copied. This could cause incomplete package copying for packages that rely on dotfiles at runtime.🐛 Proposed fix
for await (const file of fsp.glob("**/*", { cwd: tracedFile.pkgPath, + dot: true, exclude: (name) => name === "node_modules", })) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/trace.ts` around lines 104 - 107, The glob call inside the for-await loop over fsp.glob in trace.ts is missing the dot: true option so hidden files are skipped; update the fsp.glob invocation (the one iterating with for await (const file of fsp.glob(...))) to include dot: true in its options (preserving cwd: tracedFile.pkgPath and the exclude predicate) so dotfiles and dotdirs (e.g., .bin, config files) are included when copying the package.
🧹 Nitpick comments (2)
src/trace.ts (1)
99-115: Potential duplicate files intracedPackageVersion.files.When
fullTraceIncludeis active, glob adds all files at lines 108-111, but line 115 still unconditionally addstracedFile.path. If that file was already found by glob, it creates a duplicate entry, causing the same file to be copied twice duringwritePackage.♻️ One approach: use a Set to deduplicate
tracedPackageVersion = { path: tracedFile.pkgPath, - files: [], + files: [] as string[], pkgJSON, }; tracedPackage.versions[pkgJSON.version || "0.0.0"] = tracedPackageVersion; if (opts.fullTraceInclude?.includes(pkgName)) { // ... glob logic ... } } - tracedPackageVersion.files.push(tracedFile.path); + if (!tracedPackageVersion.files.includes(tracedFile.path)) { + tracedPackageVersion.files.push(tracedFile.path); + }Alternatively, convert
filesto aSet<string>and spread to array when needed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/trace.ts` around lines 99 - 115, tracedPackageVersion.files can receive duplicates because when opts.fullTraceInclude includes pkgName you add files from fsp.glob and then unconditionally push tracedFile.path; update the logic in the block handling fullTraceInclude (referencing opts.fullTraceInclude, fsp.glob, tracedPackageVersion.files, and tracedFile.path) to avoid duplicates — either change files to a Set<string> and add entries via set.add(...) (convert back to array where writePackage consumes it) or check tracedPackageVersion.files.includes(tracedFile.path) before pushing so the same path is not appended twice.src/plugin.ts (1)
137-144: Silent failure whenfullTraceIncludepackage cannot be resolved.If a package name in
fullTraceIncludecannot be resolved (e.g., typo, not installed), it's silently skipped. The user won't know their configuration is ineffective until they notice missing files at runtime.Consider logging a warning for unresolved packages:
♻️ Proposed enhancement
if (traceOpts?.fullTraceInclude) { for (const pkg of traceOpts.fullTraceInclude) { const resolved = tryResolve(pkg, undefined); if (resolved) { tracedPaths.add(resolved); + } else { + console.warn(`[${PLUGIN_NAME}] Could not resolve fullTraceInclude package: ${pkg}`); } } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/plugin.ts` around lines 137 - 144, Looping over traceOpts.fullTraceInclude silently skips packages that fail to resolve; update the loop that calls tryResolve(pkg, undefined) to log a warning when tryResolve returns falsy so users know a package name failed to resolve. Specifically, in the block handling traceOpts?.fullTraceInclude, add a processLogger.warn (or the existing logger) referencing the package name and that tryResolve(pkg) returned undefined, while keeping the current behavior of adding resolved paths to tracedPaths; use traceOpts.fullTraceInclude, tryResolve, and tracedPaths to locate the code to modify.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Around line 65-71: The README example incorrectly calls rollupNodeFileTrace
while the plugin is exported as externals; update the example to reference the
exported symbol externals (or change the export to rollupNodeFileTrace if that
name is preferred) so the usage matches the actual export, ensuring consistency
between the example and the exported plugin name (refer to externals and
rollupNodeFileTrace to locate the mismatch).
---
Duplicate comments:
In `@src/trace.ts`:
- Around line 104-107: The glob call inside the for-await loop over fsp.glob in
trace.ts is missing the dot: true option so hidden files are skipped; update the
fsp.glob invocation (the one iterating with for await (const file of
fsp.glob(...))) to include dot: true in its options (preserving cwd:
tracedFile.pkgPath and the exclude predicate) so dotfiles and dotdirs (e.g.,
.bin, config files) are included when copying the package.
---
Nitpick comments:
In `@src/plugin.ts`:
- Around line 137-144: Looping over traceOpts.fullTraceInclude silently skips
packages that fail to resolve; update the loop that calls tryResolve(pkg,
undefined) to log a warning when tryResolve returns falsy so users know a
package name failed to resolve. Specifically, in the block handling
traceOpts?.fullTraceInclude, add a processLogger.warn (or the existing logger)
referencing the package name and that tryResolve(pkg) returned undefined, while
keeping the current behavior of adding resolved paths to tracedPaths; use
traceOpts.fullTraceInclude, tryResolve, and tracedPaths to locate the code to
modify.
In `@src/trace.ts`:
- Around line 99-115: tracedPackageVersion.files can receive duplicates because
when opts.fullTraceInclude includes pkgName you add files from fsp.glob and then
unconditionally push tracedFile.path; update the logic in the block handling
fullTraceInclude (referencing opts.fullTraceInclude, fsp.glob,
tracedPackageVersion.files, and tracedFile.path) to avoid duplicates — either
change files to a Set<string> and add entries via set.add(...) (convert back to
array where writePackage consumes it) or check
tracedPackageVersion.files.includes(tracedFile.path) before pushing so the same
path is not appended twice.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 294a8264-1e08-4d41-8f8a-69a3cb6951c6
📒 Files selected for processing (5)
README.mdsrc/plugin.tssrc/trace.tssrc/types.tstest/trace.test.ts
✅ Files skipped from review due to trivial changes (2)
- src/types.ts
- test/trace.test.ts
| ```js | ||
| rollupNodeFileTrace({ | ||
| trace: { | ||
| fullTraceInclude: ["some-package", "@scope/another-package"], | ||
| }, | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
Inconsistent function name in example.
The example uses rollupNodeFileTrace but the plugin is exported as externals (as shown in line 41). This will confuse users trying to use the feature.
📝 Suggested fix
-rollupNodeFileTrace({
+externals({
trace: {
fullTraceInclude: ["some-package", "@scope/another-package"],
},
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ```js | |
| rollupNodeFileTrace({ | |
| trace: { | |
| fullTraceInclude: ["some-package", "@scope/another-package"], | |
| }, | |
| }); | |
| ``` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 65 - 71, The README example incorrectly calls
rollupNodeFileTrace while the plugin is exported as externals; update the
example to reference the exported symbol externals (or change the export to
rollupNodeFileTrace if that name is preferred) so the usage matches the actual
export, ensuring consistency between the example and the exported plugin name
(refer to externals and rollupNodeFileTrace to locate the mismatch).
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Resolves nitrojs/nitro#1988
Summary
Adds a
fullTraceIncludeoption totraceNodeModulesthat includes all files in traced packages (not just the ones referenced by nft). Uses Node.js built-infs.promises.glob(requires Node >= 22).Changes
fullTraceIncludeoption toExternalsTraceOptionsnode_modules) and include them in the outputfs.promises.globis unavailable (Node < 22)Summary by CodeRabbit
Release Notes
New Features
fullTraceIncludeconfiguration option to explicitly specify package names whose files should be included in traces (requires Node.js 22.0.0+).Documentation
fullTraceIncludeoption.Tests
fullTraceIncludetracing capability.Improvements