Skip to content

Commit

Permalink
fix: reuse findNearestMainPackageData at more places
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Feb 4, 2025
1 parent 6f1e744 commit 635521f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { dataURIPlugin } from './plugins/dataUri'
import { buildImportAnalysisPlugin } from './plugins/importAnalysisBuild'
import { ssrManifestPlugin } from './ssr/ssrManifestPlugin'
import { buildLoadFallbackPlugin } from './plugins/loadFallback'
import { findNearestPackageData } from './packages'
import { findNearestMainPackageData, findNearestPackageData } from './packages'
import type { PackageCache } from './packages'
import {
getResolvedOutDirs,
Expand Down Expand Up @@ -919,7 +919,7 @@ export function resolveLibFilename(
return libOptions.fileName(format, entryName)
}

const packageJson = findNearestPackageData(root, packageCache)?.data
const packageJson = findNearestMainPackageData(root, packageCache)?.data
const name =
libOptions.fileName ||
(packageJson && typeof libOptions.entry === 'string'
Expand Down
7 changes: 3 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ import type { TransformPluginContext } from '../server/pluginContainer'
import { searchForWorkspaceRoot } from '../server/searchRoot'
import { type DevEnvironment } from '..'
import type { PackageCache } from '../packages'
import { findNearestPackageData } from '../packages'
import { findNearestMainPackageData } from '../packages'
import { addToHTMLProxyTransformResult } from './html'
import {
assetUrlRE,
Expand Down Expand Up @@ -3462,9 +3462,8 @@ export function resolveLibCssFilename(
return `${libOptions.fileName}.css`
}

const packageJson = findNearestPackageData(root, packageCache)?.data
const name =
packageJson && packageJson.name ? getPkgName(packageJson.name) : undefined
const packageJson = findNearestMainPackageData(root, packageCache)?.data
const name = packageJson ? getPkgName(packageJson.name) : undefined

if (!name)
throw new Error(
Expand Down

0 comments on commit 635521f

Please sign in to comment.