Skip to content

Commit

Permalink
Restricts overbroad //visibility:public usages.
Browse files Browse the repository at this point in the history
`//visibility:public` actually makes the target available to any target _in any workspace_, meaning they are publicly visible to user workspaces. For most of these they were actually intended as being public _internally to `@rules_prerender`_. This updates as many targets as possible to be as restrictive as possible.

Unfortunately a decent number of these are referenced from macros and rules invoked in the user's workspace, so they need to be `//visibility:public` even when they are technically implementation details.
  • Loading branch information
dgp1130 committed Mar 9, 2023
1 parent e89209f commit c146934
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 32 deletions.
14 changes: 7 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ load("//tools/stamping:defs.bzl", "stamp_package")
load("//tools/typescript:defs.bzl", "types_only")
load("//:index.bzl", "link_prerender_component", "prerender_component")

exports_files([".npmrc"], visibility = ["//visibility:public"])
exports_files([".npmrc"], visibility = ["//:__subpackages__"])

ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_config(
name = "tsconfig_client",
src = "tsconfig.client.json",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [":tsconfig"],
)

Expand Down Expand Up @@ -50,23 +50,23 @@ npm_publish(
npm_link_package(
name = "node_modules/rules_prerender",
src = ":rules_prerender_pkg",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)
types_only(
name = "node_modules_types/rules_prerender",
dep = "//:node_modules/rules_prerender",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

npm_link_package(
name = "node_modules/@rules_prerender/declarative_shadow_dom",
src = "//packages/declarative_shadow_dom:pkg",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)
link_prerender_component(
name = "prerender_components/@rules_prerender/declarative_shadow_dom",
package = ":node_modules/@rules_prerender/declarative_shadow_dom",
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

bzl_library(
Expand Down
20 changes: 11 additions & 9 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ load(":paths_test.bzl", "paths_test_suite")
ts_project(
name = "binary",
srcs = ["binary.mts"],
# Needs to be public because this gets directly linked in the renderer entry
# point generated in the user's workspace.
visibility = ["//visibility:public"],
deps = ["//:node_modules/@types/node"],
)
Expand All @@ -29,7 +31,7 @@ jasmine_node_test(
ts_project(
name = "collections",
srcs = ["collections.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_project(
Expand All @@ -50,7 +52,7 @@ jasmine_node_test(
ts_project(
name = "formatters",
srcs = ["formatters.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_project(
Expand All @@ -71,14 +73,14 @@ jasmine_node_test(
ts_project(
name = "file_system",
srcs = ["file_system.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = ["//:node_modules/@types/node"],
)

ts_project(
name = "file_system_fake",
srcs = ["file_system_fake.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
testonly = True,
deps = [
":file_system",
Expand All @@ -89,7 +91,7 @@ ts_project(
ts_project(
name = "http",
srcs = ["http.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = ["//:node_modules/@types/node"],
)

Expand All @@ -112,7 +114,7 @@ jasmine_node_test(
bzl_library(
name = "label",
srcs = ["label.bzl"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

bzl_library(
Expand All @@ -126,7 +128,7 @@ label_test_suite(name = "label_test")
bzl_library(
name = "paths",
srcs = ["paths.bzl"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

bzl_library(
Expand All @@ -140,7 +142,7 @@ paths_test_suite(name = "paths_test")
ts_project(
name = "prerender_annotation_walker",
srcs = ["prerender_annotation_walker.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [
"//common/models:prerender_annotation",
"//:node_modules/node-html-parser",
Expand Down Expand Up @@ -168,7 +170,7 @@ jasmine_node_test(
ts_project(
name = "probably",
srcs = ["probably.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_project(
Expand Down
10 changes: 5 additions & 5 deletions common/models/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("//tools/typescript:defs.bzl", "ts_project")
ts_project(
name = "prerender_annotation",
srcs = ["prerender_annotation.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_project(
Expand All @@ -26,14 +26,14 @@ ts_project(
name = "prerender_annotation_mock",
srcs = ["prerender_annotation_mock.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [":prerender_annotation"],
)

ts_project(
name = "prerender_metadata",
srcs = ["prerender_metadata.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
)

ts_project(
Expand All @@ -55,14 +55,14 @@ ts_project(
name = "prerender_metadata_mock",
srcs = ["prerender_metadata_mock.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [":prerender_metadata"],
)

ts_project(
name = "prerender_resource",
srcs = ["prerender_resource.mts"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [":url_path"],
)

Expand Down
14 changes: 7 additions & 7 deletions common/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ts_project(
name = "binary",
srcs = ["binary.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = ["//:node_modules/@types/node"],
)

Expand All @@ -31,7 +31,7 @@ ts_project(
name = "devserver",
srcs = ["devserver.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
data = [
"//:node_modules/http-status-codes",
"//:node_modules/tree-kill",
Expand Down Expand Up @@ -110,7 +110,7 @@ ts_project(
name = "effect_fake",
srcs = ["effect_fake.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [":effects"],
)

Expand All @@ -134,7 +134,7 @@ ts_project(
name = "effect_tester",
srcs = ["effect_tester.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [
":effects",
"//:node_modules/@types/jasmine",
Expand Down Expand Up @@ -162,7 +162,7 @@ ts_project(
name = "mocks",
srcs = ["mocks.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = ["//:node_modules/@types/jasmine"],
)

Expand All @@ -185,7 +185,7 @@ ts_project(
name = "temp_dir",
srcs = ["temp_dir.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [
":effects",
"//:node_modules/@types/node",
Expand Down Expand Up @@ -234,7 +234,7 @@ ts_project(
name = "webdriver",
srcs = ["webdriver.mts"],
testonly = True,
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
data = ["//:node_modules/webdriverio"],
deps = [
":effects",
Expand Down
2 changes: 1 addition & 1 deletion tools/browsers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ custom_browser(
"//conditions:default": "chromium_local.json",
":use_debug_browsers_config": "chromium_local_debug.json",
}),
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
tags = ["native"],
environment = select({
"//conditions:default": None,
Expand Down
2 changes: 1 addition & 1 deletion tools/jasmine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "defs",
srcs = ["defs.bzl"],
visibility = ["//visibility:public"],
visibility = ["//:__subpackages__"],
deps = [
":jasmine_node_test",
":jasmine_web_test_suite",
Expand Down
2 changes: 1 addition & 1 deletion tools/publish/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(["npm_publish.sh"], visibility = ["//visibility:public"])
exports_files(["npm_publish.sh"], visibility = ["//:__subpackages__"])

bzl_library(
name = "defs",
Expand Down
2 changes: 1 addition & 1 deletion tools/stamping/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":stamp_package.bzl", "stamp_package")

exports_files(["stamp.jq"], visibility = ["//visibility:public"])
exports_files(["stamp.jq"], visibility = ["//:__subpackages__"])

bzl_library(
name = "defs",
Expand Down

0 comments on commit c146934

Please sign in to comment.