fix(ivy): handle windows drives correctly (#30297)
At the moment the module resolver will end up in an infinite loop in Windows because we are assuming that the root directory is always `/` however in windows this can be any drive letter example `c:/` or `d:/` etc... With this change we also resolve the drive letter in windows, when using `AbsoluteFsPath.from` for consistence so under `/foo` will be converted to `c:/foo` this is also needed because of relative paths with different drive letters. PR Close #30297
This commit is contained in:
@ -118,7 +118,7 @@ export class ModuleResolver {
|
||||
*/
|
||||
private resolveAsEntryPoint(moduleName: string, fromPath: AbsoluteFsPath): ResolvedModule|null {
|
||||
let folder = fromPath;
|
||||
while (folder !== '/') {
|
||||
while (!AbsoluteFsPath.isRoot(folder)) {
|
||||
folder = AbsoluteFsPath.dirname(folder);
|
||||
if (folder.endsWith('node_modules')) {
|
||||
// Skip up if the folder already ends in node_modules
|
||||
@ -225,7 +225,7 @@ export class ModuleResolver {
|
||||
*/
|
||||
private findPackagePath(path: AbsoluteFsPath): AbsoluteFsPath|null {
|
||||
let folder = path;
|
||||
while (folder !== '/') {
|
||||
while (!AbsoluteFsPath.isRoot(folder)) {
|
||||
folder = AbsoluteFsPath.dirname(folder);
|
||||
if (this.fs.exists(AbsoluteFsPath.join(folder, 'package.json'))) {
|
||||
return folder;
|
||||
|
@ -27,7 +27,7 @@ export class NgccCompilerHost implements ts.CompilerHost {
|
||||
}
|
||||
|
||||
getDefaultLibLocation(): string {
|
||||
const nodeLibPath = AbsoluteFsPath.fromUnchecked(require.resolve('typescript'));
|
||||
const nodeLibPath = AbsoluteFsPath.from(require.resolve('typescript'));
|
||||
return AbsoluteFsPath.join(nodeLibPath, '..');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user