Skip to main content

js_bundle_genrule

js_bundle_genrule is a genrule that acts on a js_bundle and provides a bunch of additional environment variables for the genrule to use.

Function Signature​

def js_bundle_genrule(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str | target_name_glob] = [],
within_view: list[str | target_name_glob] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
allow_offline_output_cache: bool = False,
always_print_stderr: bool = False,
bash: None | str = None,
bundle_name: None | str = None,
bundle_name_for_flavor: list[(str, str)] = [],
cacheable: None | bool = None,
cmd: None | str = None,
cmd_exe: None | str = None,
contacts: list[str] = [],
enable_sandbox: None | bool = None,
environment_expansion_separator: None | str = None,
has_content_based_path: bool = select({"prelude//features/apple:content_based_path_hashing_enabled": True, "DEFAULT": False}),
js_bundle: str,
labels: list[str] = [],
licenses: list[str] = [],
metadata_env_var: None | str = None,
metadata_path: None | str = None,
no_outputs_cleanup: bool = False,
remote: None | bool = None,
remote_execution_dependencies: list[dict[str, str]] = [],
repo_relative_root: bool = False,
rewrite_deps_file: bool = False,
rewrite_misc: bool = False,
rewrite_sourcemap: bool = False,
skip_resources: bool = False,
srcs: list[str] | dict[str, str] = [],
type: str = "js_bundle_genrule",
weight: None | int = None,
) -> None

Parameters​

  • name: (required)

    name of the target

  • default_target_platform: (defaults to: None)

    specifies the default target platform, used when no platforms are specified on the command line

  • target_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with a configuration

  • exec_compatible_with: (defaults to: [])

    a list of constraints that are required to be satisfied for this target to be compatible with an execution platform

  • visibility: (defaults to: [])

    a list of visibility patterns restricting what targets can depend on this one

  • within_view: (defaults to: ["PUBLIC"])

    a list of visibility patterns restricting what this target can depend on

  • metadata: (defaults to: {})

    a key-value map of metadata associated with this target

  • tests: (defaults to: [])

    a list of targets that provide tests for this one

  • modifiers: (defaults to: [])

    an array of modifiers associated with this target

  • allow_offline_output_cache: (defaults to: False)

    Enables caching of this genrule's outputs for offline builds.

    When set to True, the genrule's outputs are cached during trace builds (via buck2 debug trace-io) and restored during offline builds without re-executing the command.

    This is intended for genrules that read from the network (e.g., downloads, remote artifact fetches) which cannot execute in offline build environments where network access is restricted.

    During trace builds, outputs are copied to buck-out/offline-cache/ after successful execution. During offline builds, if all outputs exist in the offline cache, they are restored without running the genrule; otherwise the genrule executes normally (graceful fallback).

    Requires buck2.use_network_action_output_cache=true config to take effect.

    Example use case: caching network downloads in containerized offline build environments.

  • contacts: (defaults to: [])

    A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.

    contacts = [ 'Joe Sixpack', 'Erika Mustermann' ]
  • labels: (defaults to: [])

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query().

  • licenses: (defaults to: [])

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query

  • repo_relative_root: (defaults to: False)

    If true, the genrule will be executed from the project root, instead of in the genrule location in buck-out. Helps with long paths issues on windows with deeply nested directories, which will usually have long relative paths as inputs. Should eventually default to true.