Skip to content

Conversation

danielroe
Copy link
Member

Background

On SSR if an unregistered component is used we have a hard crash as we try to cache the details about this component, but it's a string (not a resolved object) and can't be used as a cache key to the WeakMap that's we're using.

It's true this is wrong usage, and there is a helpful warning:

[Vue warn]: Failed to resolve component: SomeThing
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

But there is also a fatal and hard error that occurs:

Fatal error:

Error: WeakMap key must be an object, got comp
    at _evaluate (https://node-2lafe5-dfi279td.w-corp.staticblitz.com/blitz.bff91798029e1af88e01551d056a592b2882b9ac.js:15:286611)
    at <anonymous> (<anonymous>)

Code

import { createSSRApp } from 'vue';
import { renderToString } from 'vue/server-renderer';

const app = createSSRApp({
  template: `<SomeThing />`,
});

console.log(await renderToString(app));

https://stackblitz.com/edit/node-2lafe5?file=index.mjs

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

Successfully merging this pull request may close these issues.

4 participants