Open JohnCampionJr opened 1 year ago
So I've figured out the cause but not yet sure best way to fix. Given this data loader in the theme:
// themecontent.data.ts
import { createContentLoader } from 'vitepress';
export { data };
export default createContentLoader('*.md' /* options */);
Gets transpiled to
// themecontent.data.js
import { createContentLoader } from 'vitepress';
export { data };
export default createContentLoader('*.md' /* options */);
(Note the .js)
Then when the staticDataPlugin
tries to load that one with Vite, it throws the error on this:
export { data };
Which makes sense because that is no longer needed as it is a TypeScript construct.
If I take the line out in the dist files, it works as expected.
So there is a workaround:
Use .js for the theme's data loader
And then then a types file to get proper typing
//themecontent.data.d.ts
declare const data: any
export { data }
Works perfectly while keeping the typing
track #3185 here too
Describe the bug
I want to put some data loaders into a re-usable template package but it seems in this scenario, they are not processed by VitePress.
Reproduction
This repo/branch demonstrates that its not being processed: https://github.com/jcamp-test/vitepress-theme-starter/tree/data-loader
Expected behavior
Should work as normal
System Info
Additional context
No response
Validations