From ac316b30e0cd4d59f81c531991697ccb6ed61a1a Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Mon, 7 Oct 2024 13:33:19 +0200 Subject: [PATCH] Handle alias with absolute path --- packages/ember-auto-import/ts/package.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/ember-auto-import/ts/package.ts b/packages/ember-auto-import/ts/package.ts index e5c55b54..57596bb5 100644 --- a/packages/ember-auto-import/ts/package.ts +++ b/packages/ember-auto-import/ts/package.ts @@ -326,9 +326,27 @@ export default class Package { // relative or absolute path, rather than a package name. If the // originally authored import was an absolute or relative path, it would // have hit our { type: 'local' } condition before we ran aliasFor. - // - // At the moment, we don't try to handle this case, but we could in the - // future. + + packageName = getPackageName(importedPath); + + if (packageName) { + let packageRoot: string | undefined; + let packagePath = resolvePackagePath(packageName, this.root); + + if (packagePath) { + packageRoot = dirname(packagePath); + } + + if (packageRoot) { + return { + type: 'package', + path, + packageName, + packageRoot, + }; + } + } + return { type: 'local', local: path,