feat(bazel): expose explicit mapping from closure to devmode files (#36262)

This feature is aimed at development tooling that has to translate
production build inputs into their devmode equivalent. The current
process involves guessing the devmode filename based on string
replace patterns. This allows consuming build actions to read the
known mappings instead.

This is a change in anticipation of an update to the general
Typescript build rules to consume this data.

PR Close #36262
This commit is contained in:
Jan Krems 2020-03-26 08:20:22 -07:00 committed by Misko Hevery
parent ae4f81cbab
commit 7ac166ff08
1 changed files with 12 additions and 3 deletions

View File

@ -184,6 +184,7 @@ def _expected_outs(ctx):
devmode_js_files = []
closure_js_files = []
declaration_files = []
transpilation_infos = []
summary_files = []
metadata_files = []
@ -233,11 +234,18 @@ def _expected_outs(ctx):
continue
filter_summaries = ctx.attr.filter_summaries
closure_js = [f.replace(".js", ".mjs") for f in devmode_js if not filter_summaries or not f.endswith(".ngsummary.js")]
declarations = [f.replace(".js", ".d.ts") for f in devmode_js]
devmode_js_files += [ctx.actions.declare_file(basename + ext) for ext in devmode_js]
closure_js_files += [ctx.actions.declare_file(basename + ext) for ext in closure_js]
for devmode_ext in devmode_js:
devmode_js_file = ctx.actions.declare_file(basename + devmode_ext)
devmode_js_files.append(devmode_js_file)
if not filter_summaries or not devmode_ext.endswith(".ngsummary.js"):
closure_ext = devmode_ext.replace(".js", ".mjs")
closure_js_file = ctx.actions.declare_file(basename + closure_ext)
closure_js_files.append(closure_js_file)
transpilation_infos.append(struct(closure = closure_js_file, devmode = devmode_js_file))
declaration_files += [ctx.actions.declare_file(basename + ext) for ext in declarations]
summary_files += [ctx.actions.declare_file(basename + ext) for ext in summaries]
if not _is_bazel():
@ -280,6 +288,7 @@ def _expected_outs(ctx):
closure_js = closure_js_files,
devmode_js = devmode_js_files,
declarations = declaration_files,
transpilation_infos = transpilation_infos,
summaries = summary_files,
metadata = metadata_files,
dts_bundles = dts_bundles,