Skip to content

Commit 27f4c32

Browse files
committed
refactor: remove unnecessary collection of "all" deps
1 parent 17a0001 commit 27f4c32

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

npm/private/npm_translate_lock_generate.bzl

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
317317
if link_package not in links_bzl:
318318
links_bzl[link_package] = []
319319
if link_package not in links_targets_bzl:
320-
links_targets_bzl[link_package] = {"all": [], "prod": [], "dev": []}
320+
links_targets_bzl[link_package] = {"prod": [], "dev": []}
321321

322322
# for each alias of this package
323323
for link_alias in link_aliases:
@@ -332,8 +332,6 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
332332

333333
append_stmt_base = """link_targets.append(":{{}}/{alias}".format(name))""".format(alias = link_alias)
334334

335-
links_targets_bzl[link_package]["all"].append(" " + append_stmt_base)
336-
337335
importer_deps = importer_deps_map.get(link_package, {})
338336
dep_info = importer_deps.get(link_alias, {})
339337
is_dev = dep_info.get("dev", False)
@@ -412,12 +410,10 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
412410
# Add first-party package links to npm_link_targets for each package that uses it
413411
for fp_link_package in fp_link_packages:
414412
if fp_link_package not in links_targets_bzl:
415-
links_targets_bzl[fp_link_package] = {"all": [], "prod": [], "dev": []}
413+
links_targets_bzl[fp_link_package] = {"prod": [], "dev": []}
416414

417415
fp_append_stmt = """link_targets.append(":{{}}/{pkg}".format(name))""".format(pkg = fp_package)
418416

419-
links_targets_bzl[fp_link_package]["all"].append(" " + fp_append_stmt)
420-
421417
if link_type == "link_dev_packages":
422418
links_targets_bzl[fp_link_package]["dev"].append(" " + fp_append_stmt)
423419
else:
@@ -432,20 +428,17 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
432428
pkg = link_package,
433429
))
434430

435-
if lists["prod"] or lists["dev"]:
436-
npm_link_targets_bzl.append(""" if prod:""")
437-
if lists["prod"]:
438-
npm_link_targets_bzl.extend(lists["prod"])
439-
else:
440-
npm_link_targets_bzl.append(""" pass""")
431+
npm_link_targets_bzl.append(""" if prod:""")
432+
if lists["prod"]:
433+
npm_link_targets_bzl.extend(lists["prod"])
434+
else:
435+
npm_link_targets_bzl.append(""" pass""")
441436

442-
npm_link_targets_bzl.append(""" if dev:""")
443-
if lists["dev"]:
444-
npm_link_targets_bzl.extend(lists["dev"])
445-
else:
446-
npm_link_targets_bzl.append(""" pass""")
437+
npm_link_targets_bzl.append(""" if dev:""")
438+
if lists["dev"]:
439+
npm_link_targets_bzl.extend(lists["dev"])
447440
else:
448-
npm_link_targets_bzl.extend(lists["all"])
441+
npm_link_targets_bzl.append(""" pass""")
449442

450443
first_link = False
451444

@@ -496,13 +489,11 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
496489
# Also add the first-party package to its own package context
497490
fp_package_path = fp_link.get("path")
498491
if fp_package_path and fp_package_path not in links_targets_bzl:
499-
links_targets_bzl[fp_package_path] = {"all": [], "prod": [], "dev": []}
492+
links_targets_bzl[fp_package_path] = {"prod": [], "dev": []}
500493

501494
if fp_package_path:
502495
append_stmt_self = """link_targets.append(":{{}}/{pkg}".format(name))""".format(pkg = fp_package)
503496

504-
links_targets_bzl[fp_package_path]["all"].append(" " + append_stmt_self)
505-
506497
if link_type == "link_dev_packages":
507498
links_targets_bzl[fp_package_path]["dev"].append(" " + append_stmt_self)
508499
else:
@@ -512,12 +503,10 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
512503
# Also add this first-party package to npm_link_targets for packages that use it
513504
for fp_link_package in fp_link_packages:
514505
if fp_link_package not in links_targets_bzl:
515-
links_targets_bzl[fp_link_package] = {"all": [], "prod": [], "dev": []}
506+
links_targets_bzl[fp_link_package] = {"prod": [], "dev": []}
516507

517508
fp_append_stmt = """link_targets.append(":{{}}/{pkg}".format(name))""".format(pkg = fp_package)
518509

519-
links_targets_bzl[fp_link_package]["all"].append(" " + fp_append_stmt)
520-
521510
if link_type == "link_dev_packages":
522511
links_targets_bzl[fp_link_package]["dev"].append(" " + fp_append_stmt)
523512
else:

0 commit comments

Comments
 (0)