@@ -96,12 +96,12 @@ js_binary(name = "sync", entry_point = "noop.js")
9696 # Collect first-party file: links in packages
9797 fp_links = {}
9898 for package_info in packages .values ():
99- name = package_info . get ( "name" )
100- version = package_info . get ( "version" )
101- deps = package_info . get ( "dependencies" )
102- resolution = package_info . get ( "resolution" )
99+ name = package_info [ "name" ]
100+ version = package_info [ "version" ]
101+ deps = package_info [ "dependencies" ]
102+ resolution = package_info [ "resolution" ]
103103 if resolution .get ("type" , None ) == "directory" :
104- dep_path = helpers .link_package (root_package , resolution . get ( "directory" ) )
104+ dep_path = helpers .link_package (root_package , resolution [ "directory" ] )
105105 dep_key = "{}+{}" .format (name , version )
106106 transitive_deps = {}
107107 for raw_package , raw_version in deps .items ():
@@ -158,7 +158,7 @@ js_binary(name = "sync", entry_point = "noop.js")
158158 transitive_deps = {}
159159 raw_deps = {}
160160 if importers .get (dep_link , False ):
161- raw_deps = importers .get (dep_link ). get ( "deps" )
161+ raw_deps = importers .get (dep_link )[ "deps" ]
162162 for raw_package , raw_version in raw_deps .items ():
163163 package_store_name = utils .package_store_name (raw_package , raw_version )
164164 dep_store_target = """"//{root_package}:{package_store_root}/{{}}/{package_store_name}".format(name)""" .format (
@@ -173,8 +173,17 @@ js_binary(name = "sync", entry_point = "noop.js")
173173
174174 for dep_store_target in transitive_deps .keys ():
175175 transitive_deps [dep_store_target ] = "," .join (transitive_deps [dep_store_target ])
176+
177+ # note this is the (first) name used to reference this package and not
178+ # necessarily the proper self-declared packge name
179+ package = dep_package
180+
181+ # rules_js using 0.0.0 to indicate local first-party packages
182+ version = "0.0.0"
183+
176184 fp_links [dep_key ] = {
177- "package" : dep_package ,
185+ "package" : package ,
186+ "version" : version ,
178187 "path" : dep_path ,
179188 "link_packages" : {},
180189 "deps" : transitive_deps ,
@@ -318,7 +327,7 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
318327 rctx_files [build_file ].append ("exports_files([\" {}\" ])" .format (resolved_json_rel_path ))
319328
320329 # the package_json.bzl for this package
321- if _import .package_info . get ( "has_bin" ) :
330+ if _import .package_info [ "has_bin" ] :
322331 if rctx .attr .generate_bzl_library_targets :
323332 rctx_files [build_file ].append ("""load("@bazel_skylib//:bzl_library.bzl", "bzl_library")""" )
324333
@@ -349,10 +358,10 @@ def npm_link_all_packages(name = "node_modules", imported_links = [], prod = Tru
349358
350359 # Generate the first-party package stores and linking of first-party packages
351360 for i , fp_link in enumerate (fp_links .values ()):
352- fp_package = fp_link . get ( "package" )
353- fp_version = fp_link . get ( "version" , "0.0.0" )
354- fp_path = fp_link . get ( "path" )
355- fp_deps = fp_link . get ( "deps" )
361+ fp_package = fp_link [ "package" ]
362+ fp_version = fp_link [ "version" ]
363+ fp_path = fp_link [ "path" ]
364+ fp_deps = fp_link [ "deps" ]
356365 fp_target = "//{}:{}" .format (
357366 fp_path ,
358367 rctx .attr .npm_package_target_name .replace ("{dirname}" , paths .basename (fp_path )),
@@ -690,8 +699,8 @@ def _generate_npm_package_locations(fp_links, npm_imports):
690699
691700 # Add first-party packages
692701 for fp_link in fp_links .values ():
693- fp_package = fp_link . get ( "package" )
694- fp_link_packages = list (fp_link . get ( "link_packages" ) .keys ())
702+ fp_package = fp_link [ "package" ]
703+ fp_link_packages = list (fp_link [ "link_packages" ] .keys ())
695704 for location in fp_link_packages :
696705 if location not in location_to_packages :
697706 location_to_packages [location ] = []
0 commit comments