Skip to content

Commit

Permalink
chore: fixup load statement ordering in generated bzl (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Jun 9, 2024
1 parent c753959 commit f52cc4c
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 31 deletions.
13 changes: 9 additions & 4 deletions e2e/pnpm_lockfiles/v54/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions e2e/pnpm_lockfiles/v60/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions e2e/pnpm_lockfiles/v61/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions e2e/pnpm_lockfiles/v90/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ def generate_repository_files(rctx, pnpm_lock_label, importers, packages, patche

link_packages = [helpers.link_package(root_package, import_path) for import_path in importers.keys()]

defs_bzl_header = ["""# buildifier: disable=bzl-visibility
load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library")"""]

fp_links = {}
rctx_files = {
"BUILD.bazel": [
Expand Down Expand Up @@ -197,10 +194,6 @@ sh_binary(
"deps": transitive_deps,
}

if fp_links:
defs_bzl_header.append("""load("@aspect_rules_js//npm/private:npm_link_package_store.bzl", _npm_link_package_store = "npm_link_package_store")
load("@aspect_rules_js//npm/private:npm_package_store.bzl", _npm_package_store = "npm_package_store")""")

npm_link_packages_const = """_LINK_PACKAGES = {link_packages}""".format(link_packages = str(link_packages))

npm_link_targets_bzl = [
Expand Down Expand Up @@ -241,6 +234,7 @@ def npm_link_all_packages(name = "node_modules", imported_links = []):
),
]

defs_bzl_header = []
stores_bzl = []
links_bzl = {}
links_targets_bzl = {}
Expand Down Expand Up @@ -418,6 +412,17 @@ def npm_link_all_packages(name = "node_modules", imported_links = []):

npm_link_targets_bzl.append(""" return link_targets""")

defs_bzl_header.append("")
defs_bzl_header.append("# buildifier: disable=bzl-visibility")
defs_bzl_header.append("""load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library")""")
if fp_links:
defs_bzl_header.append("")
defs_bzl_header.append("# buildifier: disable=bzl-visibility")
defs_bzl_header.append("""load("@aspect_rules_js//npm/private:npm_link_package_store.bzl", _npm_link_package_store = "npm_link_package_store")""")
defs_bzl_header.append("")
defs_bzl_header.append("# buildifier: disable=bzl-visibility")
defs_bzl_header.append("""load("@aspect_rules_js//npm/private:npm_package_store.bzl", _npm_package_store = "npm_package_store")""")

rctx_files[rctx.attr.defs_bzl_filename] = [
"\n".join(defs_bzl_header),
"",
Expand Down
13 changes: 9 additions & 4 deletions npm/private/test/snapshots/bzlmod/npm_defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions npm/private/test/snapshots/wksp/npm_defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f52cc4c

Please sign in to comment.