Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Feb 27, 2023
1 parent 09efc07 commit 7475184
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
if (
targetWeb &&
options.browserField &&
(res = tryResolveBrowserMapping(
fsPath,
importer,
options,
targetWeb,
true,
))
(res = tryResolveBrowserMapping(fsPath, importer, options, true))
) {
return res
}
Expand Down Expand Up @@ -338,7 +332,6 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
importer,
options,
false,
targetWeb,
external,
))
) {
Expand Down Expand Up @@ -1206,7 +1199,6 @@ function tryResolveBrowserMapping(
importer: string | undefined,
options: InternalResolveOptions,
isFilePath: boolean,
targetWeb: boolean,
externalize?: boolean,
) {
let res: string | undefined
Expand All @@ -1216,12 +1208,10 @@ function tryResolveBrowserMapping(
const mapId = isFilePath ? './' + slash(path.relative(pkg.dir, id)) : id
const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser)
if (browserMappedPath) {
const fsPath = path.join(pkg.dir, browserMappedPath)

if (
(res = bareImportRE.test(browserMappedPath)
? tryNodeResolve(browserMappedPath, importer, options, targetWeb)?.id
: tryFsResolve(fsPath, options))
? tryNodeResolve(browserMappedPath, importer, options, true)?.id
: tryFsResolve(path.join(pkg.dir, browserMappedPath), options))
) {
isDebug &&
debug(`[browser mapped] ${colors.cyan(id)} -> ${colors.dim(res)}`)
Expand Down

0 comments on commit 7475184

Please sign in to comment.