-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix importing absolutely aliased dependency #641
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
Comment on lines
+344
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can alter the types so that in the case of an absolute resolution these are not present. I don't know what the downstream effects of that would be, but they're extremely relevant to this PR, since this PR would be giving that code potentially misleading information. (Nothing enforces that the absolute path is actually coming from this packageName and packageRoot.) |
||
}; | ||
} | ||
} | ||
|
||
return { | ||
type: 'local', | ||
local: path, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be concerned here that if we support aliasing to absolute paths, it should not be mandatory that the package resolves at all.