Skip to content

Inconsistent Router Injection Error with Additional Resolvers #2047

Closed
@sghng

Description

@sghng

Describe the bug

When using additional component resolvers, the application becomes blank after a while, with the following browser console errors:

[Vue warn]: injection "Symbol(router)" not found.
[Vue warn]: injection "Symbol(route location)" not found.
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'currentRoute')

This is very weird problem. Sometimes the slides work fine, everything including the PrimeVue components are displayed correctly, but after a few seconds app div will become blank. Sometimes the slides don't load at all.

Minimal reproduction

Note that this problem is not reproduced consistently. Here's what my customization looks like:

// main.ts
import { defineAppSetup } from "@slidev/types";
import PrimeVue from "primevue/config";
import Aura from "@primevue/themes/aura";

export default defineAppSetup(({ app }) => {
  // TODO: support specifying themes in head matter
  app.use(PrimeVue, {
    theme: {
      preset: Aura,
      options: {
        // PrimeVue uses system dark mode selector by default, which conflicts
        // with the toggle in Slidev
        darkModeSelector: ".dark"
      }
    },
  });
});
/// <reference types="@slidev/types" />

import { defineConfig } from "vite";
import { PrimeVueResolver } from "@primevue/auto-import-resolver";

export default defineConfig({
  slidev: {
    components: {
      resolvers: [PrimeVueResolver()],
    },
  },
});
  1. Install the addon using npm install slidev-addon-prime
  2. Add the addon to slides.md:
---
addons:
  - prime
---
  1. (optional) add some PrimeVue components
<div class="card flex justify-center flex-wrap gap-4">
  <Button label="Primary" />
  <Button label="Secondary" severity="secondary" />
</div>
  1. Run slidev.

Potential Causes

Interference between the router injection and other resolvers.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions