Skip to content

fix: detect Deno workspace root (fix #22237)#22238

Open
semimikoh wants to merge 1 commit intovitejs:mainfrom
semimikoh:fix-deno-workspace-root
Open

fix: detect Deno workspace root (fix #22237)#22238
semimikoh wants to merge 1 commit intovitejs:mainfrom
semimikoh:fix-deno-workspace-root

Conversation

@semimikoh
Copy link
Copy Markdown

@semimikoh semimikoh commented Apr 15, 2026

Description

Adds Deno workspace detection to searchForWorkspaceRoot.

Deno workspaces are declared with the workspace field in deno.json. Without recognizing this config, Vite may resolve the workspace
root to a nested package directory instead of the repository root. This can make the default server.fs.allow too narrow for Deno
projects where npm packages are installed under the repository-level node_modules/.deno directory.

This became visible after server.fs checks started applying to environment transport module fetches.

Changes

  • Detect deno.json and deno.jsonc files with a workspace field in searchForWorkspaceRoot
  • Add Deno workspace fixtures
  • Add tests for nested and root Deno workspace resolution

Notes

deno.jsonc is detected only when its contents are also valid JSON. Full JSONC parsing would require an additional parser, which this PR
avoids.

Tests

pnpm exec vitest run packages/vite/src/node/server/tests/search-root.spec.ts

Fixes #22237

Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

I think it might be worth looking into supporting deno.json in searchForPackageRoot too, but I think this change itself is fine to fix the issue first now.

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.

loadAndTransform regression in 8.0.4: consumer === "server"` bypass removed, breaks Deno + nitro

2 participants