@@ -8,6 +8,7 @@ load("@aspect_bazel_lib//lib:utils.bzl", "to_label")
88load ("@aspect_bazel_lib//lib:jq.bzl" , "jq" )
99load ("@aspect_bazel_lib//lib:copy_to_directory.bzl" , "copy_to_directory" )
1010load ("//tools:link_package_json_to_tarballs.bzl" , "link_package_json_to_tarballs" )
11+ load ("//:constants.bzl" , "RELEASE_ENGINES_NODE" , "RELEASE_ENGINES_NPM" , "RELEASE_ENGINES_YARN" )
1112
1213_DEFAULT_TSCONFIG = "//:tsconfig-build.json"
1314_DEFAULT_TSCONFIG_TEST = "//:tsconfig-test.json"
@@ -64,12 +65,16 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
6465
6566 visibility = kwargs .pop ("visibility" , None )
6667
67- common_substitutions = dict (kwargs .pop ("substitutions" , {}))
68- substitutions = dict (common_substitutions , ** {
69- "0.0.0-PLACEHOLDER" : "0.0.0" ,
70- })
71- stamped_substitutions = dict (common_substitutions , ** {
68+ NPM_PACKAGE_SUBSTITUTIONS = {
69+ # Version of the local package being built, generated via the `--workspace_status_command` flag.
7270 "0.0.0-PLACEHOLDER" : "{BUILD_SCM_VERSION}" ,
71+ "0.0.0-ENGINES-NODE" : RELEASE_ENGINES_NODE ,
72+ "0.0.0-ENGINES-NPM" : RELEASE_ENGINES_NPM ,
73+ "0.0.0-ENGINES-YARN" : RELEASE_ENGINES_YARN ,
74+ }
75+
76+ NO_STAMP_PACKAGE_SUBSTITUTIONS = dict (NPM_PACKAGE_SUBSTITUTIONS , ** {
77+ "0.0.0-PLACEHOLDER" : "0.0.0" ,
7378 })
7479
7580 deps = kwargs .pop ("deps" , [])
@@ -161,8 +166,8 @@ def pkg_npm(name, pkg_deps = [], use_prodmode_output = False, **kwargs):
161166 package_name = None ,
162167 validate = False ,
163168 substitutions = select ({
164- "//:stamp" : stamped_substitutions ,
165- "//conditions:default" : substitutions ,
169+ "//:stamp" : NPM_PACKAGE_SUBSTITUTIONS ,
170+ "//conditions:default" : NO_STAMP_PACKAGE_SUBSTITUTIONS ,
166171 }),
167172 visibility = visibility ,
168173 nested_packages = ["package" ],
0 commit comments