Skip to content

Commit

Permalink
fix: transitive js_library npm package deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jul 2, 2024
1 parent 61d6083 commit 6b8a7a5
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
app/a/package.json=574382986
app/b/package.json=795450875
app/c/package.json=1357235418
app/d/package.json=1859553579
lib/a/package.json=1162557353
lib/b/package.json=1612905941
lib/c/package.json=1015268365
lib/d/package.json=-1311314987
lib/d/package.json=476969669
package.json=-716078204
pnpm-lock.yaml=793845425
pnpm-lock.yaml=-1749700182
pnpm-workspace.yaml=-67685769
vendored/a/package.json=-174142441
vendored/b/package.json=536664170
1 change: 1 addition & 0 deletions e2e/pnpm_workspace/.bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
app/a/node_modules/
app/b/node_modules/
app/c/node_modules/
app/d/node_modules/
lib/a/node_modules/
lib/b/node_modules/
lib/c/node_modules/
Expand Down
26 changes: 26 additions & 0 deletions e2e/pnpm_workspace/app/d/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

js_binary(
name = "main",
args = ["foo"],
data = [
":node_modules/@aspect-test",
":node_modules/@lib/d",
"//:node_modules/@aspect-test",
],
entry_point = "main.js",
)

js_test(
name = "test",
args = ["foo"],
data = [
":node_modules",
"//:node_modules/@aspect-test",
],
entry_point = "main.js",
log_level = "info",
)
7 changes: 7 additions & 0 deletions e2e/pnpm_workspace/app/d/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
console.log(process.argv)
console.log('--@aspect-test/a--', require('@aspect-test/a').id())
console.log('--@aspect-test/b--', require('@aspect-test/b').id())
console.log('--@aspect-test/c--', require('@aspect-test/c').id())
console.log('--@aspect-test/g--', require('@aspect-test/g').id())
console.log('--@lib/d--', require('@lib/d').id())
console.log('--@lib/d--', require('@lib/d').test())
8 changes: 8 additions & 0 deletions e2e/pnpm_workspace/app/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@app/c",
"private": true,
"dependencies": {
"@aspect-test/g": "1.0.0",
"@lib/d": "workspace:*"
}
}
1 change: 1 addition & 0 deletions e2e/pnpm_workspace/lib/d/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ js_library(
],
visibility = ["//visibility:public"],
deps = [
":node_modules/@aspect-test/d",
":node_modules/alias-2",
],
)
7 changes: 5 additions & 2 deletions e2e/pnpm_workspace/lib/d/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const packageJson = require('./package.json')
const a2 = require('alias-2/package.json')
module.exports = {
id: () =>
`${packageJson.name}@${
packageJson.version ? packageJson.version : '0.0.0'
}`,
test: () => [a2.name].join('\n'),
test: () =>
[
require('@aspect-test/d').version,
require('alias-2/package.json').name,
].join('\n'),
}
1 change: 1 addition & 0 deletions e2e/pnpm_workspace/lib/d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@lib/d",
"private": true,
"dependencies": {
"@aspect-test/d": "^2.0.0",
"alias-2": "npm:@types/node@16.18.11"
}
}
12 changes: 12 additions & 0 deletions e2e/pnpm_workspace/pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
app/a/package.json=574382986
app/b/package.json=795450875
app/c/package.json=1357235418
app/d/package.json=1859553579
lib/a/package.json=1162557353
lib/b/package.json=1612905941
lib/c/package.json=1015268365
lib/d/package.json=-1311314987
lib/d/package.json=476969669
package.json=-716078204
root/pnpm-lock.yaml=-1844676859
root/pnpm-lock.yaml=1120945581
root/pnpm-workspace.yaml=1861018878
vendored/a/package.json=-174142441
vendored/b/package.json=536664170
1 change: 1 addition & 0 deletions e2e/pnpm_workspace_rerooted/.bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
app/a/node_modules/
app/b/node_modules/
app/c/node_modules/
app/d/node_modules/
lib/a/node_modules/
lib/b/node_modules/
lib/c/node_modules/
Expand Down
26 changes: 26 additions & 0 deletions e2e/pnpm_workspace_rerooted/app/d/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_test")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

js_binary(
name = "main",
args = ["foo"],
data = [
":node_modules/@aspect-test",
":node_modules/@lib/d",
"//:node_modules/@aspect-test",
],
entry_point = "main.js",
)

js_test(
name = "test",
args = ["foo"],
data = [
":node_modules",
"//:node_modules/@aspect-test",
],
entry_point = "main.js",
log_level = "info",
)
7 changes: 7 additions & 0 deletions e2e/pnpm_workspace_rerooted/app/d/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
console.log(process.argv)
console.log('--@aspect-test/a--', require('@aspect-test/a').id())
console.log('--@aspect-test/b--', require('@aspect-test/b').id())
console.log('--@aspect-test/c--', require('@aspect-test/c').id())
console.log('--@aspect-test/g--', require('@aspect-test/g').id())
console.log('--@lib/d--', require('@lib/d').id())
console.log('--@lib/d--', require('@lib/d').test())
8 changes: 8 additions & 0 deletions e2e/pnpm_workspace_rerooted/app/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@app/c",
"private": true,
"dependencies": {
"@aspect-test/g": "1.0.0",
"@lib/d": "workspace:*"
}
}
1 change: 1 addition & 0 deletions e2e/pnpm_workspace_rerooted/lib/d/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ js_library(
],
visibility = ["//visibility:public"],
deps = [
":node_modules/@aspect-test/d",
":node_modules/alias-2",
],
)
7 changes: 5 additions & 2 deletions e2e/pnpm_workspace_rerooted/lib/d/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const packageJson = require('./package.json')
const a2 = require('alias-2/package.json')
module.exports = {
id: () =>
`${packageJson.name}@${
packageJson.version ? packageJson.version : '0.0.0'
}`,
test: () => [a2.name].join('\n'),
test: () =>
[
require('@aspect-test/d').version,
require('alias-2/package.json').name,
].join('\n'),
}
1 change: 1 addition & 0 deletions e2e/pnpm_workspace_rerooted/lib/d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@lib/d",
"private": true,
"dependencies": {
"@aspect-test/d": "^2.0.0",
"alias-2": "npm:@types/node@16.18.11"
}
}
12 changes: 12 additions & 0 deletions e2e/pnpm_workspace_rerooted/root/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions npm/private/npm_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ deps of npm_package_store must be in the same package.""" % (ctx.label.package,
symlink_path = "{}/{}".format(ctx.label.package or ".", package_store_directory_path)
transitive_files_depsets.append(jsinfo.transitive_sources)
transitive_files_depsets.append(jsinfo.transitive_types)
transitive_files_depsets.append(jsinfo.npm_sources)
transitive_package_store_infos_depsets.append(jsinfo.npm_package_store_infos)
if jsinfo.target.workspace_name:
target_path = "{}/external/{}/{}".format(ctx.bin_dir.path, jsinfo.target.workspace_name, jsinfo.target.package)
Expand Down

0 comments on commit 6b8a7a5

Please sign in to comment.