Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.7.1
9.0.0rc3
34 changes: 31 additions & 3 deletions npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
),
)

stores_bzl.append(""" store_{i}()""".format(i = i))
stores_bzl.append(""" store_{i}()""".format(i = i))
for link_package, _link_aliases in _import.link_packages.items():
link_aliases = _link_aliases or [_import.package]

Expand Down Expand Up @@ -408,7 +408,15 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru

if stores_bzl:
npm_link_all_packages_bzl.append(""" if is_root:""")
npm_link_all_packages_bzl.extend(stores_bzl)
# Super-hacky - need to have the target start with `.aspect_rules` followed by underscore, so this fits `.aspect_rules_js`.
npm_link_all_packages_bzl.append(""" _all_stores(name = ".aspect_rules")""")

all_stores_bzl = """
def _all_stores_impl(name, visibility):
{all_stores}

_all_stores = macro(implementation = _all_stores_impl)""".format(
all_stores = "\n".join(stores_bzl))

# Start with empty link and scope targets
npm_link_all_packages_bzl.append("""
Expand Down Expand Up @@ -455,6 +463,15 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru

# Generate catch all & scoped js_library targets
npm_link_all_packages_bzl.append("""

_npm_link_all_packages(
name = name,
link_targets = link_targets,
scope_targets = scope_targets,
is_importer = is_importer,
)

def _npm_link_all_packages_impl(name, visibility, link_targets, scope_targets, is_importer):
if scope_targets:
for scope, scoped_targets in scope_targets.items():
_js_library(
Expand All @@ -470,7 +487,16 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
srcs = link_targets if link_targets else [],
tags = ["manual"],
visibility = ["//visibility:public"],
)""")
)

_npm_link_all_packages = macro(
implementation = _npm_link_all_packages_impl,
attrs = {
"link_targets": attr.label_list(configurable = False),
"scope_targets": attr.label_list_dict(configurable = False),
"is_importer": attr.bool(configurable = False),
},
)""")

npm_link_targets_bzl = _generate_npm_link_targets(links_targets)

Expand Down Expand Up @@ -509,6 +535,8 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
"\n".join(npm_link_targets_bzl),
"",
"\n\n".join(link_factories_bzl),
"",
all_stores_bzl,
])

rctx_files[_DEFS_BZL_FILENAME] = defs_bzl_contents
Expand Down
Loading