Skip to content

Commit

Permalink
chore: remove old stamping
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- rollup_bundle config_file no longer has substitutions from a "bazel_stamp_file" - use bazel_version_file instead
- pkg_npm no longer has replace_with_version attribute, use substitutions instead

Fixes #2158
  • Loading branch information
Alex Eagle authored and alexeagle committed Nov 25, 2020
1 parent 2c73fde commit 68b18d8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
3 changes: 0 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ pkg_npm(
"BUILD.bazel",
"LICENSE",
],
# Don't replace the default 0.0.0-PLACEHOLDER for this pkg_npm since
# we are packaging up the packager itself and this replacement will break it
replace_with_version = "",
substitutions = COMMON_REPLACEMENTS,
deps = [
"//internal:package_contents",
Expand Down
18 changes: 1 addition & 17 deletions internal/pkg_npm/pkg_npm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ PKG_NPM_ATTRS = dict(NODE_CONTEXT_ATTRS, **{
"package_name": attr.string(
doc = """Optional package_name that this npm package may be imported as.""",
),
"replace_with_version": attr.string(
doc = """DEPRECATED: use substitutions instead.
`replace_with_version = "my_version_placeholder"` is just syntax sugar for
`substitutions = {"my_version_placeholder": "{BUILD_SCM_VERSION}"}`.
Follow this deprecation at https://github.com/bazelbuild/rules_nodejs/issues/2158
""",
default = "0.0.0-PLACEHOLDER",
),
"srcs": attr.label_list(
doc = """Files inside this directory which are simply copied into the package.""",
allow_files = True,
Expand Down Expand Up @@ -196,12 +186,6 @@ def create_package(ctx, deps_files, nested_packages):
# current package unless explicitely specified.
filtered_deps_sources = _filter_out_external_files(ctx, deps_files, package_path)

# Back-compat for the replace_with_version stamping
# see https://github.com/bazelbuild/rules_nodejs/issues/2158 for removal
substitutions = dict(**ctx.attr.substitutions)
if stamp and ctx.attr.replace_with_version:
substitutions.setdefault(ctx.attr.replace_with_version, "{BUILD_SCM_VERSION}")

args = ctx.actions.args()
inputs = ctx.files.srcs + deps_files + nested_packages

Expand All @@ -213,7 +197,7 @@ def create_package(ctx, deps_files, nested_packages):
args.add(ctx.genfiles_dir.path)
args.add_joined(filtered_deps_sources, join_with = ",", omit_if_empty = False)
args.add_joined([p.path for p in nested_packages], join_with = ",", omit_if_empty = False)
args.add(substitutions)
args.add(ctx.attr.substitutions)

if stamp:
# The version_file is an undocumented attribute of the ctx that lets us read the volatile-status.txt file
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg_npm/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ pkg_npm(
],
nested_packages = [":dependent_pkg"],
node_context_data = ":force_stamp",
substitutions = {"replace_me": "replaced"},
substitutions = {
"0.0.0-PLACEHOLDER": "{BUILD_SCM_VERSION}",
"replace_me": "replaced",
},
vendor_external = [
"internal_npm_package_test_vendored_external",
],
Expand Down
3 changes: 0 additions & 3 deletions packages/rollup/rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ def _rollup_bundle(ctx):
output = config,
substitutions = {
"bazel_info_file": "\"%s\"" % ctx.info_file.path if stamp else "undefined",
# Back-compat: we used to replace a variable "bazel_stamp_file"
# Remove in 3.0: https://github.com/bazelbuild/rules_nodejs/issues/2158
"bazel_stamp_file": "\"%s\"" % ctx.version_file.path if stamp else "undefined",
"bazel_version_file": "\"%s\"" % ctx.version_file.path if stamp else "undefined",
},
)
Expand Down

0 comments on commit 68b18d8

Please sign in to comment.