Skip to content

Commit d208fcf

Browse files
jbedardGreg Magolan
authored andcommitted
test: add e2e esm version of npm_link_package test
1 parent 389593c commit d208fcf

18 files changed

Lines changed: 593 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
# TODO: figure out and re-enable
4545
# - 'e2e/bzlmod'
4646
- 'e2e/npm_link_package'
47+
- 'e2e/npm_link_package-esm'
4748
- 'e2e/pnpm_workspace'
4849
- 'e2e/pnpm_workspace_rerooted'
4950
- 'e2e/npm_translate_package_lock'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

e2e/npm_link_package-esm/.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# import common bazelrc shared with e2e workspaces
2+
import %workspace%/../../.bazelrc.common
3+
build --sandbox_default_allow_network=false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.bazelversion
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@npm//:defs.bzl", "npm_link_all_packages")
2+
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
3+
load("@rules_foo_npm//foo:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin")
4+
5+
npm_link_all_packages(name = "node_modules")
6+
7+
npm_link_package(
8+
name = "node_modules/@e2e/lib",
9+
src = "//lib",
10+
visibility = ["//visibility:public"],
11+
)
12+
13+
npm_link_package(
14+
name = "node_modules/@e2e/wrapper-lib",
15+
src = "//wrapper-lib",
16+
)
17+
18+
aspect_test_a_bin.bin_a_test(
19+
name = "aspect_test_a_bin_test",
20+
)

e2e/npm_link_package-esm/WORKSPACE

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
local_repository(
2+
name = "aspect_rules_js",
3+
path = "../..",
4+
)
5+
6+
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
7+
8+
rules_js_dependencies()
9+
10+
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
11+
12+
nodejs_register_toolchains(
13+
name = "nodejs",
14+
node_version = "16.9.0",
15+
)
16+
17+
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
18+
19+
npm_translate_lock(
20+
name = "npm",
21+
lifecycle_hooks_envs = {
22+
"*": [
23+
"aspect_test_id=testc",
24+
"BUILD_VERSION=1",
25+
],
26+
# Without APPDATA environment variable, sharp install will fail because of the binary can not
27+
# be copied to ~/.npm folder which is readonly for bazel.
28+
"sharp": ["APPDATA=."],
29+
},
30+
lifecycle_hooks_execution_requirements = {
31+
"sharp": [
32+
# Workaround Engflow not honoring requires-network on build actions
33+
"no-remote-exec",
34+
"requires-network",
35+
],
36+
},
37+
pnpm_lock = "//:pnpm-lock.yaml",
38+
verify_node_modules_ignored = "//:.bazelignore",
39+
)
40+
41+
load("@npm//:repositories.bzl", "npm_repositories")
42+
43+
npm_repositories()
44+
45+
local_repository(
46+
name = "rules_foo",
47+
path = "../rules_foo",
48+
)
49+
50+
load("@rules_foo//:repositories.bzl", rules_foo_repositories = "repositories")
51+
52+
rules_foo_repositories()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
2+
3+
npm_package(
4+
name = "lib",
5+
srcs = [
6+
"index.mjs",
7+
"package.json",
8+
],
9+
package = "@e2e/lib",
10+
visibility = ["//visibility:public"],
11+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import packageJson from './package.json';
2+
3+
export const id = () =>
4+
`${packageJson.name}@${
5+
packageJson.version ? packageJson.version : '0.0.0'
6+
}`
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@e2e/lib",
3+
"private": true,
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"import": "./index.mjs"
8+
}
9+
}
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "simple",
3+
"dependencies": {
4+
"@aspect-test/a": "5.0.0",
5+
"sharp": "0.30.7"
6+
},
7+
"devDependencies": {
8+
"@aspect-test/b": "5.0.2"
9+
},
10+
"optionalDependencies": {
11+
"@aspect-test/c": "2.0.2"
12+
}
13+
}

0 commit comments

Comments
 (0)