Skip to content

Commit cf97711

Browse files
committed
fix: revert, "fix: resolve pnpm .modules.yaml from workspace root instead of cwd (#22757)"
This reverts commit 2531ac7.
1 parent cccef55 commit cf97711

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

packages/vite/src/node/server/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,13 +1220,12 @@ export async function resolveServerOptions(
12201220

12211221
setupHmrWsOptionCompat(_server)
12221222

1223-
const workspaceRoot = searchForWorkspaceRoot(root)
12241223
const server: ResolvedServerOptions = {
12251224
..._server,
12261225
fs: {
12271226
..._server.fs,
12281227
// run searchForWorkspaceRoot only if needed
1229-
allow: raw?.fs?.allow ?? [workspaceRoot],
1228+
allow: raw?.fs?.allow ?? [searchForWorkspaceRoot(root)],
12301229
},
12311230
sourcemapIgnoreList:
12321231
_server.sourcemapIgnoreList === false
@@ -1264,13 +1263,7 @@ export async function resolveServerOptions(
12641263
// Read node_modules/.modules.yaml which pnpm always writes on install — this works
12651264
// unconditionally regardless of how Vite is launched (node / npx / pnpm run),
12661265
// avoiding the need for subprocess calls or user-agent sniffing.
1267-
// Use workspace root (not package root) because .modules.yaml lives at the
1268-
// monorepo root's node_modules/, not in nested workspace packages.
1269-
const pnpmModulesYaml = path.join(
1270-
workspaceRoot,
1271-
'node_modules',
1272-
'.modules.yaml',
1273-
)
1266+
const pnpmModulesYaml = path.join(cwd, 'node_modules', '.modules.yaml')
12741267
try {
12751268
const content = fs.readFileSync(pnpmModulesYaml, 'utf-8')
12761269
const parsed = JSON.parse(content)
@@ -1280,10 +1273,7 @@ export async function resolveServerOptions(
12801273
allowDirs.push(virtualStoreDir)
12811274
} else if (virtualStoreDir.startsWith('..')) {
12821275
allowDirs.push(
1283-
path.resolve(
1284-
path.join(workspaceRoot, 'node_modules'),
1285-
virtualStoreDir,
1286-
),
1276+
path.resolve(path.join(cwd, 'node_modules'), virtualStoreDir),
12871277
)
12881278
}
12891279
}

0 commit comments

Comments
 (0)