Open Gehbt opened 3 months ago
AFAIK shouldn’t this just work? Or maybe I could use the join from pathe
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\\\\
.
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'
A reproduction will still help for this. I don't have a windows to test right now thought
OK, I will do.
A reproduction is provided
I tried running the example on repo in windows, an warning occurred. And vite serve is broken.
By tracing, It seems by the
root.insert
call node variable__dirname
. It will return win32 style path\\unplugin-vue-router\\
, andpath.join
function keep the style.When it written to
/ __vue-router/auto-routes
bygeneratePageImport
, path is converted to\unplugin-vue-router\
. That caused backslash escape error.reproduction
https://github.com/Gehbt/uvr-bug-repo1
vite.config.js
join
function import source tonode:path