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

fix: skip template files that are not transpiled #245

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/renderer/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ function importComponent(filepath: string): Promise<TemplateFunction | undefined
if (require === undefined) resolve(undefined);

let componentPath = filepath;

// Check if the file exists
if (!fs.existsSync(componentPath)) {
// If transpiled version doesn't exist, try the original version
const originalPath = componentPath.replace('__transpiled', 'template');
if (fs.existsSync(originalPath)) {
componentPath = originalPath;
} else {
throw new Error(`Neither transpiled nor original template file found: ${filepath}`);
}
}

// Check if the transpiled version of the template file exists and skip if doesn't
//It is needed to support case where you have template files, but do not want to use them yet
if (!fs.existsSync(componentPath)) resolve(undefined);

// Remove from cache and require the file
delete require.cache[require.resolve(componentPath)];
Expand Down
Loading