Skip to content

Commit f5ab3f7

Browse files
committed
fix: properly compile entire Go module directory (final fix)
- Removed the main.go-only path that was still present - Now always compiles the entire module directory - Ensures TinyGo sees all Go files in the same package - Resolves multi-file Go component build failures definitively
1 parent 6f8a736 commit f5ab3f7

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

go/defs.bzl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,9 @@ def _compile_tinygo_module(ctx, tinygo, go_binary, wasm_opt_binary, wasm_tools,
232232
ctx.attr.world,
233233
])
234234

235-
# Find main Go file path within the module directory
236-
main_go_found = False
237-
main_go_path = None
238-
for src in ctx.files.srcs:
239-
if src.basename == "main.go":
240-
main_go_path = go_module_files.path + "/main.go"
241-
main_go_found = True
242-
break
243-
244-
if main_go_found:
245-
tinygo_args.append(main_go_path)
246-
else:
247-
# If no main.go, compile the entire module directory
248-
# This allows TinyGo to see all Go files in the package
249-
tinygo_args.append(go_module_files.path)
235+
# Always compile the entire Go module directory to include all source files
236+
# This ensures TinyGo can see all Go files in the same package, not just main.go
237+
tinygo_args.append(go_module_files.path)
250238

251239
# Validate that we have Go source files
252240
go_files = [src for src in ctx.files.srcs if src.extension == "go"]

0 commit comments

Comments
 (0)