Skip to content

Commit

Permalink
bugfix(react-native): change the metro-resolver to run tsconfig path …
Browse files Browse the repository at this point in the history
…resolver first (#9876)
  • Loading branch information
xiongemi authored and FrozenPandaz committed Apr 19, 2022
1 parent f3ae594 commit 075ec01
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions packages/react-native/plugins/metro-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,21 @@ export function getResolveRequest(extensions: string[]) {

const { resolveRequest, ...context } = _context;

let resolvedPath = defaultMetroResolver(context, moduleName, platform);
if (resolvedPath) {
return resolvedPath;
}
const resolvedPath =
defaultMetroResolver(context, moduleName, platform) ||
tsconfigPathsResolver(
context,
extensions,
realModuleName,
moduleName,
platform
) ||
pnpmResolver(extensions, context, realModuleName, moduleName);

resolvedPath = pnpmResolver(
extensions,
context,
realModuleName,
moduleName
);
if (resolvedPath) {
return resolvedPath;
}

return tsconfigPathsResolver(
context,
extensions,
realModuleName,
moduleName,
platform
);
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
};
}

Expand Down Expand Up @@ -136,7 +129,6 @@ function tsconfigPathsResolver(
)
);
}
throw new Error(`Cannot resolve ${chalk.bold(moduleName)}`);
}
}

Expand Down

0 comments on commit 075ec01

Please sign in to comment.