-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(esbuild): prefer finding entry_point files in deps rather than sr…
…cs (#2692) When using esbuild with `js_library`, the entry_point may be part of the deps, therefore the path will end up in `bazel-out/` inside the sandbox where esbuild is running, however the entrypoint path will be in the sources path, leaving any relative path inputs to no longer be relative to the entrypoint file. The reordering here forces the `resolve_entry_point` method to prefer the file that resides in the `bazel-out/` path in the sandbox. A possible future breaking change would be to force users to list the entrypoint file(s) in either srcs or deps for the correct pathing, or remove `srcs` from esbuild, meaning all input files must be in the output tree.
- Loading branch information
Showing
5 changed files
with
49 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
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,41 @@ | ||
load("//:index.bzl", "generated_file_test", "js_library", "nodejs_binary", "npm_package_bin") | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
|
||
js_library( | ||
name = "lib", | ||
srcs = ["lib.jsx"], | ||
) | ||
|
||
js_library( | ||
name = "main", | ||
srcs = ["main.js"], | ||
deps = [":lib"], | ||
) | ||
|
||
esbuild( | ||
name = "bundle", | ||
entry_point = "main.js", | ||
deps = [ | ||
":main", | ||
], | ||
) | ||
|
||
nodejs_binary( | ||
name = "bin", | ||
data = [ | ||
":bundle", | ||
], | ||
entry_point = "bundle.js", | ||
) | ||
|
||
npm_package_bin( | ||
name = "runner", | ||
stdout = "out.txt", | ||
tool = ":bin", | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "out.golden.txt", | ||
generated = "out.txt", | ||
) |
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 @@ | ||
export const NAME = 'rules_nodejs'; |
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 @@ | ||
import {NAME as name} from './lib'; | ||
|
||
console.log(name); |
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 @@ | ||
rules_nodejs |