Skip to content

Commit

Permalink
fix(esbuild): fix depending on testonly targets (#2984)
Browse files Browse the repository at this point in the history
* test(esbuild): test depending on a testonly target

* fix(esbuild): fix depending on testonly targets
  • Loading branch information
mattsoulanille authored Sep 27, 2021
1 parent 9a065cd commit 4278ef1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/esbuild/esbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def esbuild_macro(name, output_dir = False, splitting = False, **kwargs):
args_file = "%s.user.args.json" % name
params_file(
name = "%s_args" % name,
testonly = kwargs.get("testonly", False),
out = args_file,
args = [json.encode(args)],
data = deps + srcs,
Expand Down
48 changes: 48 additions & 0 deletions packages/esbuild/test/testonly/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
load("//:index.bzl", "generated_file_test", "js_library", "nodejs_binary", "npm_package_bin")
load("//packages/esbuild:index.bzl", "esbuild")

js_library(
name = "lib",
srcs = ["lib.jsx"],
)

js_library(
name = "main",
testonly = True,
srcs = ["main.js"],
deps = [":lib"],
)

esbuild(
name = "bundle",
testonly = True,
args = {
"keepNames": True,
},
entry_point = "main.js",
deps = [
":main",
],
)

nodejs_binary(
name = "bin",
testonly = True,
data = [
":bundle",
],
entry_point = "bundle.js",
)

npm_package_bin(
name = "runner",
testonly = True,
stdout = "out.txt",
tool = ":bin",
)

generated_file_test(
name = "test",
src = "out.golden.txt",
generated = "out.txt",
)
1 change: 1 addition & 0 deletions packages/esbuild/test/testonly/lib.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const NAME = 'rules_nodejs';
3 changes: 3 additions & 0 deletions packages/esbuild/test/testonly/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {NAME as name} from './lib';

console.log(name);
1 change: 1 addition & 0 deletions packages/esbuild/test/testonly/out.golden.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rules_nodejs

0 comments on commit 4278ef1

Please sign in to comment.