fix(vite): pre-bundle deps of layers installed in `node_modules` by danielroe · Pull Request #36208 · nuxt/nuxt · GitHub
Skip to content

fix(vite): pre-bundle deps of layers installed in node_modules - #36208

Merged
danielroe merged 2 commits into
mainfrom
fix/pre-bundle-layers
Sep 26, 2026
Merged

danielroe merged 2 commits into
mainfrom
fix/pre-bundle-layers

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #36135

📚 Description

this cleans up some dead code that wasn't running, and improves how we optimise layer dependencies.

  1. we explicitly scan layer entries entries to make things just work out of the box. the cost here is ~200ms per 300 scanned files in layers (in my measurements)...
  2. ... and where users have provided optimizeDeps which are not installed in the user directory, we make these resolvable under pnpm.

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Aug 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

@danielroe
danielroe force-pushed the fix/pre-bundle-layers branch from 4ff88ea to 0594f96 Compare August 29, 2026 08:05
@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a97229d3-80f8-4561-907a-b42a39b2d257

📥 Commits

Reviewing files that changed from the base of the PR and between 0594f96 and 3e3f006.

📒 Files selected for processing (5)
  • packages/vite/src/plugins/layer-dep-optimize.ts
  • packages/vite/src/plugins/optimize-deps.ts
  • packages/vite/src/utils/optimize-deps.ts
  • packages/vite/src/vite.ts
  • packages/vite/test/optimize-deps.test.ts
💤 Files with no reviewable changes (1)
  • packages/vite/src/plugins/layer-dep-optimize.ts

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


Walkthrough

Vite dependency optimisation now scans application files from installed Nuxt layers and registered module files. Client optimizeDeps.include entries can resolve from an installed layer and are rewritten to Vite nested dependency syntax. The new OptimizeDepsPlugin applies these settings during client environment configuration and records rewritten user entries. Tests cover scan entries, dependency resolution, environment handling, and pre-bundling behaviour.

Merge Risk: ⚪ Minimal · up to 3e3f0

This PR expands client dependency pre-bundling to dependencies provided by installed layers without changing server-side runtime behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 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 clearly describes the main change: pre-bundling dependencies from Nuxt layers installed in node_modules.
Description check ✅ Passed The description directly explains the layer dependency optimisation changes and the pnpm resolution behaviour.
Linked Issues check ✅ Passed The changes address issue #36135 by scanning installed layer entries, resolving pnpm-only optimiseDeps.include entries, and pre-bundling dependencies reached through layer plugins and layouts. The tes…
Out of Scope Changes check ✅ Passed The changes remain within scope. They update the Vite optimisation plugin, add supporting resolution utilities, integrate the plugin, and add focused tests.
Full details: Linked Issues check

Explanation

The changes address issue #36135 by scanning installed layer entries, resolving pnpm-only optimiseDeps.include entries, and pre-bundling dependencies reached through layer plugins and layouts. The tests cover these behaviours.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pre-bundle-layers

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.

@codspeed

codspeed Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

@danielroe
danielroe force-pushed the fix/pre-bundle-layers branch from 0594f96 to 3e3f006 Compare August 29, 2026 18:28
@danielroe
danielroe added this pull request to the merge queue Sep 26, 2026
Merged via the queue into main with commit 86cbb18 Sep 26, 2026
35 checks passed
@danielroe
danielroe deleted the fix/pre-bundle-layers branch September 26, 2026 17:13
@github-actions github-actions Bot mentioned this pull request Sep 26, 2026
@github-actions github-actions Bot mentioned this pull request Sep 26, 2026
@github-actions github-actions Bot mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CJS-only dependency reached only through a layer's plugin/layout bypasses optimizeDeps.include and is served broken to the browser

1 participant