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

generatePageImport error handling path variable of win32 style #440

Open
Gehbt opened this issue Jul 9, 2024 · 6 comments · May be fixed by #441
Open

generatePageImport error handling path variable of win32 style #440

Gehbt opened this issue Jul 9, 2024 · 6 comments · May be fixed by #441
Labels
♦️ need repro the issue needs a reproduction for further investigation

Comments

@Gehbt
Copy link

Gehbt commented Jul 9, 2024

I tried running the example on repo in windows, an warning occurred. And vite serve is broken.

image

By tracing, It seems by the root.insert call node variable __dirname. It will return win32 style path \\unplugin-vue-router\\ , and path.join function keep the style.

image

When it written to / __vue-router/auto-routes by generatePageImport, path is converted to \unplugin-vue-router\. That caused backslash escape error.

reproduction

https://github.com/Gehbt/uvr-bug-repo1

  • go to vite.config.js
  • change join function import source to node:path
@Gehbt Gehbt changed the title generatePageImport may broken in win32 generatePageImport error handling path variable of win32 style Jul 9, 2024
@Gehbt Gehbt linked a pull request Jul 9, 2024 that will close this issue
@posva
Copy link
Owner

posva commented Jul 9, 2024

AFAIK shouldn’t this just work? Or maybe I could use the join from pathe

@Gehbt
Copy link
Author

Gehbt commented Jul 10, 2024

If the path as string, it can work, but it has been written to a file. Backslashes are transformed. For a Win32-style path, should prepare \\\\unplugin-vue-router\\\\.

@posva posva added the ♦️ need repro the issue needs a reproduction for further investigation label Jul 10, 2024
@Gehbt
Copy link
Author

Gehbt commented Jul 10, 2024

By the example of playground

beforeWriteFiles(root) {
   root.insert('/from-root', join(__dirname, './src/pages/index.vue'))
}

In windows, __dirname like C:\\Users\\USERNAME\\unplugin-vue-router, the path.join follow the style.

Like '\n' be newLine, the generated code be:

"component: () => import('C:\Users\USERNAME\unplugin-vue-router\playground\src\pages\index.vue'"

the backslashes transform do wrong.

If kept the Win32-style path, the filepath should be transformed into a raw string.

'C:\\\\Users\\\\USERNAME\\\\unplugin-vue-router\\\\playground\\\\src\\\\pages\\\\index.vue'

@posva
Copy link
Owner

posva commented Sep 3, 2024

A reproduction will still help for this. I don't have a windows to test right now thought

@Gehbt
Copy link
Author

Gehbt commented Sep 3, 2024

OK, I will do.

@Gehbt
Copy link
Author

Gehbt commented Sep 3, 2024

A reproduction is provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♦️ need repro the issue needs a reproduction for further investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants