From 369d6cc4d8f80c8253859ce14c2c674191fa8263 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 30 Sep 2024 17:02:24 +0800 Subject: [PATCH] fix sui dynamic components import bug --- sui/core/build.go | 8 ++++++++ sui/core/parser.go | 1 + 2 files changed, 9 insertions(+) diff --git a/sui/core/build.go b/sui/core/build.go index 6119b2251..d9b08aafe 100644 --- a/sui/core/build.go +++ b/sui/core/build.go @@ -284,6 +284,14 @@ func (page *Page) parseDynamics(ctx *BuildContext, sel *goquery.Selection) { return } ctx.addJitComponent(route) + + // This is a temprary solution, we will refactor this later + // Some components are not used in the page, but they are used in the script + // So we need to add them to the components + // But this solution is not perfect, it will cause import the unnecessary components, just ignore it. + // Add to the imports + name := fmt.Sprintf("comp_%s", strings.ReplaceAll(route, "/", "_")) + ctx.components[name] = route }) } diff --git a/sui/core/parser.go b/sui/core/parser.go index aa46f20f9..d7532834e 100644 --- a/sui/core/parser.go +++ b/sui/core/parser.go @@ -901,6 +901,7 @@ func (parser *TemplateParser) show(sel *goquery.Selection) { // sel.SetAttr("style", style) } +// Tidy the template by removing the parsed attributes func (parser *TemplateParser) Tidy(s *goquery.Selection) { s.Contents().Each(func(i int, child *goquery.Selection) {