Skip to content

Commit

Permalink
fix(builtin): don't include external files when pkg_npm is in root pa…
Browse files Browse the repository at this point in the history
…ckage (#1677)

This logic assumed that package_path was non-empty, but when a pkg_npm rule appears in the workspace root, package_path will be empty string and the startswith guard has no effect.

Fixes #1499
  • Loading branch information
alexeagle authored Mar 2, 2020
1 parent a7f07d1 commit 8089999
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ install_bazel_dependencies()
git_repository(
name = "build_bazel_rules_typescript",
commit = "10a5a86885f95ab788fd841ade47b6a16e0c13d6",
patches = ["//:rules_typescript.patch"],
remote = "http://github.com/bazelbuild/rules_typescript.git",
shallow_since = "1582757372 -0800",
)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg_npm/pkg_npm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ PKG_NPM_OUTPUTS = {
def _filter_out_external_files(ctx, files, package_path):
result = []
for file in files:
if file.short_path.startswith(package_path):
if file.short_path.startswith(package_path) and not file.short_path.startswith("../"):
result.append(file.path)
else:
for v in ctx.attr.vendor_external:
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("//third_party/github.com/bazelbuild/bazel-skylib:rules/copy_file.bzl", "co

# We reach inside the @bazel/typescript npm package to grab this one .js file
# This avoids a complex refactoring where we extract that .ts file from tsc_wrapped to a common library
_worker_path = "external/build_bazel_rules_typescript/internal/tsc_wrapped/worker"
_worker_path = "internal/tsc_wrapped/worker"

# Copy the proto file to a matching third_party/... nested directory
# so the runtime require() statements still work
Expand Down
12 changes: 12 additions & 0 deletions rules_typescript.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff BUILD.bazel BUILD.bazel
index 3a519c5..6121ef6 100644
--- BUILD.bazel
+++ BUILD.bazel
@@ -38,6 +38,7 @@ pkg_npm(
"//internal:npm_package_assets",
"//third_party/github.com/bazelbuild/bazel/src/main/protobuf:npm_package_assets",
],
+ vendor_external = ["build_bazel_rules_typescript"],
visibility = ["//visibility:public"],
deps = [
"//devserver:devserver-darwin",

0 comments on commit 8089999

Please sign in to comment.