failed to resolve custom component after version 0.49.16
Describe the bug
see https://github.com/slidevjs/slidev/discussions/1863#discussioncomment-10613408
Minimal reproduction
attached please find a reproducible example.
after decompressed, cd to root/project, then run
./start
this will install node_module and launch the site. You'll find a workable version, like this:
then stop it, perform the following actions:
- cd to root/project, remove .vite
- goto root/slidev_themes, edit package.json, change version to 0.49.29
- remove node_modules
- then start slidev again.
you'll find cannot resolve custom component in develop pane. custom-component-resolve-issue.tar.gz
before compressing, I've removed .git and styles/fonts folder, this should have no side effect.
Environment
- Slidev version: 0.49.29
- Browser: firefox
- OS: ubuntu focal
If you are using Slidev globally (i.e. npx slidev or npm i -g slidev), please try to reproduce the issue in a local project (i.e. npm create slidev@latest).
confirmed run the slide without npx lead to same:
npm run dev -- ~/workspace/issue/project/slides.md -t ~/workspace/issue/slidev_themes/themes/landscape-jade/
Success Scenario
if I move slidev_themes/components, package.json and project/slides.md,..etc into themes/landscape-jade, it will all work (but without specify theme. If I did, it will complain that route is not found)
Why should I use the folder structure in the issue?
I am an online course teacher. In different courses and scenarios (exercise, promotion, main course, etc), I need to use different themes, but I will always use the same components.
-
To ensure version consistency, I want these customized components to be in a single place rather than having multiple copies scattered across different themes.
-
I don't want to manage the slides and Slidev files in the same directory. Both the slides and Slidev files will be backed up using GitHub, but I need to put them in different repositories (the slides are private, but the Slidev themes are open source – because Slidev is open source).
workaround
link project to theme/slides.md
ln -s ~/workspace/issue/project/slides.md ./slides.md
ln -s ~/workspace/issue/project/pages ./pages
And keep components still copied into landscape_jade, this works.
link components
ln -s ~/workspace/issue/slidev_themes/components ./components
this will work too.
Therefore, before running a specific slide, I just need to create some symbolic links. The only inconvenience is that I have about 10 themes (most of which are meaningless experiments), and now these themes will unnecessarily install node_modules 10 times. However, this is not a major issue.
By the way, Slidev is an excellent project, and I really love it. I have even tried writing themes for it and released them. Later, I realized that I was doing some things that Slidev had already done, and I wasn’t doing them as well. Additionally, I used syntax that conflicts with Slidev. It seems that I am not yet ready to release my own themes. My themes might not help others and could instead waste their time.
I think the best way to do this is to extract the components into an addon (or simply a directory like X/components/*), and then use it as an addon in each of your slides.md.