From e6367e037310071af145edad867513211832bc26 Mon Sep 17 00:00:00 2001 From: hgaol Date: Mon, 13 Apr 2026 00:00:33 +0800 Subject: [PATCH] fix: resolve local plugin paths to absolute and enhance module replacement logic --- internal/cli/build.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/cli/build.go b/internal/cli/build.go index efc876e31..68820fe0e 100644 --- a/internal/cli/build.go +++ b/internal/cli/build.go @@ -140,6 +140,12 @@ func formatPlugins(plugins []string) (formatted []*pluginInfo) { info := &pluginInfo{} plugin, info.Path, _ = strings.Cut(plugin, "=") info.Name, info.Version, _ = strings.Cut(plugin, "@") + // Resolve local path to absolute since build runs in a temp directory + if len(info.Path) > 0 { + if absPath, err := filepath.Abs(info.Path); err == nil { + info.Path = absPath + } + } formatted = append(formatted, info) } return formatted @@ -185,7 +191,12 @@ func createMainGoFile(b *buildingMaterial) (err error) { for _, p := range b.plugins { // If user set a path, use it to replace the module with local path if len(p.Path) > 0 { - replacement := fmt.Sprintf("%s@%s=%s", p.Name, p.Version, p.Path) + var replacement string + if len(p.Version) > 0 { + replacement = fmt.Sprintf("%s@%s=%s", p.Name, p.Version, p.Path) + } else { + replacement = fmt.Sprintf("%s=%s", p.Name, p.Path) + } err = b.newExecCmd("go", "mod", "edit", "-replace", replacement).Run() } else if len(p.Version) > 0 { // If user specify a version, use it to get specific version of the module @@ -415,6 +426,13 @@ func copyDirEntries(sourceFs fs.FS, sourceDir, targetDir string, ignoreDir ...st if strings.HasPrefix(path, s) { return true } + // Also ignore nested occurrences, e.g. src/plugins/foo/node_modules + if strings.Contains(path, string(filepath.Separator)+s) { + return true + } + if strings.Contains(path, "/"+s) { + return true + } } return false }