Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
learosema committed Sep 24, 2024
1 parent 1fecb93 commit 3d14f18
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/transforms/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const SYNTAXES = {
* @param {'html'|'css'} syntax
* @returns {Promise<string>} return the bundled resource
*/
async function bundle(inputContent, resolve, syntax) {
async function bundle(inputContent, resolve, syntax, processor) {
const includes = new Map();
let content = inputContent, matches;
const includePattern = SYNTAXES[syntax];
Expand All @@ -22,15 +22,16 @@ async function bundle(inputContent, resolve, syntax) {
const fullPath = path.join(config.dir.input, config.dir.includes, file);
try {
const content = await resolve(fullPath);
includes.set(file, content);

includes.set(file, await (await processor(content, file)).compile(data));
} catch (err) {
console.error('error processing file:', fullPath, err);
// silently fail if there is no include
includes.set(file, `<!-- html-include src="${file}" -->`);
}
}
content = content.replace(includePattern, (_, file) => {
return includes.get(file)
return includes.get(file);
});
}
}

0 comments on commit 3d14f18

Please sign in to comment.