-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Site config and data loaders don't support subpath imports #4173
Comments
I tried the following configurations:
Unfortunately none of the configuration worked.
It's interesting that the second configuration throws an error with |
I meant try this: import sharedData from '#sharedData'
// sharedData.js
export stuff ... It's not specific to vitepress. Create a normal |
Thank you for pointing that out! I hadn't tried that specific configuration before. While your solution works perfectly for JavaScript files, I noticed that it doesn't seem to work for TypeScript files. Do you have any suggestions on how to make this work with TypeScript as well? Edit: |
Ah, currently no. You'll need to use tsx, or switch completely to bun. Newer node versions have added an experimental strip types flag that might also work in certain cases. But even then updates in that subpath imported file won't be tracked and config won't auto-reload. You'll need to manually restart your server every time you change that file. |
Describe the bug
Subpath imports configured in
package.json
are not resolved in.vitepress/config.ts
and*.data.ts
.Reproduction
StackBlitz
package.json
in
.vitepress/config.ts
in a data loader
Expected behavior
import sharedData from '#sharedData'
should work identically to
import sharedData from '../../sharedData'
and set the site title to
Shared site title
.System Info
Additional context
Running VitePress with Bun (
bun --bun run docs:dev
) or tsxtsx node_modules/vitepress/bin/vitepress.js
works around the issue.Validations
The text was updated successfully, but these errors were encountered: