-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
custom resolve alias not available in .paths.js file #3125
Comments
i think the issue comes from this:
being a completely new Vite "load like is ssrLoadModule() a way to do the "load with ts and esm support" operation? idk https://vitejs.dev/guide/ssr.html#:~:text=%3D%20await%20vite.-,ssrLoadModule,-(%27/src/entry |
server isn't there in build, so can't do server.ssrLoadModule. I'm not sure if there is any simple solution to this. There was some discussion at #2289. But the solution, until vite itself lands something like vite-node or vavite into the core, is to not use aliases in data/path loader files. |
Hint: There is native support for this in Node itself. This works everywhere, including in data/path loader files: package.json: "imports": {
"#theme/*": "./docs/.vitepress/theme/*"
} [slug].paths.js: import hello from '#theme/hello.js' |
this is a great trick! it doesn't work so well for my usecase where the |
This solved my issue, THANKS ❤️ |
Describe the bug
when using a
[slug].md
and[slug].paths.js
file for dynamic routes the[slug].paths.js
file doesnt seem to get access to the magicresolve.alias["alias-goes-here"] = "/the/actual/file.js"
stuff.Reproduction
https://stackblitz.com/edit/vite-lt2rg5?file=docs%2F.vitepress%2Fconfig.ts,docs%2F.vitepress%2Fhello.js,docs%2F[slug].paths.js
if i remove the
import hello from "~hello"
line the error goes awayExpected behavior
i should be able to
import hello from "~hello"
and have it work, right?System Info
Additional context
Validations
The text was updated successfully, but these errors were encountered: