Skip to content

Commit

Permalink
fix: don't hardlink source directories (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Mar 20, 2024
1 parent bc55306 commit f78e26c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion npm/private/npm_package_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ NpmPackageInfo = provider(
"version": "version of this npm package",
"directory": "the directory (typically a TreeArtifact) that contains the package sources",
"npm_package_store_deps": "A depset of NpmPackageStoreInfo providers from npm dependencies of the package and the packages's transitive deps to use as direct dependencies when linking with npm_link_package",
"hardlink": "internal use only",
},
)
1 change: 0 additions & 1 deletion npm/private/npm_package_internal.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def _npm_package_internal_impl(ctx):
version = ctx.attr.version,
directory = dst,
npm_package_store_deps = depset(),
hardlink = True, # always hardlink downstream
),
]

Expand Down
10 changes: 8 additions & 2 deletions npm/private/npm_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ If set, takes precendance over the package version in the NpmPackageInfo src.
- "auto": hardlinks are used for generated files already in the output tree
- "off": all files are copied
- "on": hardlinks are used for all files (not recommended)
NB: Hardlinking source files in external repositories as was done under the hood
prior to https://github.com/aspect-build/rules_js/pull/1533 may lead to flaky build
failures as reported in https://github.com/aspect-build/rules_js/issues/1412.
""",
),
"verbose": attr.bool(
Expand Down Expand Up @@ -191,13 +195,15 @@ def _npm_package_store_impl(ctx):
virtual_store_directory = src_directory
else:
virtual_store_directory = ctx.actions.declare_directory(virtual_store_directory_path)
hardlink = ctx.attr.src[NpmPackageInfo].hardlink if hasattr(ctx.attr.src[NpmPackageInfo], "hardlink") else False
copy_directory_bin_action(
ctx,
src = src_directory,
dst = virtual_store_directory,
copy_directory_bin = ctx.toolchains["@aspect_bazel_lib//lib:copy_directory_toolchain_type"].copy_directory_info.bin,
hardlink = "on" if hardlink else ctx.attr.hardlink,
# Hardlinking source files in external repositories as was done under the hood
# prior to https://github.com/aspect-build/rules_js/pull/1533 may lead to flaky build
# failures as reported in https://github.com/aspect-build/rules_js/issues/1412.
hardlink = ctx.attr.hardlink,
verbose = ctx.attr.verbose,
)

Expand Down

0 comments on commit f78e26c

Please sign in to comment.