From cce48d7c9fb2815fabb4b0091b615cec01b93b69 Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 19 Jul 2024 22:42:24 -0700 Subject: [PATCH] fix(npm): expost package_json.bzl and resolved.json for each package alias --- e2e/pnpm_lockfiles/MODULE.bazel | 4 +- e2e/pnpm_lockfiles/base/package.json | 1 + e2e/pnpm_lockfiles/lockfile-test.bzl | 6 +- e2e/pnpm_lockfiles/v54/pnpm-lock.yaml | 10 ++ e2e/pnpm_lockfiles/v54/snapshots/defs.bzl | 49 +++++----- .../v54/snapshots/is-odd-v0_resolved.json | 1 + .../v54/snapshots/rollup3_package_json.bzl | 76 ++++++++++++++++ e2e/pnpm_lockfiles/v60/pnpm-lock.yaml | 23 +++-- e2e/pnpm_lockfiles/v60/snapshots/defs.bzl | 53 ++++++----- .../v60/snapshots/is-odd-v0_resolved.json | 1 + .../v60/snapshots/rollup3_package_json.bzl | 76 ++++++++++++++++ e2e/pnpm_lockfiles/v61/pnpm-lock.yaml | 23 +++-- e2e/pnpm_lockfiles/v61/snapshots/defs.bzl | 53 ++++++----- .../v61/snapshots/is-odd-v0_resolved.json | 1 + .../v61/snapshots/rollup3_package_json.bzl | 76 ++++++++++++++++ e2e/pnpm_lockfiles/v90/pnpm-lock.yaml | 12 +++ e2e/pnpm_lockfiles/v90/snapshots/defs.bzl | 49 +++++----- .../v90/snapshots/is-odd-v0_resolved.json | 1 + .../v90/snapshots/rollup3_package_json.bzl | 76 ++++++++++++++++ npm/private/npm_translate_lock_generate.bzl | 91 +++++++++++-------- 20 files changed, 538 insertions(+), 144 deletions(-) create mode 100644 e2e/pnpm_lockfiles/v54/snapshots/is-odd-v0_resolved.json create mode 100644 e2e/pnpm_lockfiles/v54/snapshots/rollup3_package_json.bzl create mode 100644 e2e/pnpm_lockfiles/v60/snapshots/is-odd-v0_resolved.json create mode 100644 e2e/pnpm_lockfiles/v60/snapshots/rollup3_package_json.bzl create mode 100644 e2e/pnpm_lockfiles/v61/snapshots/is-odd-v0_resolved.json create mode 100644 e2e/pnpm_lockfiles/v61/snapshots/rollup3_package_json.bzl create mode 100644 e2e/pnpm_lockfiles/v90/snapshots/is-odd-v0_resolved.json create mode 100644 e2e/pnpm_lockfiles/v90/snapshots/rollup3_package_json.bzl diff --git a/e2e/pnpm_lockfiles/MODULE.bazel b/e2e/pnpm_lockfiles/MODULE.bazel index 44b661e120..9ecb74f082 100644 --- a/e2e/pnpm_lockfiles/MODULE.bazel +++ b/e2e/pnpm_lockfiles/MODULE.bazel @@ -67,6 +67,8 @@ npm = use_extension( # Dep with bin entries etc "lock-%s__rollup__2.14.0" % version, "lock-%s__rollup__2.14.0__links" % version, + "lock-%s__rollup__3.29.4" % version, + "lock-%s__rollup__3.29.4__links" % version, # Dep only referenced via npm: should have the real package name in the repo name "lock-%s__at_types_sizzle__2.3.8" % version, @@ -79,7 +81,7 @@ npm = use_extension( # Deep with many peers "lock-%s__at_rollup_plugin-typescript__8.2.1__%s" % ( version, - "ommloj5qql5ba6x5wuiluawhoi" if version == "v54" else "1662662592", + "ommloj5qql5ba6x5wuiluawhoi" if version == "v54" else "1662662592" if version == "v90" else "1813138439", ), # Dep with patch diff --git a/e2e/pnpm_lockfiles/base/package.json b/e2e/pnpm_lockfiles/base/package.json index c2f5eb47b9..dea7fe93db 100644 --- a/e2e/pnpm_lockfiles/base/package.json +++ b/e2e/pnpm_lockfiles/base/package.json @@ -9,6 +9,7 @@ "hello": "https://gitpkg.vercel.app/EqualMa/gitpkg-hello/packages/hello", "jsonify": "https://github.com/aspect-build/test-packages/releases/download/0.0.0/@foo-jsonify-0.0.0.tgz", "rollup": "2.14.0", + "rollup3": "npm:rollup@3.29.4", "rollup-plugin-with-peers": "npm:@rollup/plugin-typescript@8.2.1", "tslib": "^2.6.3", "typescript": "^5.4.5", diff --git a/e2e/pnpm_lockfiles/lockfile-test.bzl b/e2e/pnpm_lockfiles/lockfile-test.bzl index cd741852af..87429aa0b7 100644 --- a/e2e/pnpm_lockfiles/lockfile-test.bzl +++ b/e2e/pnpm_lockfiles/lockfile-test.bzl @@ -21,10 +21,12 @@ BZL_FILES = { # resolved.json reference "is-odd_resolved.json": "@REPO_NAME//VERSION:is-odd/resolved.json", + "is-odd-v0_resolved.json": "@REPO_NAME//VERSION:is-odd-v0/resolved.json", - # hasBin, optional deps, deps + # hasBin, optional deps, deps and across versions "rollup_links_defs.bzl": "@REPO_NAME__rollup__2.14.0__links//:defs.bzl", "rollup_package_json.bzl": "@REPO_NAME__rollup__2.14.0//VERSION:package_json.bzl", + "rollup3_package_json.bzl": "@REPO_NAME__rollup__3.29.4//VERSION:package_json.bzl", } def lockfile_test(name = None): @@ -95,7 +97,7 @@ def lockfile_test(name = None): # npm: alias to a package that has many peers ":node_modules/rollup-plugin-with-peers", # underlying repo for the many-peers package - "@%s__at_rollup_plugin-typescript__8.2.1__%s//:pkg" % (lock_repo, "ommloj5qql5ba6x5wuiluawhoi" if lock_version == "v54" else "1662662592"), + "@%s__at_rollup_plugin-typescript__8.2.1__%s//:pkg" % (lock_repo, "ommloj5qql5ba6x5wuiluawhoi" if lock_version == "v54" else "1662662592" if lock_version == "v90" else "1813138439"), # uuv 'hasBin' ":node_modules/uvu", diff --git a/e2e/pnpm_lockfiles/v54/pnpm-lock.yaml b/e2e/pnpm_lockfiles/v54/pnpm-lock.yaml index 70ab2004c5..d65837d39f 100644 --- a/e2e/pnpm_lockfiles/v54/pnpm-lock.yaml +++ b/e2e/pnpm_lockfiles/v54/pnpm-lock.yaml @@ -43,6 +43,7 @@ importers: meaning-of-life: 1.0.0 rollup: 2.14.0 rollup-plugin-with-peers: npm:@rollup/plugin-typescript@8.2.1 + rollup3: npm:rollup@3.29.4 tslib: ^2.6.3 typescript: 5.5.2 uvu: 0.5.6 @@ -66,6 +67,7 @@ importers: meaning-of-life: 1.0.0_o3deharooos255qt5xdujc3cuq rollup: 2.14.0 rollup-plugin-with-peers: /@rollup/plugin-typescript/8.2.1_ommloj5qql5ba6x5wuiluawhoi + rollup3: /rollup/3.29.4 tslib: 2.6.3 typescript: 5.5.2 uvu: 0.5.6 @@ -343,6 +345,14 @@ packages: fsevents: 2.3.3 dev: false + /rollup/3.29.4: + resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.3 + dev: false + /sade/1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} diff --git a/e2e/pnpm_lockfiles/v54/snapshots/defs.bzl b/e2e/pnpm_lockfiles/v54/snapshots/defs.bzl index a33fba47eb..faaa8e4c8b 100644 --- a/e2e/pnpm_lockfiles/v54/snapshots/defs.bzl +++ b/e2e/pnpm_lockfiles/v54/snapshots/defs.bzl @@ -47,17 +47,18 @@ load("@@aspect_rules_js~~npm~lock-__path-parse__1.0.7__links//:defs load("@@aspect_rules_js~~npm~lock-__picomatch__2.3.1__links//:defs.bzl", store_44 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__resolve__1.22.8__links//:defs.bzl", store_45 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__rollup__2.14.0__links//:defs.bzl", link_46 = "npm_link_imported_package_store", store_46 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_47 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_48 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_49 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_50 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_51 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_52 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_53 = "npm_link_imported_package_store", store_53 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_54 = "npm_link_imported_package_store", store_54 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_56 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_57 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__rollup__3.29.4__links//:defs.bzl", link_47 = "npm_link_imported_package_store", store_47 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_48 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_49 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_50 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_51 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_52 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_53 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_54 = "npm_link_imported_package_store", store_54 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_57 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_58 = "npm_imported_package_store") # buildifier: disable=bzl-visibility load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library") @@ -136,17 +137,18 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): store_44(name = "{}/picomatch".format(name)) store_45(name = "{}/resolve".format(name)) store_46(name = "{}/rollup".format(name)) - store_47(name = "{}/sade".format(name)) - store_48(name = "{}/string-width".format(name)) + store_47(name = "{}/rollup".format(name)) + store_48(name = "{}/sade".format(name)) store_49(name = "{}/string-width".format(name)) - store_50(name = "{}/strip-ansi".format(name)) + store_50(name = "{}/string-width".format(name)) store_51(name = "{}/strip-ansi".format(name)) - store_52(name = "{}/supports-preserve-symlinks-flag".format(name)) - store_53(name = "{}/tslib".format(name)) - store_54(name = "{}/typescript".format(name)) - store_55(name = "{}/uvu".format(name)) - store_56(name = "{}/wrap-ansi".format(name)) + store_52(name = "{}/strip-ansi".format(name)) + store_53(name = "{}/supports-preserve-symlinks-flag".format(name)) + store_54(name = "{}/tslib".format(name)) + store_55(name = "{}/typescript".format(name)) + store_56(name = "{}/uvu".format(name)) store_57(name = "{}/wrap-ansi".format(name)) + store_58(name = "{}/wrap-ansi".format(name)) if link: if bazel_package == "": link_4(name = "{}/@aspect-test/a".format(name)) @@ -198,11 +200,13 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_46(name = "{}/rollup".format(name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) - link_53(name = "{}/tslib".format(name)) + link_47(name = "{}/rollup3".format(name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) + link_54(name = "{}/tslib".format(name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) - link_54(name = "{}/typescript".format(name)) + link_55(name = "{}/typescript".format(name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) - link_55(name = "{}/uvu".format(name)) + link_56(name = "{}/uvu".format(name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) if is_root: @@ -399,6 +403,7 @@ def npm_link_targets(name = "node_modules", package = None): link_targets.append("//{}:{}/is-odd-alias".format(bazel_package, name)) link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) diff --git a/e2e/pnpm_lockfiles/v54/snapshots/is-odd-v0_resolved.json b/e2e/pnpm_lockfiles/v54/snapshots/is-odd-v0_resolved.json new file mode 100644 index 0000000000..d39e89cb3c --- /dev/null +++ b/e2e/pnpm_lockfiles/v54/snapshots/is-odd-v0_resolved.json @@ -0,0 +1 @@ +{"$schema":"https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock","integrity":"sha512-3RKAybrJxq3zCUC+TJ5Ao0sBsbacAT3OBeNVcCbsQsHUC70qWK2R4JsIvax4OTjeGWnB8FumAWATUtS1jd+KYw==","version":"0.1.0"} \ No newline at end of file diff --git a/e2e/pnpm_lockfiles/v54/snapshots/rollup3_package_json.bzl b/e2e/pnpm_lockfiles/v54/snapshots/rollup3_package_json.bzl new file mode 100644 index 0000000000..cd6bb8d79a --- /dev/null +++ b/e2e/pnpm_lockfiles/v54/snapshots/rollup3_package_json.bzl @@ -0,0 +1,76 @@ +"@generated by @aspect_rules_js//npm/private:npm_import.bzl for npm package rollup@3.29.4" + +load("@aspect_bazel_lib//lib:directory_path.bzl", _directory_path = "directory_path") +load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary", _js_run_binary = "js_run_binary", _js_test = "js_test") + +def _rollup_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = "%s__js_binary" % name, + entry_point = ":%s__entry_point" % name, + data = ["@//:{}".format(store_target_name)], + include_npm = kwargs.pop("include_npm", False), + tags = ["manual"], + ) + _js_run_binary( + name = name, + tool = ":%s__js_binary" % name, + mnemonic = kwargs.pop("mnemonic", "Rollup"), + **kwargs + ) + +def _rollup_test_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_test( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def _rollup_binary_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def rollup(name, **kwargs): + _rollup_internal(name, "node_modules", **kwargs) + +def rollup_test(name, **kwargs): + _rollup_test_internal(name, "node_modules", **kwargs) + +def rollup_binary(name, **kwargs): + _rollup_binary_internal(name, "node_modules", **kwargs) + +def bin_factory(link_root_name): + # bind link_root_name using lambdas + return struct( + rollup = lambda name, **kwargs: _rollup_internal(name, link_root_name = link_root_name, **kwargs), + rollup_test = lambda name, **kwargs: _rollup_test_internal(name, link_root_name = link_root_name, **kwargs), + rollup_binary = lambda name, **kwargs: _rollup_binary_internal(name, link_root_name = link_root_name, **kwargs), + rollup_path = "dist/bin/rollup", + ) + +bin = bin_factory("node_modules") diff --git a/e2e/pnpm_lockfiles/v60/pnpm-lock.yaml b/e2e/pnpm_lockfiles/v60/pnpm-lock.yaml index 877281dc86..9a51c50f31 100644 --- a/e2e/pnpm_lockfiles/v60/pnpm-lock.yaml +++ b/e2e/pnpm_lockfiles/v60/pnpm-lock.yaml @@ -77,7 +77,10 @@ importers: version: 2.14.0 rollup-plugin-with-peers: specifier: npm:@rollup/plugin-typescript@8.2.1 - version: /@rollup/plugin-typescript@8.2.1(rollup@2.14.0)(tslib@2.6.3)(typescript@5.5.2) + version: /@rollup/plugin-typescript@8.2.1(rollup@3.29.4)(tslib@2.6.3)(typescript@5.5.2) + rollup3: + specifier: npm:rollup@3.29.4 + version: /rollup@3.29.4 tslib: specifier: ^2.6.3 version: 2.6.3 @@ -185,7 +188,7 @@ packages: wrap-ansi-cjs: /wrap-ansi@7.0.0 dev: false - /@rollup/plugin-typescript@8.2.1(rollup@2.14.0)(tslib@2.6.3)(typescript@5.5.2): + /@rollup/plugin-typescript@8.2.1(rollup@3.29.4)(tslib@2.6.3)(typescript@5.5.2): resolution: {integrity: sha512-Qd2E1pleDR4bwyFxqbjt4eJf+wB0UKVMLc7/BAFDGVdAXQMCsD4DUv5/7/ww47BZCYxWtJqe1Lo0KVNswBJlRw==} engines: {node: '>=8.0.0'} peerDependencies: @@ -193,14 +196,14 @@ packages: tslib: '*' typescript: '>=3.7.0' dependencies: - '@rollup/pluginutils': 3.1.0(rollup@2.14.0) + '@rollup/pluginutils': 3.1.0(rollup@3.29.4) resolve: 1.22.8 - rollup: 2.14.0 + rollup: 3.29.4 tslib: 2.6.3 typescript: 5.5.2 dev: false - /@rollup/pluginutils@3.1.0(rollup@2.14.0): + /@rollup/pluginutils@3.1.0(rollup@3.29.4): resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} engines: {node: '>= 8.0.0'} peerDependencies: @@ -209,7 +212,7 @@ packages: '@types/estree': registry.npmjs.org/@types/estree@0.0.39 estree-walker: 1.0.1 picomatch: 2.3.1 - rollup: 2.14.0 + rollup: 3.29.4 dev: false /ansi-regex@5.0.1: @@ -376,6 +379,14 @@ packages: fsevents: 2.3.3 dev: false + /rollup@3.29.4: + resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.3 + dev: false + /sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} diff --git a/e2e/pnpm_lockfiles/v60/snapshots/defs.bzl b/e2e/pnpm_lockfiles/v60/snapshots/defs.bzl index ddce6c27e6..26a09642e5 100644 --- a/e2e/pnpm_lockfiles/v60/snapshots/defs.bzl +++ b/e2e/pnpm_lockfiles/v60/snapshots/defs.bzl @@ -12,8 +12,8 @@ load("@@aspect_rules_js~~npm~lock-__at_aspect-test_d__2.0.0__at_asp load("@@aspect_rules_js~~npm~lock-__at_aspect-test_e__1.0.0__links//:defs.bzl", link_9 = "npm_link_imported_package_store", store_9 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_foo_jsonify__at_github.com_aspect-build_test-packages_releases_download_0.0.0_at_foo-jsonify-0.0.0.tgz__links//:defs.bzl", link_10 = "npm_link_imported_package_store", store_10 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_isaacs_cliui__8.0.2__links//:defs.bzl", link_11 = "npm_link_imported_package_store", store_11 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__at_rollup_plugin-typescript__8.2.1__1662662592__links//:defs.bzl", link_12 = "npm_link_imported_package_store", store_12 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__at_rollup_pluginutils__3.1.0__rollup_2.14.0__links//:defs.bzl", store_13 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__at_rollup_plugin-typescript__8.2.1__1813138439__links//:defs.bzl", link_12 = "npm_link_imported_package_store", store_12 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__at_rollup_pluginutils__3.1.0__rollup_3.29.4__links//:defs.bzl", store_13 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_archiver__5.3.1__links//:defs.bzl", link_14 = "npm_link_imported_package_store", store_14 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_estree__0.0.39__links//:defs.bzl", store_15 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_glob__8.1.0__links//:defs.bzl", store_16 = "npm_imported_package_store") @@ -48,17 +48,18 @@ load("@@aspect_rules_js~~npm~lock-__path-parse__1.0.7__links//:defs load("@@aspect_rules_js~~npm~lock-__picomatch__2.3.1__links//:defs.bzl", store_45 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__resolve__1.22.8__links//:defs.bzl", store_46 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__rollup__2.14.0__links//:defs.bzl", link_47 = "npm_link_imported_package_store", store_47 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_48 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_49 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_50 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_51 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_52 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_53 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_54 = "npm_link_imported_package_store", store_54 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_57 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__rollup__3.29.4__links//:defs.bzl", link_48 = "npm_link_imported_package_store", store_48 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_49 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_50 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_51 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_52 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_53 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_54 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_57 = "npm_link_imported_package_store", store_57 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_59 = "npm_imported_package_store") # buildifier: disable=bzl-visibility load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library") @@ -138,17 +139,18 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): store_45(name = "{}/picomatch".format(name)) store_46(name = "{}/resolve".format(name)) store_47(name = "{}/rollup".format(name)) - store_48(name = "{}/sade".format(name)) - store_49(name = "{}/string-width".format(name)) + store_48(name = "{}/rollup".format(name)) + store_49(name = "{}/sade".format(name)) store_50(name = "{}/string-width".format(name)) - store_51(name = "{}/strip-ansi".format(name)) + store_51(name = "{}/string-width".format(name)) store_52(name = "{}/strip-ansi".format(name)) - store_53(name = "{}/supports-preserve-symlinks-flag".format(name)) - store_54(name = "{}/tslib".format(name)) - store_55(name = "{}/typescript".format(name)) - store_56(name = "{}/uvu".format(name)) - store_57(name = "{}/wrap-ansi".format(name)) + store_53(name = "{}/strip-ansi".format(name)) + store_54(name = "{}/supports-preserve-symlinks-flag".format(name)) + store_55(name = "{}/tslib".format(name)) + store_56(name = "{}/typescript".format(name)) + store_57(name = "{}/uvu".format(name)) store_58(name = "{}/wrap-ansi".format(name)) + store_59(name = "{}/wrap-ansi".format(name)) if link: if bazel_package == "": link_4(name = "{}/@aspect-test/a".format(name)) @@ -203,11 +205,13 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_47(name = "{}/rollup".format(name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) - link_54(name = "{}/tslib".format(name)) + link_48(name = "{}/rollup3".format(name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) + link_55(name = "{}/tslib".format(name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) - link_55(name = "{}/typescript".format(name)) + link_56(name = "{}/typescript".format(name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) - link_56(name = "{}/uvu".format(name)) + link_57(name = "{}/uvu".format(name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) if is_root: @@ -405,6 +409,7 @@ def npm_link_targets(name = "node_modules", package = None): link_targets.append("//{}:{}/is-odd-alias".format(bazel_package, name)) link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) diff --git a/e2e/pnpm_lockfiles/v60/snapshots/is-odd-v0_resolved.json b/e2e/pnpm_lockfiles/v60/snapshots/is-odd-v0_resolved.json new file mode 100644 index 0000000000..d39e89cb3c --- /dev/null +++ b/e2e/pnpm_lockfiles/v60/snapshots/is-odd-v0_resolved.json @@ -0,0 +1 @@ +{"$schema":"https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock","integrity":"sha512-3RKAybrJxq3zCUC+TJ5Ao0sBsbacAT3OBeNVcCbsQsHUC70qWK2R4JsIvax4OTjeGWnB8FumAWATUtS1jd+KYw==","version":"0.1.0"} \ No newline at end of file diff --git a/e2e/pnpm_lockfiles/v60/snapshots/rollup3_package_json.bzl b/e2e/pnpm_lockfiles/v60/snapshots/rollup3_package_json.bzl new file mode 100644 index 0000000000..cd6bb8d79a --- /dev/null +++ b/e2e/pnpm_lockfiles/v60/snapshots/rollup3_package_json.bzl @@ -0,0 +1,76 @@ +"@generated by @aspect_rules_js//npm/private:npm_import.bzl for npm package rollup@3.29.4" + +load("@aspect_bazel_lib//lib:directory_path.bzl", _directory_path = "directory_path") +load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary", _js_run_binary = "js_run_binary", _js_test = "js_test") + +def _rollup_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = "%s__js_binary" % name, + entry_point = ":%s__entry_point" % name, + data = ["@//:{}".format(store_target_name)], + include_npm = kwargs.pop("include_npm", False), + tags = ["manual"], + ) + _js_run_binary( + name = name, + tool = ":%s__js_binary" % name, + mnemonic = kwargs.pop("mnemonic", "Rollup"), + **kwargs + ) + +def _rollup_test_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_test( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def _rollup_binary_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def rollup(name, **kwargs): + _rollup_internal(name, "node_modules", **kwargs) + +def rollup_test(name, **kwargs): + _rollup_test_internal(name, "node_modules", **kwargs) + +def rollup_binary(name, **kwargs): + _rollup_binary_internal(name, "node_modules", **kwargs) + +def bin_factory(link_root_name): + # bind link_root_name using lambdas + return struct( + rollup = lambda name, **kwargs: _rollup_internal(name, link_root_name = link_root_name, **kwargs), + rollup_test = lambda name, **kwargs: _rollup_test_internal(name, link_root_name = link_root_name, **kwargs), + rollup_binary = lambda name, **kwargs: _rollup_binary_internal(name, link_root_name = link_root_name, **kwargs), + rollup_path = "dist/bin/rollup", + ) + +bin = bin_factory("node_modules") diff --git a/e2e/pnpm_lockfiles/v61/pnpm-lock.yaml b/e2e/pnpm_lockfiles/v61/pnpm-lock.yaml index 37e7e404dc..4686618f8e 100644 --- a/e2e/pnpm_lockfiles/v61/pnpm-lock.yaml +++ b/e2e/pnpm_lockfiles/v61/pnpm-lock.yaml @@ -81,7 +81,10 @@ importers: version: 2.14.0 rollup-plugin-with-peers: specifier: npm:@rollup/plugin-typescript@8.2.1 - version: /@rollup/plugin-typescript@8.2.1(rollup@2.14.0)(tslib@2.6.3)(typescript@5.5.2) + version: /@rollup/plugin-typescript@8.2.1(rollup@3.29.4)(tslib@2.6.3)(typescript@5.5.2) + rollup3: + specifier: npm:rollup@3.29.4 + version: /rollup@3.29.4 tslib: specifier: ^2.6.3 version: 2.6.3 @@ -189,7 +192,7 @@ packages: wrap-ansi-cjs: /wrap-ansi@7.0.0 dev: false - /@rollup/plugin-typescript@8.2.1(rollup@2.14.0)(tslib@2.6.3)(typescript@5.5.2): + /@rollup/plugin-typescript@8.2.1(rollup@3.29.4)(tslib@2.6.3)(typescript@5.5.2): resolution: {integrity: sha512-Qd2E1pleDR4bwyFxqbjt4eJf+wB0UKVMLc7/BAFDGVdAXQMCsD4DUv5/7/ww47BZCYxWtJqe1Lo0KVNswBJlRw==} engines: {node: '>=8.0.0'} peerDependencies: @@ -197,14 +200,14 @@ packages: tslib: '*' typescript: '>=3.7.0' dependencies: - '@rollup/pluginutils': 3.1.0(rollup@2.14.0) + '@rollup/pluginutils': 3.1.0(rollup@3.29.4) resolve: 1.22.8 - rollup: 2.14.0 + rollup: 3.29.4 tslib: 2.6.3 typescript: 5.5.2 dev: false - /@rollup/pluginutils@3.1.0(rollup@2.14.0): + /@rollup/pluginutils@3.1.0(rollup@3.29.4): resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} engines: {node: '>= 8.0.0'} peerDependencies: @@ -213,7 +216,7 @@ packages: '@types/estree': registry.npmjs.org/@types/estree@0.0.39 estree-walker: 1.0.1 picomatch: 2.3.1 - rollup: 2.14.0 + rollup: 3.29.4 dev: false /ansi-regex@5.0.1: @@ -380,6 +383,14 @@ packages: fsevents: 2.3.3 dev: false + /rollup@3.29.4: + resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.3 + dev: false + /sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} diff --git a/e2e/pnpm_lockfiles/v61/snapshots/defs.bzl b/e2e/pnpm_lockfiles/v61/snapshots/defs.bzl index ddce6c27e6..26a09642e5 100644 --- a/e2e/pnpm_lockfiles/v61/snapshots/defs.bzl +++ b/e2e/pnpm_lockfiles/v61/snapshots/defs.bzl @@ -12,8 +12,8 @@ load("@@aspect_rules_js~~npm~lock-__at_aspect-test_d__2.0.0__at_asp load("@@aspect_rules_js~~npm~lock-__at_aspect-test_e__1.0.0__links//:defs.bzl", link_9 = "npm_link_imported_package_store", store_9 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_foo_jsonify__at_github.com_aspect-build_test-packages_releases_download_0.0.0_at_foo-jsonify-0.0.0.tgz__links//:defs.bzl", link_10 = "npm_link_imported_package_store", store_10 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_isaacs_cliui__8.0.2__links//:defs.bzl", link_11 = "npm_link_imported_package_store", store_11 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__at_rollup_plugin-typescript__8.2.1__1662662592__links//:defs.bzl", link_12 = "npm_link_imported_package_store", store_12 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__at_rollup_pluginutils__3.1.0__rollup_2.14.0__links//:defs.bzl", store_13 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__at_rollup_plugin-typescript__8.2.1__1813138439__links//:defs.bzl", link_12 = "npm_link_imported_package_store", store_12 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__at_rollup_pluginutils__3.1.0__rollup_3.29.4__links//:defs.bzl", store_13 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_archiver__5.3.1__links//:defs.bzl", link_14 = "npm_link_imported_package_store", store_14 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_estree__0.0.39__links//:defs.bzl", store_15 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__at_types_glob__8.1.0__links//:defs.bzl", store_16 = "npm_imported_package_store") @@ -48,17 +48,18 @@ load("@@aspect_rules_js~~npm~lock-__path-parse__1.0.7__links//:defs load("@@aspect_rules_js~~npm~lock-__picomatch__2.3.1__links//:defs.bzl", store_45 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__resolve__1.22.8__links//:defs.bzl", store_46 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__rollup__2.14.0__links//:defs.bzl", link_47 = "npm_link_imported_package_store", store_47 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_48 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_49 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_50 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_51 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_52 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_53 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_54 = "npm_link_imported_package_store", store_54 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_57 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__rollup__3.29.4__links//:defs.bzl", link_48 = "npm_link_imported_package_store", store_48 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_49 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_50 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_51 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_52 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_53 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_54 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_57 = "npm_link_imported_package_store", store_57 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_59 = "npm_imported_package_store") # buildifier: disable=bzl-visibility load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library") @@ -138,17 +139,18 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): store_45(name = "{}/picomatch".format(name)) store_46(name = "{}/resolve".format(name)) store_47(name = "{}/rollup".format(name)) - store_48(name = "{}/sade".format(name)) - store_49(name = "{}/string-width".format(name)) + store_48(name = "{}/rollup".format(name)) + store_49(name = "{}/sade".format(name)) store_50(name = "{}/string-width".format(name)) - store_51(name = "{}/strip-ansi".format(name)) + store_51(name = "{}/string-width".format(name)) store_52(name = "{}/strip-ansi".format(name)) - store_53(name = "{}/supports-preserve-symlinks-flag".format(name)) - store_54(name = "{}/tslib".format(name)) - store_55(name = "{}/typescript".format(name)) - store_56(name = "{}/uvu".format(name)) - store_57(name = "{}/wrap-ansi".format(name)) + store_53(name = "{}/strip-ansi".format(name)) + store_54(name = "{}/supports-preserve-symlinks-flag".format(name)) + store_55(name = "{}/tslib".format(name)) + store_56(name = "{}/typescript".format(name)) + store_57(name = "{}/uvu".format(name)) store_58(name = "{}/wrap-ansi".format(name)) + store_59(name = "{}/wrap-ansi".format(name)) if link: if bazel_package == "": link_4(name = "{}/@aspect-test/a".format(name)) @@ -203,11 +205,13 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_47(name = "{}/rollup".format(name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) - link_54(name = "{}/tslib".format(name)) + link_48(name = "{}/rollup3".format(name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) + link_55(name = "{}/tslib".format(name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) - link_55(name = "{}/typescript".format(name)) + link_56(name = "{}/typescript".format(name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) - link_56(name = "{}/uvu".format(name)) + link_57(name = "{}/uvu".format(name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) if is_root: @@ -405,6 +409,7 @@ def npm_link_targets(name = "node_modules", package = None): link_targets.append("//{}:{}/is-odd-alias".format(bazel_package, name)) link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) diff --git a/e2e/pnpm_lockfiles/v61/snapshots/is-odd-v0_resolved.json b/e2e/pnpm_lockfiles/v61/snapshots/is-odd-v0_resolved.json new file mode 100644 index 0000000000..d39e89cb3c --- /dev/null +++ b/e2e/pnpm_lockfiles/v61/snapshots/is-odd-v0_resolved.json @@ -0,0 +1 @@ +{"$schema":"https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock","integrity":"sha512-3RKAybrJxq3zCUC+TJ5Ao0sBsbacAT3OBeNVcCbsQsHUC70qWK2R4JsIvax4OTjeGWnB8FumAWATUtS1jd+KYw==","version":"0.1.0"} \ No newline at end of file diff --git a/e2e/pnpm_lockfiles/v61/snapshots/rollup3_package_json.bzl b/e2e/pnpm_lockfiles/v61/snapshots/rollup3_package_json.bzl new file mode 100644 index 0000000000..cd6bb8d79a --- /dev/null +++ b/e2e/pnpm_lockfiles/v61/snapshots/rollup3_package_json.bzl @@ -0,0 +1,76 @@ +"@generated by @aspect_rules_js//npm/private:npm_import.bzl for npm package rollup@3.29.4" + +load("@aspect_bazel_lib//lib:directory_path.bzl", _directory_path = "directory_path") +load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary", _js_run_binary = "js_run_binary", _js_test = "js_test") + +def _rollup_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = "%s__js_binary" % name, + entry_point = ":%s__entry_point" % name, + data = ["@//:{}".format(store_target_name)], + include_npm = kwargs.pop("include_npm", False), + tags = ["manual"], + ) + _js_run_binary( + name = name, + tool = ":%s__js_binary" % name, + mnemonic = kwargs.pop("mnemonic", "Rollup"), + **kwargs + ) + +def _rollup_test_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_test( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def _rollup_binary_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def rollup(name, **kwargs): + _rollup_internal(name, "node_modules", **kwargs) + +def rollup_test(name, **kwargs): + _rollup_test_internal(name, "node_modules", **kwargs) + +def rollup_binary(name, **kwargs): + _rollup_binary_internal(name, "node_modules", **kwargs) + +def bin_factory(link_root_name): + # bind link_root_name using lambdas + return struct( + rollup = lambda name, **kwargs: _rollup_internal(name, link_root_name = link_root_name, **kwargs), + rollup_test = lambda name, **kwargs: _rollup_test_internal(name, link_root_name = link_root_name, **kwargs), + rollup_binary = lambda name, **kwargs: _rollup_binary_internal(name, link_root_name = link_root_name, **kwargs), + rollup_path = "dist/bin/rollup", + ) + +bin = bin_factory("node_modules") diff --git a/e2e/pnpm_lockfiles/v90/pnpm-lock.yaml b/e2e/pnpm_lockfiles/v90/pnpm-lock.yaml index 19e96c4b62..8ca629e445 100644 --- a/e2e/pnpm_lockfiles/v90/pnpm-lock.yaml +++ b/e2e/pnpm_lockfiles/v90/pnpm-lock.yaml @@ -79,6 +79,9 @@ importers: rollup-plugin-with-peers: specifier: npm:@rollup/plugin-typescript@8.2.1 version: '@rollup/plugin-typescript@8.2.1(rollup@2.14.0)(tslib@2.6.3)(typescript@5.5.2)' + rollup3: + specifier: npm:rollup@3.29.4 + version: rollup@3.29.4 tslib: specifier: ^2.6.3 version: 2.6.3 @@ -332,6 +335,11 @@ packages: engines: {node: '>=10.0.0'} hasBin: true + rollup@3.29.4: + resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} @@ -542,6 +550,10 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + rollup@3.29.4: + optionalDependencies: + fsevents: 2.3.3 + sade@1.8.1: dependencies: mri: 1.2.0 diff --git a/e2e/pnpm_lockfiles/v90/snapshots/defs.bzl b/e2e/pnpm_lockfiles/v90/snapshots/defs.bzl index 61f3b1d641..57dac03f78 100644 --- a/e2e/pnpm_lockfiles/v90/snapshots/defs.bzl +++ b/e2e/pnpm_lockfiles/v90/snapshots/defs.bzl @@ -48,17 +48,18 @@ load("@@aspect_rules_js~~npm~lock-__path-parse__1.0.7__links//:defs load("@@aspect_rules_js~~npm~lock-__picomatch__2.3.1__links//:defs.bzl", store_45 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__resolve__1.22.8__links//:defs.bzl", store_46 = "npm_imported_package_store") load("@@aspect_rules_js~~npm~lock-__rollup__2.14.0__links//:defs.bzl", link_47 = "npm_link_imported_package_store", store_47 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_48 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_49 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_50 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_51 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_52 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_53 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_54 = "npm_link_imported_package_store", store_54 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_57 = "npm_imported_package_store") -load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__rollup__3.29.4__links//:defs.bzl", link_48 = "npm_link_imported_package_store", store_48 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__sade__1.8.1__links//:defs.bzl", store_49 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__4.2.3__links//:defs.bzl", store_50 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__string-width__5.1.2__links//:defs.bzl", store_51 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__6.0.1__links//:defs.bzl", store_52 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__strip-ansi__7.1.0__links//:defs.bzl", store_53 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__supports-preserve-symlinks-flag__1.0.0__links//:defs.bzl", store_54 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__tslib__2.6.3__links//:defs.bzl", link_55 = "npm_link_imported_package_store", store_55 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__typescript__5.5.2__links//:defs.bzl", link_56 = "npm_link_imported_package_store", store_56 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__uvu__0.5.6__links//:defs.bzl", link_57 = "npm_link_imported_package_store", store_57 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__7.0.0__links//:defs.bzl", store_58 = "npm_imported_package_store") +load("@@aspect_rules_js~~npm~lock-__wrap-ansi__8.1.0__links//:defs.bzl", store_59 = "npm_imported_package_store") # buildifier: disable=bzl-visibility load("@aspect_rules_js//js:defs.bzl", _js_library = "js_library") @@ -138,17 +139,18 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): store_45(name = "{}/picomatch".format(name)) store_46(name = "{}/resolve".format(name)) store_47(name = "{}/rollup".format(name)) - store_48(name = "{}/sade".format(name)) - store_49(name = "{}/string-width".format(name)) + store_48(name = "{}/rollup".format(name)) + store_49(name = "{}/sade".format(name)) store_50(name = "{}/string-width".format(name)) - store_51(name = "{}/strip-ansi".format(name)) + store_51(name = "{}/string-width".format(name)) store_52(name = "{}/strip-ansi".format(name)) - store_53(name = "{}/supports-preserve-symlinks-flag".format(name)) - store_54(name = "{}/tslib".format(name)) - store_55(name = "{}/typescript".format(name)) - store_56(name = "{}/uvu".format(name)) - store_57(name = "{}/wrap-ansi".format(name)) + store_53(name = "{}/strip-ansi".format(name)) + store_54(name = "{}/supports-preserve-symlinks-flag".format(name)) + store_55(name = "{}/tslib".format(name)) + store_56(name = "{}/typescript".format(name)) + store_57(name = "{}/uvu".format(name)) store_58(name = "{}/wrap-ansi".format(name)) + store_59(name = "{}/wrap-ansi".format(name)) if link: if bazel_package == "": link_4(name = "{}/@aspect-test/a".format(name)) @@ -203,11 +205,13 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_47(name = "{}/rollup".format(name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) - link_54(name = "{}/tslib".format(name)) + link_48(name = "{}/rollup3".format(name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) + link_55(name = "{}/tslib".format(name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) - link_55(name = "{}/typescript".format(name)) + link_56(name = "{}/typescript".format(name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) - link_56(name = "{}/uvu".format(name)) + link_57(name = "{}/uvu".format(name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) if is_root: @@ -405,6 +409,7 @@ def npm_link_targets(name = "node_modules", package = None): link_targets.append("//{}:{}/is-odd-alias".format(bazel_package, name)) link_targets.append("//{}:{}/meaning-of-life".format(bazel_package, name)) link_targets.append("//{}:{}/rollup".format(bazel_package, name)) + link_targets.append("//{}:{}/rollup3".format(bazel_package, name)) link_targets.append("//{}:{}/tslib".format(bazel_package, name)) link_targets.append("//{}:{}/typescript".format(bazel_package, name)) link_targets.append("//{}:{}/uvu".format(bazel_package, name)) diff --git a/e2e/pnpm_lockfiles/v90/snapshots/is-odd-v0_resolved.json b/e2e/pnpm_lockfiles/v90/snapshots/is-odd-v0_resolved.json new file mode 100644 index 0000000000..d39e89cb3c --- /dev/null +++ b/e2e/pnpm_lockfiles/v90/snapshots/is-odd-v0_resolved.json @@ -0,0 +1 @@ +{"$schema":"https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock","integrity":"sha512-3RKAybrJxq3zCUC+TJ5Ao0sBsbacAT3OBeNVcCbsQsHUC70qWK2R4JsIvax4OTjeGWnB8FumAWATUtS1jd+KYw==","version":"0.1.0"} \ No newline at end of file diff --git a/e2e/pnpm_lockfiles/v90/snapshots/rollup3_package_json.bzl b/e2e/pnpm_lockfiles/v90/snapshots/rollup3_package_json.bzl new file mode 100644 index 0000000000..cd6bb8d79a --- /dev/null +++ b/e2e/pnpm_lockfiles/v90/snapshots/rollup3_package_json.bzl @@ -0,0 +1,76 @@ +"@generated by @aspect_rules_js//npm/private:npm_import.bzl for npm package rollup@3.29.4" + +load("@aspect_bazel_lib//lib:directory_path.bzl", _directory_path = "directory_path") +load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary", _js_run_binary = "js_run_binary", _js_test = "js_test") + +def _rollup_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = "%s__js_binary" % name, + entry_point = ":%s__entry_point" % name, + data = ["@//:{}".format(store_target_name)], + include_npm = kwargs.pop("include_npm", False), + tags = ["manual"], + ) + _js_run_binary( + name = name, + tool = ":%s__js_binary" % name, + mnemonic = kwargs.pop("mnemonic", "Rollup"), + **kwargs + ) + +def _rollup_test_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_test( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def _rollup_binary_internal(name, link_root_name, **kwargs): + store_target_name = ".aspect_rules_js/{}/rollup@3.29.4".format(link_root_name) + _directory_path( + name = "%s__entry_point" % name, + directory = "@//:{}/dir".format(store_target_name), + path = "dist/bin/rollup", + tags = ["manual"], + ) + _js_binary( + name = name, + entry_point = ":%s__entry_point" % name, + data = kwargs.pop("data", []) + ["@//:{}".format(store_target_name)], + **kwargs + ) + +def rollup(name, **kwargs): + _rollup_internal(name, "node_modules", **kwargs) + +def rollup_test(name, **kwargs): + _rollup_test_internal(name, "node_modules", **kwargs) + +def rollup_binary(name, **kwargs): + _rollup_binary_internal(name, "node_modules", **kwargs) + +def bin_factory(link_root_name): + # bind link_root_name using lambdas + return struct( + rollup = lambda name, **kwargs: _rollup_internal(name, link_root_name = link_root_name, **kwargs), + rollup_test = lambda name, **kwargs: _rollup_test_internal(name, link_root_name = link_root_name, **kwargs), + rollup_binary = lambda name, **kwargs: _rollup_binary_internal(name, link_root_name = link_root_name, **kwargs), + rollup_path = "dist/bin/rollup", + ) + +bin = bin_factory("node_modules") diff --git a/npm/private/npm_translate_lock_generate.bzl b/npm/private/npm_translate_lock_generate.bzl index 29f7684609..15fa3e16df 100644 --- a/npm/private/npm_translate_lock_generate.bzl +++ b/npm/private/npm_translate_lock_generate.bzl @@ -265,15 +265,27 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): )) for link_package, _link_aliases in _import.link_packages.items(): link_aliases = _link_aliases or [_import.package] + + # the build file for the package being linked + build_file = "{}/{}".format(link_package, "BUILD.bazel") if link_package else "BUILD.bazel" + if build_file not in rctx_files: + rctx_files[build_file] = [] + + # the bzl files for the package being linked + if link_package not in links_bzl: + links_bzl[link_package] = [] + if link_package not in links_targets_bzl: + links_targets_bzl[link_package] = [] + + # for each alias of this package for link_alias in link_aliases: - if link_package not in links_bzl: - links_bzl[link_package] = [] - if link_package not in links_targets_bzl: - links_targets_bzl[link_package] = [] + # link the alias to the underlying package links_bzl[link_package].append(""" link_{i}(name = "{{}}/{name}".format(name))""".format( i = i, name = link_alias, )) + + # expose the alias if public if "//visibility:public" in _import.package_visibility: add_to_link_targets = """ link_targets.append("//{{}}:{{}}/{name}".format(bazel_package, name))""".format(name = link_alias) links_bzl[link_package].append(add_to_link_targets) @@ -282,43 +294,48 @@ def npm_link_all_packages(name = "node_modules", imported_links = []): package_scope = link_alias.split("/", 1)[0] add_to_scoped_targets = """ scope_targets["{package_scope}"] = scope_targets["{package_scope}"] + [link_targets[-1]] if "{package_scope}" in scope_targets else [link_targets[-1]]""".format(package_scope = package_scope) links_bzl[link_package].append(add_to_scoped_targets) - for link_package in _import.link_packages.keys(): - build_file = "{}/{}".format(link_package, "BUILD.bazel") if link_package else "BUILD.bazel" - if build_file not in rctx_files: - rctx_files[build_file] = [] - resolved_json_rel_path = "{}/{}".format(_import.package, _RESOLVED_JSON_FILENAME) if _import.package else _RESOLVED_JSON_FILENAME - resolved_json_file_path = "{}/{}".format(link_package, resolved_json_rel_path) if link_package else resolved_json_rel_path - rctx.file(resolved_json_file_path, json.encode({ - # Allow consumers to auto-detect this filetype - "$schema": "https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock", - "version": _import.version, - "integrity": _import.integrity, - })) - rctx_files[build_file].append("exports_files([\"{}\"])".format(resolved_json_rel_path)) + + # the resolved.json for this alias of the package + resolved_json_rel_path = "{}/{}".format(link_alias, _RESOLVED_JSON_FILENAME) + resolved_json_file_path = "{}/{}".format(link_package, resolved_json_rel_path) if link_package else resolved_json_rel_path + + rctx.file(resolved_json_file_path, json.encode({ + # Allow consumers to auto-detect this filetype + "$schema": "https://docs.aspect.build/rules/aspect_rules_js/docs/npm_translate_lock", + "version": _import.version, + "integrity": _import.integrity, + })) + rctx_files[build_file].append("exports_files([\"{}\"])".format(resolved_json_rel_path)) + + # the package_json.bzl for this package if _import.package_info.get("has_bin"): if rctx.attr.generate_bzl_library_targets: rctx_files[build_file].append("""load("@bazel_skylib//:bzl_library.bzl", "bzl_library")""") - rctx_files[build_file].append(_BZL_LIBRARY_TMPL.format( - name = _import.package, - src = ":{}/{}".format(_import.package, _PACKAGE_JSON_BZL_FILENAME), - dep = "@{repo_name}//{link_package}:{package_name}_bzl_library".format( - repo_name = helpers.to_apparent_repo_name(_import.name), - link_package = link_package, - package_name = link_package.split("/")[-1] or _import.package.split("/")[-1], + + for link_alias in link_aliases: + rctx_files[build_file].append(_BZL_LIBRARY_TMPL.format( + name = link_alias, + src = ":{}/{}".format(link_alias, _PACKAGE_JSON_BZL_FILENAME), + dep = "@{repo_name}//{link_package}:{package_name}_bzl_library".format( + repo_name = helpers.to_apparent_repo_name(_import.name), + link_package = link_package, + package_name = link_package.split("/")[-1] or link_alias.split("/")[-1], + ), + )) + + for link_alias in link_aliases: + package_json_bzl_file_path = "{}/{}/{}".format(link_package, link_alias, _PACKAGE_JSON_BZL_FILENAME) if link_package else "{}/{}".format(link_alias, _PACKAGE_JSON_BZL_FILENAME) + repo_package_json_bzl = "@@{repo_name}//{link_package}:{package_json_bzl}".format( + repo_name = _import.name, + link_package = link_package, + package_json_bzl = _PACKAGE_JSON_BZL_FILENAME, + ) + rctx.file( + package_json_bzl_file_path, + _BIN_TMPL.format( + repo_package_json_bzl = repo_package_json_bzl, ), - )) - package_json_bzl_file_path = "{}/{}/{}".format(link_package, _import.package, _PACKAGE_JSON_BZL_FILENAME) if link_package else "{}/{}".format(_import.package, _PACKAGE_JSON_BZL_FILENAME) - repo_package_json_bzl = "@@{repo_name}//{link_package}:{package_json_bzl}".format( - repo_name = _import.name, - link_package = link_package, - package_json_bzl = _PACKAGE_JSON_BZL_FILENAME, - ) - rctx.file( - package_json_bzl_file_path, - _BIN_TMPL.format( - repo_package_json_bzl = repo_package_json_bzl, - ), - ) + ) if len(stores_bzl) > 0: npm_link_all_packages_bzl.append(""" if is_root:""")