Skip to content
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

Async components files are not returned in preloadFiles #11

Closed
juvirez opened this issue Jul 21, 2021 · 2 comments
Closed

Async components files are not returned in preloadFiles #11

juvirez opened this issue Jul 21, 2021 · 2 comments

Comments

@juvirez
Copy link
Contributor

juvirez commented Jul 21, 2021

If a component is defined as an async component like this:

app.component('HelloWorld', defineAsyncComponent(() => import(/* webpackChunkName: "hello-world" */ './components/HelloWorld.vue')));

Component resources (js, css) are not included in the result of renderToString().preloadFiles().

Here is example: https://github.com/juvirez/test-async-components

It looks like here is the code responsible for this:

export function getUsedAsyncFiles (ssrContext: SSRContext, renderContext: RenderContext): Array<Resource> {
if (!ssrContext._mappedFiles && ssrContext._registeredComponents && renderContext.mapFiles) {
const registered = Array.from(ssrContext._registeredComponents)
ssrContext._mappedFiles = renderContext.mapFiles(registered).map(normalizeFile)
}
return ssrContext._mappedFiles || []
}

But in my case _registeredComponents is undefined. How can I define this variable for ssrContext?

@danielroe
Copy link
Member

danielroe commented May 4, 2022

If you're using webpack, _registeredComponents needs to be filled out with all components used to render a page. Previously vue-loader did this in v15 and it's still planned for v16: vuejs/vue-loader#1887

Here's how we do it in Nuxt for webpack: https://github.com/nuxt/framework/blob/4712e994112a97feba447b3edb4afb65e968ed63/packages/nuxt/src/app/plugins/preload.server.ts#L1-L12

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2022
@dmitryuk
Copy link

dmitryuk commented Nov 2, 2024

@danielroe do you know where __moduleIdentifier param is set? It is missing in my case
nuxt/nuxt#29747

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants