Skip to content
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(compiler-sfc): normalize windows paths when resolving types #8671

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

Y0me
Copy link

@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

@sodatea sodatea added ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. scope: script-setup labels Oct 11, 2023
@@ -778,7 +778,7 @@ function importSourceToScope(
if (!resolved) {
if (source.startsWith('.')) {
// relative import - fast path
const filename = joinPaths(scope.filename, '..', source)
const filename = joinPaths(normalizePath(scope.filename), '..', normalizePath(source))
Copy link
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 ...

@sodatea sodatea 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
sodatea added a commit to sodatea/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.
@sodatea
Copy link
Member

sodatea commented Oct 20, 2023

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.

None yet

5 participants