fix(bazel): only providing stamping information if the --stamp flag is used (#39392)
Previously the volatile status file was always provided to the ng_rollup action which prevented it from being cacheable remotely. This change to only provide this file as an input when the --stamp flag is used will allow for the action to be remotely cached and prevent needing to run the action on every CI run. PR Close #39392
This commit is contained in:
parent
27a4adebcb
commit
67069ce42a
|
@ -13,7 +13,7 @@ It packages your library following the Angular Package Format, see the
|
|||
specification of this format at https://goo.gl/jB3GVv
|
||||
"""
|
||||
|
||||
load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NpmPackageInfo", "node_modules_aspect")
|
||||
load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NodeContextInfo", "NpmPackageInfo", "node_modules_aspect")
|
||||
load(
|
||||
"@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
|
||||
"PKG_NPM_ATTRS",
|
||||
|
@ -230,6 +230,9 @@ def _write_rollup_config(
|
|||
if not include_tslib:
|
||||
external.append("tslib")
|
||||
|
||||
# Whether the --stamp flag is applied in the context of the action's execution.
|
||||
stamp = ctx.attr.node_context_data[NodeContextInfo].stamp
|
||||
|
||||
# Pass external & globals through a templated config file because on Windows there is
|
||||
# an argument limit and we there might be a lot of globals which need to be passed to
|
||||
# rollup.
|
||||
|
@ -242,7 +245,7 @@ def _write_rollup_config(
|
|||
"TMPL_module_mappings": str(mappings),
|
||||
"TMPL_node_modules_root": _compute_node_modules_root(ctx),
|
||||
"TMPL_root_dir": root_dir,
|
||||
"TMPL_stamp_data": "\"%s\"" % ctx.version_file.path if ctx.version_file else "undefined",
|
||||
"TMPL_stamp_data": "\"%s\"" % ctx.version_file.path if (stamp and ctx.version_file) else "undefined",
|
||||
"TMPL_workspace_name": ctx.workspace_name,
|
||||
"TMPL_external": ", ".join(["'%s'" % e for e in external]),
|
||||
"TMPL_globals": ", ".join(["'%s': '%s'" % g for g in globals.items()]),
|
||||
|
@ -289,10 +292,13 @@ def _run_rollup(ctx, bundle_name, rollup_config, entry_point, inputs, js_output,
|
|||
# bazel rule prints nothing on success.
|
||||
args.add("--silent")
|
||||
|
||||
# Whether the --stamp flag is applied in the context of the action's execution.
|
||||
stamp = ctx.attr.node_context_data[NodeContextInfo].stamp
|
||||
|
||||
other_inputs = [rollup_config]
|
||||
if ctx.file.license_banner:
|
||||
other_inputs.append(ctx.file.license_banner)
|
||||
if ctx.version_file:
|
||||
if stamp and ctx.version_file:
|
||||
other_inputs.append(ctx.version_file)
|
||||
ctx.actions.run(
|
||||
progress_message = "ng_package: Rollup %s %s" % (bundle_name, ctx.label),
|
||||
|
|
Loading…
Reference in New Issue