-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(npm): npm_link_package() in subdirectory to js_library() package
- Loading branch information
Showing
24 changed files
with
674 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
root/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.bazeliskrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Import Aspect bazelrc presets | ||
try-import %workspace%/../../.aspect/bazelrc/bazel7.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/convenience.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/correctness.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/debug.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/javascript.bazelrc | ||
import %workspace%/../../.aspect/bazelrc/performance.bazelrc | ||
|
||
### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### | ||
|
||
# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. | ||
# This file should appear in `.gitignore` so that settings are not shared with team members. This | ||
# should be last statement in this config so the user configuration is able to overwrite flags from | ||
# this file. See https://bazel.build/configure/best-practices#bazelrc-file. | ||
try-import %workspace%/../../.aspect/bazelrc/user.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../.bazelversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Disabling pnpm [hoisting](https://pnpm.io/npmrc#hoist) by setting `hoist=false` is recommended on | ||
# projects using rules_js so that pnpm outside of Bazel lays out a node_modules tree similar to what | ||
# rules_js lays out under Bazel (without a hidden node_modules/.pnpm/node_modules) | ||
hoist=false |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
local_repository( | ||
name = "aspect_rules_js", | ||
path = "../..", | ||
) | ||
|
||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") | ||
|
||
rules_js_dependencies() | ||
|
||
load("@aspect_rules_js//js:toolchains.bzl", "rules_js_register_toolchains") | ||
|
||
rules_js_register_toolchains(node_version = "16.14.2") | ||
|
||
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") | ||
|
||
npm_translate_lock( | ||
name = "npm", | ||
lifecycle_hooks_envs = { | ||
"*": [ | ||
"aspect_test_id=testc", | ||
"BUILD_VERSION=1", | ||
], | ||
# Without APPDATA environment variable, sharp install will fail because of the binary can not | ||
# be copied to ~/.npm folder which is readonly for bazel. | ||
"sharp": ["APPDATA=."], | ||
}, | ||
lifecycle_hooks_execution_requirements = { | ||
"sharp": ["requires-network"], | ||
}, | ||
npm_package_target_name = "{dirname}_pkg", | ||
npmrc = "//:.npmrc", | ||
pnpm_lock = "//root:pnpm-lock.yaml", | ||
verify_node_modules_ignored = "//:.bazelignore", | ||
) | ||
|
||
load("@npm//:repositories.bzl", "npm_repositories") | ||
|
||
npm_repositories() | ||
|
||
local_repository( | ||
name = "rules_foo", | ||
path = "../rules_foo", | ||
) | ||
|
||
load("@rules_foo//foo:repositories.bzl", "foo_repositories") | ||
|
||
foo_repositories() | ||
|
||
load("@foo//:npm_repositories.bzl", foo_npm_repositories = "npm_repositories") | ||
|
||
foo_npm_repositories() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package") | ||
load("@foo//:@aspect-test/a/package_json.bzl", aspect_test_a_bin = "bin") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") | ||
|
||
npm_link_package( | ||
name = "node_modules/@e2e/lib", | ||
src = "//root/lib:lib_pkg", | ||
package = "@e2e/lib", | ||
root_package = "root", | ||
) | ||
|
||
npm_link_package( | ||
name = "node_modules/@e2e/pkg", | ||
src = "//root/pkg:lib_pkg", | ||
root_package = "root", | ||
) | ||
|
||
npm_link_package( | ||
name = "node_modules/@e2e/wrapper-lib", | ||
src = "//root/wrapper-lib:wrapper-lib_pkg", | ||
root_package = "root", | ||
) | ||
|
||
aspect_test_a_bin.bin_a_test( | ||
name = "aspect_test_a_bin_test", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
|
||
js_library( | ||
name = "lib_pkg", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
# uvu is a runtime dependency of this package and should be linked into its direct dependencies | ||
# by the downstream npm_link_package | ||
"//root:node_modules/uvu", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const packageJson = require('./package.json') | ||
const assert = require('uvu/assert') | ||
assert.is(2 + 2, 4) | ||
module.exports = { | ||
id: () => | ||
`${packageJson.name}@${ | ||
packageJson.version ? packageJson.version : '0.0.0' | ||
}`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@e2e/lib", | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "simple", | ||
"dependencies": { | ||
"@aspect-test/a": "5.0.2", | ||
"sharp": "0.32.1", | ||
"uvu": "0.5.6" | ||
}, | ||
"devDependencies": { | ||
"@aspect-test/b": "5.0.2" | ||
}, | ||
"optionalDependencies": { | ||
"@aspect-test/c": "2.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_package") | ||
|
||
npm_package( | ||
name = "lib_pkg", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
data = [ | ||
# A locally linked package as a runtime dependency | ||
"//root:node_modules/@e2e/lib", | ||
# uvu is a runtime dependency of this package and should be linked into its direct dependencies | ||
# by the downstream npm_link_package | ||
"//root:node_modules/uvu", | ||
], | ||
package = "@e2e/pkg", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const packageJson = require('./package.json') | ||
const assert = require('uvu/assert') | ||
const lib = require('@e2e/lib') | ||
assert.is(2 + 2, 4) | ||
module.exports = { | ||
id: () => | ||
`${packageJson.name}@${ | ||
packageJson.version ? packageJson.version : '0.0.0' | ||
}` + lib.id(), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@e2e/pkg", | ||
"private": true | ||
} |
Oops, something went wrong.