From 74feef56fd27a9583f8df3133d52f11151b90436 Mon Sep 17 00:00:00 2001 From: Stephen Randall Date: Fri, 16 Dec 2022 15:35:57 -0500 Subject: [PATCH 1/2] sync version of `realpath` --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c1ad378..b725c8e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import fs from 'node:fs/promises' +import fsSync from 'node:fs' import path from 'node:path' import { isDepIncluded, @@ -207,7 +208,8 @@ export async function findDepPkgJsonPath(dep, parent) { const pkg = path.join(root, 'node_modules', dep, 'package.json') try { await fs.access(pkg) - return await fs.realpath(pkg) + // use 'node:fs' version to match 'vite:resolve' + return fsSync.realpathSync(pkg) } catch {} const nextRoot = path.dirname(root) if (nextRoot === root) break From f8f8011a7f6d52d087b0059dc117a55e3b8023ea Mon Sep 17 00:00:00 2001 From: bluwy Date: Sat, 17 Dec 2022 14:36:37 +0800 Subject: [PATCH 2/2] Update comment --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b725c8e..0ea1482 100644 --- a/src/index.js +++ b/src/index.js @@ -208,7 +208,8 @@ export async function findDepPkgJsonPath(dep, parent) { const pkg = path.join(root, 'node_modules', dep, 'package.json') try { await fs.access(pkg) - // use 'node:fs' version to match 'vite:resolve' + // use 'node:fs' version to match 'vite:resolve' and avoid realpath.native quirk + // https://github.com/sveltejs/vite-plugin-svelte/issues/525#issuecomment-1355551264 return fsSync.realpathSync(pkg) } catch {} const nextRoot = path.dirname(root)