bazelbuild/rules_nodejs

//:bzl is currently broken in release archives

Kernald opened this issue ยท 5 comments

๐Ÿž bug report

Affected Rule

The issue is caused by the rule: mocked `bzl_library`

Is this a regression?

No - //:bzl was unusable in release archives < 3.1.0 because the visibility of the internal bzl files were restricted, and following #2430 (first included in 3.1.0), the visibility is fixed but references to internal tests are still listed.

Description

In the release archive, //:bzl looks like this:

bzl_library(
    name = "bzl",
    srcs = [
        "index.bzl",
        "index.for_docs.bzl",
        "providers.bzl",
        "version.bzl",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//internal/common:bzl",
        "//internal/generated_file_test:bzl",
        "//internal/js_library:bzl",
        "//internal/linker:bzl",
        "//internal/pkg_npm:bzl",
        "//internal/pkg_web:bzl",
        "//internal/providers:bzl",
        "//toolchains/node:bzl",
    ],
)

However, some of those targets (at least //internal/generated_file_test:bzl and //internal/linker:bzl) are not present in the release archive (the corresponding BUILD file just contains a single exports_files directive, not exporting any bzl_library target or file).

๐Ÿ”ฌ Minimal Reproduction

bzl_library(
    name = "bzl",
    srcs = [
        "dummy.bzl",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "@build_bazel_rules_nodejs//:bzl",
    ]
)

๐Ÿ”ฅ Exception or Error


ERROR: /home/kernald/.cache/bazel/_bazel_kernald/a724f0347869d5393045d1d679cf6b9f/external/build_bazel_rules_nodejs/BUILD.bazel:42:12: no such target '@build_bazel_rules_nodejs//internal/generated_file_test:bzl': target 'bzl' not declared in package 'internal/generated_file_test' defined by /home/kernald/.cache/bazel/_bazel_kernald/a724f0347869d5393045d1d679cf6b9f/external/build_bazel_rules_nodejs/internal/generated_file_test/BUILD and referenced by '@build_bazel_rules_nodejs//:bzl'
ERROR: /home/kernald/.cache/bazel/_bazel_kernald/a724f0347869d5393045d1d679cf6b9f/external/build_bazel_rules_nodejs/BUILD.bazel:42:12: no such target '@build_bazel_rules_nodejs//internal/linker:bzl': target 'bzl' not declared in package 'internal/linker' defined by /home/kernald/.cache/bazel/_bazel_kernald/a724f0347869d5393045d1d679cf6b9f/external/build_bazel_rules_nodejs/internal/linker/BUILD.bazel and referenced by '@build_bazel_rules_nodejs//:bzl'

๐ŸŒ Your Environment

Operating System:

  
Archlinux
  

Output of bazel version:

  
Build label: 4.1.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sat Jul 3 14:35:30 2021 (1625322930)
Build timestamp: 1625322930
Build timestamp as int: 1625322930
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
3.8.0, also tested 3.1.0 (and 3.0.0 but was blocked by #1348)
  

Anything else relevant?

We didn't add the appropriate test to ensure these bzl targets are usable, looks like. I think we just need a single bzl_library in one of the examples to reproduce that error, then we can make sure it stays fixed.

This would be a good start as it would ensure all the files listed are present in the release archive, but this would only cover half of the potential issues around this target - just defining a bzl_library target and ensuring it builds doesn't ensure all the necessary transitive dependencies are listed. Maybe we should setup stardoc on a sample?

I think for 5.0 we should just take a dependency on bazel-skylib so we can simplify things and ship the same bzl_library calls in our distro as exist in our sources.

This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?"