-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exports_directories_only causes node to resolve from runfiles/no…
…de_modules (#3380)
- Loading branch information
Showing
12 changed files
with
92 additions
and
6 deletions.
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
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
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,19 @@ | ||
load("@npm//pkg_with_bin:index.bzl", "instanceof_execroot_test") | ||
load( | ||
"@npm_directory_artifacts//pkg_with_bin:index.bzl", | ||
instanceof_execroot_test_exports_directories = "instanceof_execroot_test", | ||
) | ||
|
||
instanceof_execroot_test( | ||
name = "test", | ||
data = [ | ||
"//internal/node/test/instanceof_test_execroot/lib", | ||
], | ||
) | ||
|
||
instanceof_execroot_test_exports_directories( | ||
name = "test_exports_directories_only", | ||
data = [ | ||
"//internal/node/test/instanceof_test_execroot/lib", | ||
], | ||
) |
Empty file.
16 changes: 16 additions & 0 deletions
16
internal/node/test/instanceof_test_execroot/lib/BUILD.bazel
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,16 @@ | ||
load("//:index.bzl", "js_library") | ||
|
||
package(default_visibility = ["//internal/node/test/instanceof_test_execroot:__subpackages__"]) | ||
|
||
js_library( | ||
name = "lib", | ||
# required by tools/npm_packages/pkg_with_bin as third-party dep | ||
package_name = "instanceof_test_execroot_lib", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
deps = [ | ||
"@npm//node_resolve_main", | ||
], | ||
) |
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,20 @@ | ||
// This file will fail when one dependency is resolved from two distinct node_modules | ||
// mostly likely to be one inside runfiles and other from bazel-out | ||
// See: https://github.com/bazelbuild/rules_nodejs/pull/3380 for more. | ||
const assert = require("assert"); | ||
|
||
const resolved_by_lib = require.resolve("node_resolve_main"); | ||
const resolved_by_pkg_with_bin = globalThis["node_resolve_main_resolved_path_by_pkg_with_bin"] | ||
assert.equal( | ||
resolved_by_lib, | ||
resolved_by_pkg_with_bin, | ||
` | ||
Expected to resolve package "node_resolve_main" from the same node_modules but | ||
tools/npm_packages/pkg_with_bin resolved it from ${resolved_by_pkg_with_bin} | ||
internal/node/test/instanceof_test_execroot/lib resolved it from ${resolved_by_lib} | ||
See: https://github.com/bazelbuild/rules_nodejs/pull/3380 for context. | ||
` | ||
); |
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 @@ | ||
{"name": "instanceof_test_execroot_lib"} |
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
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
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,3 @@ | ||
globalThis["node_resolve_main_resolved_path_by_pkg_with_bin"] = require.resolve("node_resolve_main"); | ||
require("instanceof_test_execroot_lib"); | ||
// See: internal/node/test/instanceof_test_execroot |
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 @@ | ||
{ | ||
"version": "0.0.1", | ||
"description": "See: internal/node/test/instanceof_test_execroot", | ||
"bin": { | ||
"instanceof_execroot": "main.js" | ||
}, | ||
"peerDependencies": { | ||
"node_resolve_main": "*" | ||
} | ||
} |
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