Skip to content

fix(build): ignore MODULE_LEVEL_DIRECTIVE warnings - #4696

Merged
pi0 merged 1 commit into
nitrojs:mainfrom
kaanisthatyou:fix/ignore-module-level-directive
Oct 3, 2026
Merged

pi0 merged 1 commit into
nitrojs:mainfrom
kaanisthatyou:fix/ignore-module-level-directive

Conversation

@kaanisthatyou

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Resolves #4695

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

A dependency whose modules start with "use client" printed one MODULE_LEVEL_DIRECTIVE warning per module in the server build. The directive only matters to React Server Components bundlers, so this adds the code to ignoreWarningCodes, which the rollup, rolldown and vite builders already share. It also removes a leftover console.log(warning.code) from the rolldown builder's onwarn.

The new unit test calls onwarn of all four builder configs (rollup, rolldown, vite with rollup, vite with rolldown): the "use client" warning is dropped and other warnings are still forwarded. It fails on main for all four. With the issue's repro, the published 3.0.260903-beta prints 15 warnings and this branch prints none; the built server still responds.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

A dependency whose modules start with "use client" printed one
MODULE_LEVEL_DIRECTIVE warning per module in the server build. The
directive only matters to React Server Components bundlers, so add the
code to the warnings the rollup, rolldown and vite builders already
ignore.

Also drop a leftover console.log of each warning code in the rolldown
builder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaanisthatyou
kaanisthatyou requested a review from pi0 as a code owner October 2, 2026 15:36
@vercel

vercel Bot commented Oct 2, 2026

Copy link
Copy Markdown

@kaanisthatyou is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ef9cfc13-5d2f-4da3-815a-e1304139ab6b

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf83c8 and dbe7139.

📒 Files selected for processing (3)
  • src/build/config.ts
  • src/build/rolldown/config.ts
  • test/unit/build-warnings.test.ts
💤 Files with no reviewable changes (1)
  • src/build/rolldown/config.ts

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


📝 Walkthrough

Walkthrough

The build warning handlers now suppress MODULE_LEVEL_DIRECTIVE warnings. The Rolldown configuration no longer logs warning codes. Tests cover suppression and forwarding across Rollup, Rolldown, and Vite configurations.

Changes

Build warning handling

Layer / File(s) Summary
Warning filtering and forwarding
src/build/config.ts, src/build/rolldown/config.ts, test/unit/build-warnings.test.ts
The shared warning configuration ignores MODULE_LEVEL_DIRECTIVE. The Rolldown configuration no longer logs warning codes. Tests check that directive warnings are suppressed and unresolved import warnings reach the callback across the four configurations.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to dbe71

The change addresses the noisy build warnings without an identified merge-blocking issue.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the Conventional Commits format with the fix type and build scope. It accurately describes the warning-filtering change.
Description check ✅ Passed The description directly explains the warning suppression, Rolldown cleanup, affected builders, tests, and issue context.
Linked Issues check ✅ Passed Issue [#4695] requires Nitro to suppress noisy MODULE_LEVEL_DIRECTIVE warnings through the shared warning handling while forwarding other warning codes. baseBuildConfig adds `MODULE_LEVEL_DIRECTIV…
Out of Scope Changes check ✅ Passed The changes stay within the linked issue scope. The new shared warning filter and its four-builder tests implement and verify the requested behavior. Removing the leftover warning-code console.log f…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@pi0
pi0 merged commit ba9de82 into nitrojs:main Oct 3, 2026
10 of 11 checks passed
viclafouch added a commit to viclafouch/petit-meme that referenced this pull request Oct 5, 2026
…nings

nitro 3.0.260903-beta. It now builds the server with the project's Vite
and rolldown 1.2.12 instead of its own 1.1.1. The Vercel output is the
same: identical config.json, a 36 MB function, takumi's native addon
traced.

rolldown 1.2.9 warns about every "use client" directive it meets, 152 of
them in the server build, where the directive means nothing. Nitro
ignores the code upstream (nitrojs/nitro#4696, not yet released); until
then the Nitro rolldown config drops that one log and hands every other
to Nitro's own filter.
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.

Server build warns MODULE_LEVEL_DIRECTIVE for every "use client" dependency module

2 participants