Skip to content

Commit

Permalink
fix: fencing for npm packages (#946)
Browse files Browse the repository at this point in the history
and other minor cleanups
  • Loading branch information
gregmagolan committed Jul 30, 2019
1 parent 7708858 commit 780dfb4
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 21 deletions.
1 change: 0 additions & 1 deletion internal/rollup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ nodejs_binary(
)

# BEGIN-INTERNAL
# TODO: switch to npm_bazel_jasmine
# buildozer: disable=load-on-top
# buildozer: disable=out-of-order-load
load("@npm_bazel_jasmine//:index.from_src.bzl", "jasmine_node_test")
Expand Down
3 changes: 2 additions & 1 deletion packages/jasmine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS", "npm_package")

# Copy the license from our parent folder
genrule(
Expand Down Expand Up @@ -40,6 +40,7 @@ npm_package(
srcs = [
"@npm_bazel_jasmine//:package_contents",
],
replacements = COMMON_REPLACEMENTS,
vendor_external = [
"npm_bazel_jasmine",
],
Expand Down
18 changes: 18 additions & 0 deletions packages/jasmine/src/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# BEGIN-INTERNAL
# Parts of this BUILD file only necessary when building from source.
# The generated `@bazel/jasmine` npm package contains a trimmed BUILD file using INTERNAL fences.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "js_library")

Expand Down Expand Up @@ -31,3 +48,4 @@ js_library(
],
module_name = "@bazel/jasmine",
)
# END-INTERNAL
6 changes: 4 additions & 2 deletions packages/karma/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# BEGIN-INTERNAL
# Parts of this BUILD file only necessary when building from source.
# The generated `@bazel/karma` npm package contains a trimmed BUILD file using # INTERNAL fences.
# The generated `@bazel/karma` npm package contains a trimmed BUILD file using INTERNAL fences.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@npm_bazel_typescript//:index.from_src.bzl", "ts_library")
Expand Down Expand Up @@ -82,4 +82,6 @@ filegroup(
)

# END-INTERNAL
exports_files(["karma.conf.js"])
exports_files([
"karma.conf.js",
])
3 changes: 2 additions & 1 deletion packages/labs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS", "npm_package")

exports_files(["tsconfig.json"])

Expand All @@ -14,6 +14,7 @@ npm_package(
srcs = [
"@npm_bazel_labs//:package_contents",
],
replacements = COMMON_REPLACEMENTS,
vendor_external = [
"npm_bazel_labs",
],
Expand Down
4 changes: 4 additions & 0 deletions packages/labs/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# BEGIN-INTERNAL
# Parts of this BUILD file only necessary when building from source.
# The generated `@bazel/labs` npm package contains a trimmed BUILD file using INTERNAL fences.
package(default_visibility = ["//visibility:public"])

exports_files(["tsconfig.json"])
Expand All @@ -25,3 +28,4 @@ filegroup(
"//webpack:package_contents",
],
)
# END-INTERNAL
2 changes: 2 additions & 0 deletions packages/labs/src/webpack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.

# BEGIN-INTERNAL
# Parts of this BUILD file only necessary when building from source.
# The generated `@bazel/labs` npm package contains a trimmed BUILD file using INTERNAL fences.
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@npm_bazel_typescript//:index.from_src.bzl", "ts_library")

Expand Down
3 changes: 2 additions & 1 deletion packages/protractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS", "npm_package")

# Copy the license from our parent folder
genrule(
Expand Down Expand Up @@ -40,6 +40,7 @@ npm_package(
srcs = [
"@npm_bazel_protractor//:package_contents",
],
replacements = COMMON_REPLACEMENTS,
vendor_external = [
"npm_bazel_protractor",
],
Expand Down
3 changes: 2 additions & 1 deletion packages/stylus/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS", "npm_package")

# Copy the license from our parent folder
genrule(
Expand Down Expand Up @@ -40,6 +40,7 @@ npm_package(
srcs = [
"@npm_bazel_stylus//:package_contents",
],
replacements = COMMON_REPLACEMENTS,
vendor_external = [
"npm_bazel_stylus",
],
Expand Down
4 changes: 4 additions & 0 deletions packages/stylus/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# BEGIN-INTERNAL
# Parts of this BUILD file only necessary when building from source.
# The generated `@bazel/stylus` npm package contains a trimmed BUILD file using INTERNAL fences.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(default_visibility = ["//visibility:public"])
Expand All @@ -33,3 +36,4 @@ filegroup(
"package.json",
],
)
# END-INTERNAL
2 changes: 1 addition & 1 deletion packages/typescript/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
load("@npm_bazel_typescript//:index.bzl", "TYPESCRIPT_REPLACEMENTS")
load(":replacements.bzl", "TYPESCRIPT_REPLACEMENTS")

genrule(
name = "copy_LICENSE",
Expand Down
30 changes: 30 additions & 0 deletions packages/typescript/replacements.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Replacements for @npm/typescript package
"""

load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS")

TYPESCRIPT_REPLACEMENTS = dict(
COMMON_REPLACEMENTS,
**{
# This BEGIN-DEV fencing is required as files pulled in from
# @build_bazel_rules_typescript//:npm_bazel_typescript_package
# use this alternate fencing
"(#|\/\/)\\s+BEGIN-DEV-ONLY[\\w\W]+?(#|\/\/)\\s+END-DEV-ONLY": "",
# This file gets vendored into our repo
"@build_bazel_rules_typescript//internal:common": "//internal:common",
}
)
13 changes: 0 additions & 13 deletions packages/typescript/src/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Users should not load files under "/internal"
"""

load("@build_bazel_rules_nodejs//:defs.bzl", "COMMON_REPLACEMENTS")
load("//:version.bzl", _check_rules_typescript_version = "check_rules_typescript_version")
load("//internal:build_defs.bzl", _ts_library = "ts_library_macro")
load("//internal:ts_config.bzl", _ts_config = "ts_config")
Expand All @@ -32,15 +31,3 @@ ts_config = _ts_config
ts_devserver = _ts_devserver
ts_proto_library = _ts_proto_library
# If adding rules here also add to index.docs.bzl

TYPESCRIPT_REPLACEMENTS = dict(
COMMON_REPLACEMENTS,
**{
# This BEGIN-DEV fencing is required as files pulled in from
# @build_bazel_rules_typescript//:npm_bazel_typescript_package
# use this alternate fencing
"(#|\/\/)\\s+BEGIN-DEV-ONLY[\\w\W]+?(#|\/\/)\\s+END-DEV-ONLY": "",
# This file gets vendored into our repo
"@build_bazel_rules_typescript//internal:common": "//internal:common",
}
)

0 comments on commit 780dfb4

Please sign in to comment.