pbakaus/impeccable · error · Error
Svelte-component source file not found: ${sourceFile}
Error message
Svelte-component source file not found: ${sourceFile} What it means
Thrown by resolveSourceFile when the path passes the absolute and escape guards but the resolved file does not exist on disk. This is the final existence check before the function returns the absolute path to the caller.
Source
Thrown at plugin/skills/impeccable/scripts/live/svelte-component.mjs:452
export function readManifest(manifestPath) {
const data = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
return {
...data,
manifestPath,
};
}
export function resolveSourceFile(sourceFile, cwd = process.cwd()) {
if (!sourceFile || path.isAbsolute(sourceFile)) {
throw new Error('Invalid svelte-component source file');
}
const full = path.resolve(cwd, sourceFile);
const rel = path.relative(cwd, full);
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) {
throw new Error('Svelte-component source file escapes project root');
}
if (!fs.existsSync(full)) {
throw new Error('Svelte-component source file not found: ' + sourceFile);
}
return full;
}
function appendCssToSvelteStyle(lines, cssLines) {
const closeIdx = findLastStyleCloseLine(lines);
const prepared = ['', ...cssLines.map((line) => (line.trim() === '' ? '' : ' ' + line.trimStart()))];
if (closeIdx === -1) {
return [...lines, '', '<style>', ...prepared.slice(1), '</style>'];
}
return [
...lines.slice(0, closeIdx),
...prepared,
...lines.slice(closeIdx),
];
}
function findLastStyleCloseLine(lines) {View on GitHub (pinned to d14711ae3d)
Solutions
- Verify the file path spelling and that it exists relative to cwd.
- If the component is generated by the adapter, ensure the generation step ran before resolveSourceFile is called.
- Update the manifest's sourceFile field to the current file location.
Example fix
// before: file does not exist yet
resolveSourceFile('src/lib/Comp.svelte', cwd);
// after: ensure the file exists first
if (!fs.existsSync(path.join(cwd, 'src/lib/Comp.svelte'))) {
throw new Error('generate the component before resolving');
}
resolveSourceFile('src/lib/Comp.svelte', cwd); Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
function sourceFileExists(sourceFile, cwd) {
return fs.existsSync(path.resolve(cwd, sourceFile));
} Type guard
function isExistingSource(sourceFile, cwd) {
return typeof sourceFile === 'string' && !path.isAbsolute(sourceFile) && fs.existsSync(path.resolve(cwd, sourceFile));
} Try / catch
try {
resolveSourceFile(sourceFile, cwd);
} catch (err) {
if (err.message.startsWith('Svelte-component source file not found')) {
await generateComponent(sourceFile);
resolveSourceFile(sourceFile, cwd);
} else throw err;
} Prevention
- Generate components before resolving their source path.
- Keep manifest sourceFile fields in sync after renames via a repo-wide grep.
- Add an existence assertion in manifest-loading code to fail earlier.
When it happens
Trigger: Calling resolveSourceFile('src/lib/Missing.svelte', cwd) where the file has not been created yet, was deleted, or is misspelled.
Common situations: Component not yet generated, a typo in the manifest sourceFile field, or a stale manifest pointing at a renamed/removed file.
Related errors
- Invalid svelte-component source file
- Svelte-component source file escapes project root
- Invalid svelte-component source file
- Svelte-component source file not found: ${sourceFile}
- writeSnapshot requires a slug
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/75853a5b1e781e4c.
Report an issue: GitHub.