diff --git a/packages/ui-templates/lib/render.ts b/packages/ui-templates/lib/render.ts
index 27f0c3bf4a..cc62479a78 100644
--- a/packages/ui-templates/lib/render.ts
+++ b/packages/ui-templates/lib/render.ts
@@ -27,7 +27,11 @@ export const RenderPlugin = () => {
const critters = new Critters({ path: outputDir })
const htmlFiles = await globby(resolve(outputDir, 'templates/**/*.html'), { absolute: true })
- const templateExports = []
+ const templateExports: Array<{
+ exportName: string
+ templateName: string
+ types: string
+ }> = []
for (const fileName of htmlFiles) {
// Infer template name
@@ -48,9 +52,13 @@ export const RenderPlugin = () => {
html = html.replace(/]*>/g, '')
// Inline SVGs
- const svgSources = Array.from(html.matchAll(/src="([^"]+)"|url([^)]+)/g))
- .map(m => m[1])
- .filter(src => src?.match(/\.svg$/))
+ const svgSources: string[] = []
+
+ for (const [src] of html.matchAll(/src="([^"]+)"|url([^)]+)/g)) {
+ if (src?.match(/\.svg$/)) {
+ svgSources.push(src)
+ }
+ }
for (const src of svgSources) {
const svg = readFileSync(join(outputDir, src), 'utf-8')
@@ -59,8 +67,13 @@ export const RenderPlugin = () => {
}
// Inline our scripts
- const scriptSources = Array.from(html.matchAll(/