Skip to content

fix(compiler-sfc): normalize windows paths when resolving types#8671

Closed
Y0me wants to merge 1 commit intovuejs:mainfrom
Y0me:yome-fix
Closed

fix(compiler-sfc): normalize windows paths when resolving types#8671
Y0me wants to merge 1 commit intovuejs:mainfrom
Y0me:yome-fix

Conversation

@Y0me
Copy link
Copy Markdown

@Y0me Y0me commented Jun 28, 2023

Getting error when using defineProps and importing a type from another files on Windows.

For more information and a reproduction repository, look at this issue
Similar to this pull request

@haoqunjiang haoqunjiang added ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. scope: script-setup labels Oct 11, 2023
if (source.startsWith('.')) {
// relative import - fast path
const filename = joinPaths(scope.filename, '..', source)
const filename = joinPaths(normalizePath(scope.filename), '..', normalizePath(source))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Windows and this does not fix the bug. The problem here is the ...

@haoqunjiang haoqunjiang removed the ready to merge The PR is ready to be merged. label Oct 19, 2023
@yyx990803 yyx990803 added ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. and removed ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Oct 20, 2023
haoqunjiang added a commit to haoqunjiang/core that referenced this pull request Oct 20, 2023
Closes vuejs#8671
Closes vuejs/vue-loader#2048

`dirname` is the safest way to get a directory name from a path string.

As for this specific bug, it's because
`path.posix.join(AnyWindowsPath, '..')` returns `.`.

I'm not sure whether there will be unexpected regression if I modify the
`joinPaths` utility, so I changed the smallest possible bit of code to
fix this.
@haoqunjiang
Copy link
Copy Markdown
Member

Closing in favor of #9446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: script-setup

Projects

Status: Rejected

Development

Successfully merging this pull request may close these issues.

5 participants