Skip to content

Commit

Permalink
fix: skip template files that are not transpiled (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg committed Aug 21, 2024
1 parent 47eb245 commit f26f04e
Showing 1 changed file with 4 additions and 11 deletions.
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

0 comments on commit f26f04e

Please sign in to comment.