feat: new bun_build and bun_compile, extend bun_install
This commit is contained in:
@@ -344,6 +344,17 @@ def _bun_install_repository_impl(repository_ctx):
|
||||
workspace_packages = _materialize_workspace_packages(repository_ctx, package_json)
|
||||
|
||||
install_args = [str(bun_bin), "--bun", "install", "--frozen-lockfile", "--no-progress"]
|
||||
if repository_ctx.attr.production:
|
||||
install_args.append("--production")
|
||||
for omit in repository_ctx.attr.omit:
|
||||
install_args.extend(["--omit", omit])
|
||||
if repository_ctx.attr.linker:
|
||||
install_args.extend(["--linker", repository_ctx.attr.linker])
|
||||
if repository_ctx.attr.backend:
|
||||
install_args.extend(["--backend", repository_ctx.attr.backend])
|
||||
if repository_ctx.attr.ignore_scripts:
|
||||
install_args.append("--ignore-scripts")
|
||||
install_args.extend(repository_ctx.attr.install_flags)
|
||||
if repository_ctx.attr.isolated_home:
|
||||
result = repository_ctx.execute(
|
||||
install_args,
|
||||
@@ -394,6 +405,12 @@ bun_install_repository = repository_rule(
|
||||
"bun_lockfile": attr.label(mandatory = True, allow_single_file = True),
|
||||
"install_inputs": attr.label_list(allow_files = True),
|
||||
"isolated_home": attr.bool(default = True),
|
||||
"production": attr.bool(default = False),
|
||||
"omit": attr.string_list(),
|
||||
"linker": attr.string(),
|
||||
"backend": attr.string(),
|
||||
"ignore_scripts": attr.bool(default = False),
|
||||
"install_flags": attr.string_list(),
|
||||
"visible_repo_name": attr.string(),
|
||||
"bun_linux_x64": attr.label(default = "@bun_linux_x64//:bun-linux-x64/bun", allow_single_file = True),
|
||||
"bun_linux_aarch64": attr.label(default = "@bun_linux_aarch64//:bun-linux-aarch64/bun", allow_single_file = True),
|
||||
@@ -403,7 +420,18 @@ bun_install_repository = repository_rule(
|
||||
},
|
||||
)
|
||||
|
||||
def bun_install(name, package_json, bun_lockfile, install_inputs = [], isolated_home = True):
|
||||
def bun_install(
|
||||
name,
|
||||
package_json,
|
||||
bun_lockfile,
|
||||
install_inputs = [],
|
||||
isolated_home = True,
|
||||
production = False,
|
||||
omit = [],
|
||||
linker = "",
|
||||
backend = "",
|
||||
ignore_scripts = False,
|
||||
install_flags = []):
|
||||
"""Create an external repository containing installed node_modules.
|
||||
|
||||
Args:
|
||||
@@ -414,6 +442,12 @@ def bun_install(name, package_json, bun_lockfile, install_inputs = [], isolated_
|
||||
into the install context, such as patch files or auth/config files.
|
||||
isolated_home: Whether to run Bun with HOME set to the generated
|
||||
repository root for a more isolated install context.
|
||||
production: Whether to omit devDependencies during install.
|
||||
omit: Optional Bun dependency groups to omit, such as `dev` or `peer`.
|
||||
linker: Optional Bun linker strategy, such as `isolated` or `hoisted`.
|
||||
backend: Optional Bun install backend, such as `hardlink` or `copyfile`.
|
||||
ignore_scripts: Whether to skip lifecycle scripts in the project manifest.
|
||||
install_flags: Additional raw flags forwarded to `bun install`.
|
||||
|
||||
Usage (WORKSPACE):
|
||||
bun_install(
|
||||
@@ -429,5 +463,11 @@ def bun_install(name, package_json, bun_lockfile, install_inputs = [], isolated_
|
||||
bun_lockfile = bun_lockfile,
|
||||
install_inputs = install_inputs,
|
||||
isolated_home = isolated_home,
|
||||
production = production,
|
||||
omit = omit,
|
||||
linker = linker,
|
||||
backend = backend,
|
||||
ignore_scripts = ignore_scripts,
|
||||
install_flags = install_flags,
|
||||
visible_repo_name = name,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user