Hi, I'm trying to use the createContentLoader function but I always get the same traceback:
PS G:\THR\The-Hacker-Recipes> npm run docs:build
> docs:build
> vitepress build docs
vitepress v1.4.0
x Build failed in 13.54s
✖ building client + server bundles...
build error:
docs/.vitepress/theme/composables/authorsLoader.ts (2:9): "createContentLoader" is not exported by "node_modules/vitepress/dist/client/index.js", imported by "docs/.vitepress/theme/composables/authorsLoader.ts".
file: G:/THR/The-Hacker-Recipes/docs/.vitepress/theme/composables/authorsLoader.ts:2:9
1: // authorsLoader.ts
2: import { createContentLoader } from 'vitepress'
^
3:
4: export default createContentLoader({
docs/.vitepress/theme/composables/authorsLoader.ts (2:9): "createContentLoader" is not exported by "node_modules/vitepress/dist/client/index.js", imported by "docs/.vitepress/theme/composables/authorsLoader.ts".
file: G:/THR/The-Hacker-Recipes/docs/.vitepress/theme/composables/authorsLoader.ts:2:9
1: // authorsLoader.ts
2: import { createContentLoader } from 'vitepress'
^
3:
4: export default createContentLoader({
at getRollupError (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/parseAst.js:395:41)
at error (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/parseAst.js:391:42)
at Module.error (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:15535:16)
at Module.traceVariable (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:15984:29)
at ModuleScope.findVariable (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:13770:39)
at Identifier.bind (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:5035:40)
at CallExpression.bind (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:2855:23)
at CallExpression.bind (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:11235:15)
at ExportDefaultDeclaration.bind (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:2855:23)
at Program.bind (file:///G:/THR/The-Hacker-Recipes/node_modules/rollup/dist/es/shared/node-entry.js:2851:28)
Here is my file which uses the module, authorsLoader.ts :
And here is my index.js from which the modules I can import are taken:
// exports in this file are exposed to themes and md files via 'vitepress'
// so the user can do `import { useRoute, useData } from 'vitepress'`
// composables
export { useData, dataSymbol } from './app/data';
export { useRoute, useRouter } from './app/router';
// utilities
export { inBrowser, onContentUpdated, defineClientComponent, withBase, getScrollOffset, _escapeHtml } from './app/utils';
// components
export { Content } from './app/components/Content';
Reproduction
Here you can see the github action build failing :
createContentLoader is node-only API. You seem to be using it in client-side code. You should name your file authors.data.ts -- docs https://vitepress.dev/guide/data-loading
Describe the bug
Hi, I'm trying to use the
createContentLoader
function but I always get the same traceback:Here is my file which uses the module,
authorsLoader.ts
:And here is my
index.js
from which the modules I can import are taken:Reproduction
Here you can see the github action build failing :
https://github.com/The-Hacker-Recipes/The-Hacker-Recipes/actions/runs/11284736710/job/31386402614
Expected behavior
I expect my version of vitepress being able to use all the framework modules.
System Info
Additional context
No response
Validations