Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: demonstrate dev dependencies between workspace projects #2056

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
cases/node_modules
projects/a/node_modules
projects/a-types/node_modules
projects/b/node_modules
projects/c/node_modules
projects/d/node_modules
Expand Down
6 changes: 3 additions & 3 deletions e2e/pnpm_lockfiles/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ npm = use_extension(
"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,
"lock-%s__at_types_sizzle__2.3.8__links" % version,
"lock-%s__at_types_sizzle__2.3.9" % version,
"lock-%s__at_types_sizzle__2.3.9__links" % version,

# Dep with peers
"lock-%s__at_aspect-test_d__2.0.0_at_aspect-test_c_2.0.2" % version,
Expand All @@ -81,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" if version == "v90" else "1813138439",
"3vgsug3mjv7wvue74swjdxifxy" if version == "v54" else "626159424" if version == "v90" else "1813138439",
),

# Dep with patch
Expand Down
2 changes: 1 addition & 1 deletion e2e/pnpm_lockfiles/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@aspect-test/b": "5.0.2",
"@types/node": "16.18.11",
"@types/archiver": "5.3.1",
"alias-only-sizzle": "npm:@types/sizzle@~2.3.8",
"alias-only-sizzle": "npm:@types/sizzle@~2.3.9",
"alias-types-node": "npm:@types/node@~16.18.11"
},
"optionalDependencies": {
Expand Down
11 changes: 7 additions & 4 deletions e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@ BZL_FILES = {
"rollup3_package_json.bzl": "@REPO_NAME__rollup__3.29.4//VERSION:package_json.bzl",
}

def lockfile_test(name = None):
def lockfile_test(npm_link_all_packages, name = None):
"""
Tests for a lockfile and associated targets + files generated by rules_js.

Args:
name: the lockfile version name
npm_link_all_packages: the npm_link_all_packages function
"""

lock_version = name if name else native.package_name()
lock_repo = "lock-%s" % lock_version

npm_link_all_packages(name = "node_modules")

# Copy each test to this lockfile dir
for test in ["patched-dependencies-test.js", "aliases-test.js"]:
copy_file(
Expand Down Expand Up @@ -102,7 +105,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" if lock_version == "v90" else "1813138439"),
"@%s__at_rollup_plugin-typescript__8.2.1_%s//:pkg" % (lock_repo, "3vgsug3mjv7wvue74swjdxifxy" if lock_version == "v54" else "626159424" if lock_version == "v90" else "1813138439"),

# uuv 'hasBin'
":node_modules/uvu",
Expand Down Expand Up @@ -152,8 +155,8 @@ def lockfile_test(name = None):

# npm: alias to package not listed elsewhere
":node_modules/alias-only-sizzle",
":.aspect_rules_js/node_modules/@[email protected].8",
"@%s__at_types_sizzle__2.3.8//:pkg" % lock_repo,
":.aspect_rules_js/node_modules/@[email protected].9",
"@%s__at_types_sizzle__2.3.9//:pkg" % lock_repo,

# Targets within the virtual store...
# Direct dep targets
Expand Down
10 changes: 10 additions & 0 deletions e2e/pnpm_lockfiles/projects/a-types/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

js_library(
name = "pkg",
srcs = [
"a.d.ts",
"package.json",
],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/projects/a-types/a.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const A: number
7 changes: 7 additions & 0 deletions e2e/pnpm_lockfiles/projects/a-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "a-types",
"private": true,
"dependencies": {
"@types/node": "16.18.11"
}
}
4 changes: 4 additions & 0 deletions e2e/pnpm_lockfiles/projects/b/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"private": true,
"dependencies": {
"@scoped/a": "workspace:*"
},
"devDependencies": {
"@types/node": "16.18.11",
"a-types": "workspace:*"
}
}
4 changes: 1 addition & 3 deletions e2e/pnpm_lockfiles/v54/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("@lock-v54//:defs.bzl", "npm_link_all_packages")
load("//:lockfile-test.bzl", "lockfile_test")

npm_link_all_packages()

lockfile_test()
lockfile_test(npm_link_all_packages = npm_link_all_packages)
53 changes: 32 additions & 21 deletions e2e/pnpm_lockfiles/v54/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading