Skip to content

Commit

Permalink
Use basename comparison instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Binns-Smith committed Apr 7, 2022
1 parent 7845dc3 commit 88735fa
Show file tree
Hide file tree
Showing 2 changed files with 225 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/utils/node-resolver-core/src/NodeResolver.js
Expand Up @@ -779,7 +779,6 @@ export default class NodeResolver {
let res =
(await this.loadAsFile({
file: entry.filename,
asPackageEntry: true,
extensions,
env,
pkg,
Expand Down Expand Up @@ -973,14 +972,12 @@ export default class NodeResolver {
extensions,
env,
pkg,
asPackageEntry,
ctx,
}: {|
file: string,
extensions: Array<string>,
env: Environment,
pkg: InternalPackageJSON | null,
asPackageEntry?: boolean,
ctx: ResolverContext,
|}): Promise<?ResolvedFile> {
// Try all supported extensions
Expand All @@ -1002,9 +999,12 @@ export default class NodeResolver {
if (found) {
return {
path: found,
// If this is an entrypoint in package.json, it's possible pkg is not the
// If this package.json isn't a sibling of found, it's possible pkg is not the
// closest package.json to the resolved file. Reload it instead.
pkg: asPackageEntry ? await this.findPackage(found, ctx) : pkg,
pkg:
pkg == null || pkg?.pkgdir !== path.basename(found)
? await this.findPackage(found, ctx)
: pkg,
};
}

Expand Down

0 comments on commit 88735fa

Please sign in to comment.