Presentation with magic-move: lz-string doesn't provide an export named: 'default'
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
-
git clone https://github.com/3mdeb/slidev-template.git- clone the custom template -
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) ``` ```` -
cd slidev-template- go to the template directory -
npm install @slidev/cli@latest- update to latest slidev. -
./scripts/local-preview.sh ../slides.md- This script creates virtual environment and installs dependencies, then starts the presentation. -
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
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
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
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.