Skip to content

Commit 635521f

Browse files
committed
fix: reuse findNearestMainPackageData at more places
1 parent 6f1e744 commit 635521f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/vite/src/node/build.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import { dataURIPlugin } from './plugins/dataUri'
6060
import { buildImportAnalysisPlugin } from './plugins/importAnalysisBuild'
6161
import { ssrManifestPlugin } from './ssr/ssrManifestPlugin'
6262
import { buildLoadFallbackPlugin } from './plugins/loadFallback'
63-
import { findNearestPackageData } from './packages'
63+
import { findNearestMainPackageData, findNearestPackageData } from './packages'
6464
import type { PackageCache } from './packages'
6565
import {
6666
getResolvedOutDirs,
@@ -919,7 +919,7 @@ export function resolveLibFilename(
919919
return libOptions.fileName(format, entryName)
920920
}
921921

922-
const packageJson = findNearestPackageData(root, packageCache)?.data
922+
const packageJson = findNearestMainPackageData(root, packageCache)?.data
923923
const name =
924924
libOptions.fileName ||
925925
(packageJson && typeof libOptions.entry === 'string'

packages/vite/src/node/plugins/css.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import type { TransformPluginContext } from '../server/pluginContainer'
9191
import { searchForWorkspaceRoot } from '../server/searchRoot'
9292
import { type DevEnvironment } from '..'
9393
import type { PackageCache } from '../packages'
94-
import { findNearestPackageData } from '../packages'
94+
import { findNearestMainPackageData } from '../packages'
9595
import { addToHTMLProxyTransformResult } from './html'
9696
import {
9797
assetUrlRE,
@@ -3462,9 +3462,8 @@ export function resolveLibCssFilename(
34623462
return `${libOptions.fileName}.css`
34633463
}
34643464

3465-
const packageJson = findNearestPackageData(root, packageCache)?.data
3466-
const name =
3467-
packageJson && packageJson.name ? getPkgName(packageJson.name) : undefined
3465+
const packageJson = findNearestMainPackageData(root, packageCache)?.data
3466+
const name = packageJson ? getPkgName(packageJson.name) : undefined
34683467

34693468
if (!name)
34703469
throw new Error(

0 commit comments

Comments
 (0)