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
defineAsyncComponents
break building
#3820
Labels
Comments
Try adding something like this to your import { defineConfig } from 'vitepress'
export default defineConfig({
vite: {
plugins: [
{
name: 'patch-vitepress-symbol',
transform(code, id) {
if (id.includes('vitepress/dist/client/app/data.js')) {
return code.replace(
'const dataSymbol = Symbol();',
'const dataSymbol = "__vitepress_data__";'
)
}
}
}
]
}
}) It's happening because of chunking logic somewhere, but I'm not sure. Also, it works fine if defineAsyncComponent is used in markdown files 👀 Also, you shouldn't import |
brc-dd
added
bug
Something isn't working
has-workaround
Has workaround, low priority
client
and removed
bug: pending triage
Maybe a bug, waiting for confirmation
labels
Apr 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
Using
useData
with asyn components results in an error:Error: vitepress data not properly injected in app.
Reproduction
To replicate the issue, follow these steps in the provided StackBlitz project: https://stackblitz.com/edit/vite-5rgstx
Page.vue
file with the following code:import { useData } from 'vitepress'; const data = useData();
Page.vue
inLayout.vue
withimport Page from "./Page.vue"
and successfully build the project.const Page = defineAsyncComponent(() => import('./Page.vue'));
and attempt to rebuild. This results in an error indicating that VitePress data was not properly injected into the application.The error message is as follows:
Expected behavior
Build success
System Info
Additional context
I have encountered this bug since upgrading to v1.0.0-rc34. I'm unsure whether it's related to commit 9568fea
Validations
The text was updated successfully, but these errors were encountered: