Skip to content

Commit

Permalink
feat: add preserveSymlinks to InternalResolveOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 16, 2021
1 parent d3b7819 commit e7d35f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface InternalResolveOptions extends ResolveOptions {
tryPrefix?: string
preferRelative?: boolean
isRequire?: boolean
preserveSymlinks?: boolean
}

export function resolvePlugin(baseOptions: InternalResolveOptions): Plugin {
Expand Down Expand Up @@ -380,7 +381,7 @@ export function tryNodeResolve(
basedir = root
}

const pkg = resolvePackageData(pkgId, basedir)
const pkg = resolvePackageData(pkgId, basedir, options.preserveSymlinks)

if (!pkg) {
return
Expand Down Expand Up @@ -479,7 +480,8 @@ const packageCache = new Map<string, PackageData>()

export function resolvePackageData(
id: string,
basedir: string
basedir: string,
preserveSymlinks = false
): PackageData | undefined {
const cacheKey = id + basedir
if (packageCache.has(cacheKey)) {
Expand All @@ -488,7 +490,7 @@ export function resolvePackageData(
try {
const pkgPath = resolve.sync(`${id}/package.json`, {
basedir,
preserveSymlinks: true
preserveSymlinks
})
return loadPackageData(pkgPath, cacheKey)
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/ssr/ssrExternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function resolveSSRExternal(

const resolveOptions: InternalResolveOptions = {
root,
preserveSymlinks: true,
isProduction: false,
isBuild: true
}
Expand Down

0 comments on commit e7d35f5

Please sign in to comment.