From 68b18d8298723015de9a6e5ad782e0e38225f21d Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 25 Nov 2020 12:57:21 -0800 Subject: [PATCH] chore: remove old stamping 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 --- BUILD.bazel | 3 --- internal/pkg_npm/pkg_npm.bzl | 18 +----------------- internal/pkg_npm/test/BUILD.bazel | 5 ++++- packages/rollup/rollup_bundle.bzl | 3 --- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index fe6a9fb068..67fb6217d3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", diff --git a/internal/pkg_npm/pkg_npm.bzl b/internal/pkg_npm/pkg_npm.bzl index 0e72366cec..7626c1d885 100644 --- a/internal/pkg_npm/pkg_npm.bzl +++ b/internal/pkg_npm/pkg_npm.bzl @@ -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, @@ -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 @@ -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 diff --git a/internal/pkg_npm/test/BUILD.bazel b/internal/pkg_npm/test/BUILD.bazel index a2dfe29e02..3b33003e0a 100644 --- a/internal/pkg_npm/test/BUILD.bazel +++ b/internal/pkg_npm/test/BUILD.bazel @@ -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", ], diff --git a/packages/rollup/rollup_bundle.bzl b/packages/rollup/rollup_bundle.bzl index 474720658c..b4fb6e7527 100644 --- a/packages/rollup/rollup_bundle.bzl +++ b/packages/rollup/rollup_bundle.bzl @@ -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", }, )