Skip to content

Commit d10e17c

Browse files
authored
fix(esbuild): files not being found when building external repo (#2563)
An esbuild rule that ran fine in a local repo (eg bazel build //:my_esbuild_rule) fails when built externally (eg bazel build @other_workspace//:my_esbuild_rule). By prepending the workspace root to the bin path, the resulting base URL works correctly in both local and remote repo invocations, allowing esbuild output to be consumed by a different repo. This change fixes remote repos in Bazel 4.0.0. 3.7.0 seems to require a workspace_root.replace("external/", "") call first in order to get the correct location. So while this patch should not break anything that was not already broken, it only fixes/adds support for remote repos in 4.0+.
1 parent eb3bd7e commit d10e17c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/esbuild/helpers.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def write_jsconfig_file(ctx, path_alias_mappings):
8686
File object reference for the jsconfig file
8787
"""
8888

89-
# The package path
90-
rule_path = paths.dirname(ctx.build_file_path)
89+
# The package path, including an "external/repo_name/" prefix if the package is in
90+
# an external repo.
91+
rule_path = paths.join(ctx.label.workspace_root, paths.dirname(ctx.build_file_path))
9192

9293
# Replace all segments in the path with .. join them with "/" and postfix
9394
# it with another / to get a relative path from the build file dir

0 commit comments

Comments
 (0)