-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 tsconfig alias regression #6617
Conversation
🦋 Changeset detectedLatest commit: f63a92b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (id.startsWith('.') || id.startsWith('/')) return; | ||
|
||
// Handle baseUrl mapping for non-relative and non-root imports. | ||
// Since TypeScript only applies `baseUrl` autocompletions for files that exist | ||
// in the filesystem only, we can use this heuristic to skip resolve if needed. | ||
const resolved = path.posix.join(resolvedBaseUrl, id); | ||
if (fs.existsSync(resolved)) { |
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.
When importing TypeScript files without the .ts
extension, this condition was always false, as /path/to/ts-file
doesn't exist.
Thought about adding a check for .ts
files starting with the resolved id to make the change minimal but realized that there might be other file types that could be resolved when not specifying the extension (maybe via vite plugins pushed before the ts/js resolver? Not sure)
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.
Great call!
There's a weird path issue occuring on Windows, I'll debug this tomorrow on my windows machine |
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.
Windows passes now! It was because it checked for absolute imports via .startsWith('/')
which doesn't match on Windows. I've changed that to path.isAbsolute
.
Thanks for jumping in @bluwy! |
This reverts commit 38e6ec2.
Changes
Fix #6613
Testing
Check that Typescript file without
.ts
extension can be importedDocs
N/A, bug fix only