slidev icon indicating copy to clipboard operation
slidev copied to clipboard

Presentation with magic-move: lz-string doesn't provide an export named: 'default'

Open EduKav1813 opened this issue 8 months ago • 2 comments

Describe the bug

I have issues when running my presentation with the magic-move feature.

  • The slide fails to load and displays the "An error occurred on this slide. Check the terminal for more information.".
  • The browser console gives the following error message: "slide failed to load SyntaxError: The requested module 'http://localhost:3031/slidev-template/node_modules/lz-string/libs/lz-string.js?v=57f97925' doesn't provide an export named: 'default' slides:20:23"

Minimal reproduction

Steps to reproduce the behavior:

I am using custom theme as a submodule: https://github.com/3mdeb/slidev-template

  1. git clone https://github.com/3mdeb/slidev-template.git - clone the custom template

  2. Create the file slides.md with the following content:

         ---
        theme: ./slidev-template/theme
        layout: cover
        background: /intro.png
        class: text-center
        ---
    
        # Hello World
    
        Hello World
    
        ---
        style: |
          --slidev-code-font-size: 16px;
        ---
    
        ````md magic-move
        ```js
        console.log(`Step ${1}`)
        ```
        ```js
        console.log(`Step ${1 + 1}`)
        ```
        ```ts
        console.log(`Step ${3}` as string)
        ```
        ````
    
  3. cd slidev-template - go to the template directory

  4. npm install @slidev/cli@latest - update to latest slidev.

  5. ./scripts/local-preview.sh ../slides.md - This script creates virtual environment and installs dependencies, then starts the presentation.

  6. In the presentation, go to the next slide (with magic-move).

Expected result: Presentation works normally, code changes via the magic-move.

Actual result:

  • The slide fails to load and displays the "An error occurred on this slide. Check the terminal for more information.".
  • The browser console gives the following error message: "slide failed to load SyntaxError: The requested module 'http://localhost:3031/slidev-template/node_modules/lz-string/libs/lz-string.js?v=57f97925' doesn't provide an export named: 'default' slides:20:23"

Environment

  • Slidev version: v51.6.0 (latest)
  • Browser: Firefox
  • OS: Fedora Linux 41

EduKav1813 avatar May 15 '25 08:05 EduKav1813

Tried with https://github.com/3mdeb/slidev-template/commit/2a69b72183136b76e9039b4a8d4f15ad5898ea6f and slidev/cli: 52.0.0, magic-move works for me. To reproduce I had to create slides.md in slidev-template repository and run it with slidev-template/scripts/local-preview.sh slidev-template/slides.md

m-iwanicki avatar Jul 02 '25 08:07 m-iwanicki

The bug is that magic-move fails when slides.md file isn't in slidev-template directory or it's sub-directories but above e.g.

.
├── slides.md
└── slidev-template

In this case firefox console has this error:

slide failed to load SyntaxError: The requested module 'http://localhost:3030/slidev-template/node_modules/lz-string/libs/lz-string.js?v=98c5911f' doesn't provide an export named: 'default' [slides:20:23](http://localhost:3030/@slidev/slides)
    load2 slides:20
    preloadRoute SlidesShow.vue:34
    setup SlidesShow.vue:39
    callWithErrorHandling runtime-core.esm-bundler.js:199
    callWithAsyncErrorHandling runtime-core.esm-bundler.js:206
    call runtime-core.esm-bundler.js:6251
    getter reactivity.esm-bundler.js:1781
    run reactivity.esm-bundler.js:237
    job reactivity.esm-bundler.js:1840
    callWithErrorHandling runtime-core.esm-bundler.js:199
    flushJobs runtime-core.esm-bundler.js:408
    (Async: promise callback)
    queueFlush runtime-core.esm-bundler.js:322
    queuePostFlushCb runtime-core.esm-bundler.js:336
    queueEffectWithSuspense runtime-core.esm-bundler.js:7379
    scheduler runtime-core.esm-bundler.js:6255
    scheduler reactivity.esm-bundler.js:1847
    trigger reactivity.esm-bundler.js:265
    endBatch reactivity.esm-bundler.js:323
    notify reactivity.esm-bundler.js:614
    trigger reactivity.esm-bundler.js:588
    set value reactivity.esm-bundler.js:1465
    finalizeNavigation vue-router.mjs:3503
    pushWithRedirect vue-router.mjs:3368
    (Async: promise callback)
    pushWithRedirect vue-router.mjs:3335
    push vue-router.mjs:3260
    go useNav.ts:194
    nextSlide useNav.ts:161
    next useNav.ts:145
    trigger shortcuts.ts:44
    callWithErrorHandling runtime-core.esm-bundler.js:199
    callWithAsyncErrorHandling runtime-core.esm-bundler.js:206
    call runtime-core.esm-bundler.js:6251
    job reactivity.esm-bundler.js:1831
    trigger reactivity.esm-bundler.js:265
    endBatch reactivity.esm-bundler.js:323
    notify reactivity.esm-bundler.js:614
    trigger reactivity.esm-bundler.js:588
    set value reactivity.esm-bundler.js:1465
    setRefs index.mjs:4684
    updateRefs index.mjs:4705
    useMagicKeys index.mjs:4727

m-iwanicki avatar Jul 07 '25 09:07 m-iwanicki

Hmmm, I think this is caused by an edge case where Vite's resolution of lz-string differs from Slidev's custom one, resulting in Slidev's Vite configuration being ineffective.

kermanx avatar Nov 14 '25 09:11 kermanx