-
Notifications
You must be signed in to change notification settings - Fork 0
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
Vue nestesd SFC does not play well with Astro #10
Comments
Take a look at these error logs. This one happens when the export is not true on certain components.
This one happens when the export is true on certain components
|
Ok I think you should look at the code from Vue Plugin Vue JSX It can help you with your problem. I know I keep commenting on this issue but I like this plugin. I want it to succeed. The plugin uses the third parameter of the {
transform(load,id,options){
const ssr = opt?.ssr === true
}
} Then at the end of the function this code is written. if (ssr) {
const normalizedId = normalizePath(path.relative(root, id))
let ssrInjectCode =
`\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` +
`\nconst __moduleId = ${JSON.stringify(normalizedId)}`
for (const { local } of hotComponents) {
ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)`
}
result.code += ssrInjectCode
}
} At the top of the plugin, this code is written. const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper'
const ssrRegisterHelperCode =
`import { useSSRContext } from "vue"\n` +
`export ${ssrRegisterHelper.toString()}`
/**
* This function is serialized with toString() and evaluated as a virtual
* module during SSR
*/
function ssrRegisterHelper(comp: ComponentOptions, filename: string) {
const setup = comp.setup
comp.setup = (props, ctx) => {
// @ts-ignore
const ssrContext = useSSRContext()
;(ssrContext.modules || (ssrContext.modules = new Set())).add(filename)
if (setup) {
return setup(props, ctx)
}
}
} I think this is how Vite SSR modules are allowed to be passed. This code might be the key. I don't understand what this code does, but I know that. It works. |
I have the same issue while trying to integrate it to |
I was trying to migrate my app to using this plugin when I ran into this error. It was caused by me trying to import a component into Astro that was using the
<component/>
. It also happens when trying to import a component that does not really have a default or a script tag at all.Link to minimal Repoducible Example
This link will lead to an example where I try to import three components.
They come from module called
./components/Components.vue
You see them immediately. Please tell me when you are done.https://stackblitz.com/edit/withastro-astro-3en7fb?file=src%2Fpages%2Findex.astro
The text was updated successfully, but these errors were encountered: