Skip to content

Conversation

Mivr
Copy link
Collaborator

@Mivr Mivr commented Jul 28, 2025

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): yes
  • Suggested release notes appear below: yes

feat: moved replace package to a tag class for bzlmod

Test plan

  • Updated old test case

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

aspect-workflows bot commented Jul 28, 2025

Test

All tests were cache hits

278 tests (100.0%) were fully cached saving 36s.


Test

e2e/bzlmod

All tests were cache hits

5 tests (100.0%) were fully cached saving 618ms.


Test

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 173ms.


Test

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 7s.


Test

e2e/npm_link_package

All tests were cache hits

3 tests (100.0%) were fully cached saving 407ms.


Test

e2e/npm_link_package-esm

All tests were cache hits

3 tests (100.0%) were fully cached saving 484ms.


Test

e2e/npm_link_package-rerooted

All tests were cache hits

3 tests (100.0%) were fully cached saving 536ms.


Test

e2e/npm_translate_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/npm_translate_lock_disable_hooks

All tests were cache hits

3 tests (100.0%) were fully cached saving 195ms.


Test

e2e/npm_translate_lock_empty

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 34ms.


Test

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 164ms.


Test

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 61ms.


Test

e2e/npm_translate_lock_replace_packages

1 test target passed

Targets
//:utils_test [k8-fastbuild]81ms

Total test execution time was 81ms. 3 tests (75.0%) were fully cached saving 406ms.


Test

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 95ms.


Test

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 348ms.


Test

e2e/patch_from_repo

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/pnpm_lockfiles

All tests were cache hits

67 tests (100.0%) were fully cached saving 10s.


Test

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 2s.


Test

e2e/pnpm_workspace

All tests were cache hits

15 tests (100.0%) were fully cached saving 3s.


Test

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 901ms.


Test

e2e/pnpm_workspace_rerooted

All tests were cache hits

15 tests (100.0%) were fully cached saving 5s.


Test

e2e/repo_mapping

All tests were cache hits

3 tests (100.0%) were fully cached saving 454ms.


Test

e2e/rules_foo

All tests were cache hits

2 tests (100.0%) were fully cached saving 258ms.


Test

e2e/runfiles

All tests were cache hits

1 test (100.0%) was fully cached saving 118ms.


Test

e2e/stamped_package_json

All tests were cache hits

1 test (100.0%) was fully cached saving 44ms.


Test

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 78ms.


Test

e2e/vendored_tarfile

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Test

e2e/verify_patches

All tests were cache hits

2 tests (100.0%) were fully cached saving 109ms.


Test

e2e/worker

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Test

e2e/workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Buildifier      Format

@Mivr Mivr marked this pull request as ready for review August 5, 2025 17:59
@simoViso simoViso deleted the replace-packages-extension branch August 7, 2025 15:10
@Mivr Mivr restored the replace-packages-extension branch August 11, 2025 12:18

console.log('[utils_module] All tests passed ✓');

export function testUtilsModule() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted

@Mivr Mivr force-pushed the replace-packages-extension branch from f1bc621 to ee5b4e4 Compare October 14, 2025 13:09
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "aspect_rules_js", version = "0.0.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.7.7")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

path = "../lodash_module",
)

bazel_dep(name = "platforms", version = "0.0.5")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

If you need to replace a package in a non-root module:
1. Move the npm_replace_package() call to your root MODULE.bazel file
2. Alternatively, use the replace_packages attribute in npm_translate_lock() \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably delete this suggestion since it is deprecated?


# Validate that only root modules (or isolated extensions) use npm_replace_package
for mod in module_ctx.modules:
_fail_on_non_root_overrides(module_ctx, mod, "npm_replace_package")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it easier to put this in the loop below where we're already looping for attr in mod.tags.npm_replace_package:?

attrs.pop("exclude_package_contents") # Use tag classes only for MODULE.bazel
attrs.pop("exclude_package_contents") # Use npm_exclude_package_contents tag instead

# TODO(3.0): remove replace_packages attribute in favor of npm_replace_package tag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would we do in 3.0? If the replace_packages attribute is removed I'd think there would be nothing TODO here...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants