Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte: Fix Vite crashing on virtual module imports #26838

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions code/frameworks/svelte-vite/src/plugins/svelte-docgen.ts
Expand Up @@ -100,15 +100,18 @@ export async function svelteDocgen(svelteOptions: Record<string, any> = {}): Pro

let docOptions;
if (docPreprocessOptions) {
const rawSource = fs.readFileSync(resource).toString();

const { code: fileContent } = await preprocess(rawSource, docPreprocessOptions, {
filename: resource,
});
try {
const rawSource = fs.readFileSync(resource).toString();
const { code: fileContent } = await preprocess(rawSource, docPreprocessOptions, {
filename: resource,
})

docOptions = {
fileContent,
};
docOptions = {
fileContent,
}
} catch (_) {
// ignore fail due to virtual module import
}
} else {
docOptions = { filename: resource };
}
Expand Down