Skip to content

Load preparser also from theme#2558

Open
jgosmann wants to merge 3 commits into
slidevjs:mainfrom
jgosmann:preparser-from-theme
Open

Load preparser also from theme#2558
jgosmann wants to merge 3 commits into
slidevjs:mainfrom
jgosmann:preparser-from-theme

Conversation

@jgosmann
Copy link
Copy Markdown
Contributor

Not loading preparsers from the theme is unexpected (cp. #2402, #2456) and not documented. This PR aligns the behavior such that preparsers are also loaded from the theme. It also avoids duplicating the logic to determine the roots that things are loaded from, which might also improve perforrmance by avoiding doing resolveAddons twice. I hope this is in line with the requested refactor.

I explained my use cases for wanting to load a preparser from a theme in a prior comment.

This will later allow to use the resolved roots for loading preparsers without duplication the roots resolution there.
… else

- Preparsers weren't loaded from the theme which was inconsistent to other things (e.g. styles) and not documented.
- Besides consistency, this avoids resolving addons twice which is apparently a somewhat expensive operation.

Fixes slidevjs#2402.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 24, 2026

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 466ac55
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69eb27af6d9fa2000830a9d2
😎 Deploy Preview https://deploy-preview-2558--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 24, 2026

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2558

create-slidev

npm i https://pkg.pr.new/create-slidev@2558

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2558

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2558

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2558

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2558

commit: 466ac55

async function loadProject(entry: string) {
const userRoot = dirname(entry)
return markRaw(await load(userRoot, entry, async (path: string) => {
return markRaw(await load({ userRoot, roots: [userRoot] }, entry, async (path: string) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the VSCode plugin and I'm not using it. Is it fine to just consider the userRoot here? @slidev/cli seems not accessible here to use resolveOptions for resolving all the roots.

But setupPreparser is only called in node/cli.ts, so I suppose the VSCode extension is not running any preparsers anyways?

Copy link
Copy Markdown
Member

@kermanx kermanx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks~

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.

2 participants