@@ -56,12 +56,13 @@ def _link_mapping(label, mappings, k, v):
56
56
else :
57
57
return True
58
58
59
- def write_node_modules_manifest (ctx , extra_data = []):
59
+ def write_node_modules_manifest (ctx , extra_data = [], mnemonic = None ):
60
60
"""Writes a manifest file read by the linker, containing info about resolving runtime dependencies
61
61
62
62
Args:
63
63
ctx: starlark rule execution context
64
64
extra_data: labels to search for npm packages that need to be linked (ctx.attr.deps and ctx.attr.data will always be searched)
65
+ mnemonic: optional action mnemonic, used to differentiate module mapping files from the same rule context
65
66
"""
66
67
67
68
mappings = {}
@@ -81,7 +82,7 @@ def write_node_modules_manifest(ctx, extra_data = []):
81
82
for k , v in getattr (dep , _ASPECT_RESULT_NAME , {}).items ():
82
83
if _link_mapping (dep .label , mappings , k , v ):
83
84
# Special case for ts_library module_name for legacy behavior and for AMD name
84
- # work-around. Do not propogate tslibrary root type to runtime as it is not
85
+ # work-around. Do not propagate tslibrary root type to runtime as it is not
85
86
# needed at runtime. See comment below in _get_module_mappings for more info.
86
87
if v [0 ] == "_tslibrary" :
87
88
v = ["execroot" , v [1 ]]
@@ -90,7 +91,10 @@ def write_node_modules_manifest(ctx, extra_data = []):
90
91
91
92
# Write the result to a file, and use the magic node option --bazel_node_modules_manifest
92
93
# The launcher.sh will peel off this argument and pass it to the linker rather than the program.
93
- modules_manifest = ctx .actions .declare_file ("_%s.module_mappings.json" % ctx .label .name )
94
+ prefix = ctx .label .name
95
+ if mnemonic != None :
96
+ prefix += "_%s" % mnemonic
97
+ modules_manifest = ctx .actions .declare_file ("_%s.module_mappings.json" % prefix )
94
98
content = {
95
99
"bin" : ctx .bin_dir .path ,
96
100
"modules" : mappings ,
0 commit comments