Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _getAliasForExternal(
absSearchDir: FilePath,
requiredModule: FilePath
): AliasToValue | undefined {
const {_absRootDir, _aliasFields} = this;
const aliases = loadAliases(
absSearchDir.join('package.json'),
_aliasFields
);
let alias = aliases[requiredModule.asPosix];
// Found: return it
if (alias !== undefined) {
return alias;
}
// Search finished
if (absSearchDir.is(_absRootDir)) {
return undefined;
}
private _getAliasForLocal(
absSearchTopDir: FilePath,
absSearchDir: FilePath,
searchRelModuleName: FilePath
): AliasToValue | undefined {
const {_aliasFields} = this;
const aliases = loadAliases(
absSearchDir.join('package.json'),
_aliasFields
);
const normalizedSearchRelModuleName = `./${searchRelModuleName.asPosix}`;
let alias = aliases[normalizedSearchRelModuleName];
// Try with file alias
if (
alias === undefined &&
!normalizedSearchRelModuleName.toLowerCase().endsWith('.js')
) {
alias = aliases[`${normalizedSearchRelModuleName}.js`];
}
// Try with external module aliases