generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set explicit and configurable tsconfig (#151)
By default esbuild uses any local tsconfig.json file. With sandboxing issues (#58) this may unexpectedly cause `esbuild_bundle` to pickup any local tsconfig.json. A custom tsconfig can now be set using `esbuild_bundle(tsconfig)`. By default an empty tsconfig is used to prevent unexpected sandboxing issues.
- Loading branch information
Showing
17 changed files
with
125 additions
and
2 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
build --enable_runfiles | ||
common:bzlmod --enable_bzlmod |
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,48 @@ | ||
load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild") | ||
load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") | ||
|
||
SRCS = ["main.js", "libs/a.js", "libs/b.js"] | ||
ENTRY = "main.js" | ||
|
||
esbuild( | ||
name = "target-a", | ||
srcs = SRCS, | ||
entry_point = ENTRY, | ||
tsconfig = "tsconfig-a.json", | ||
output = "a.js", | ||
) | ||
|
||
esbuild( | ||
name = "target-b", | ||
srcs = SRCS, | ||
entry_point = ENTRY, | ||
tsconfig = "tsconfig-b.json", | ||
output = "b.js", | ||
) | ||
|
||
esbuild( | ||
name = "target-none", | ||
# include the tsconfig.json with bad syntax and ensure it is not used | ||
srcs = [ENTRY, "tsconfig.json"], | ||
entry_point = ENTRY, | ||
output = "none.js", | ||
external = ["var-lib"], | ||
) | ||
|
||
assert_contains( | ||
name = "config-a", | ||
actual = "a.js", | ||
expected = "library: A" | ||
) | ||
|
||
assert_contains( | ||
name = "config-b", | ||
actual = "b.js", | ||
expected = "library: B" | ||
) | ||
|
||
assert_contains( | ||
name = "config-none", | ||
actual = "none.js", | ||
expected = "var-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"Bazel dependencies" | ||
bazel_dep(name = "aspect_rules_esbuild", dev_dependency = True, version = "0.0.0") | ||
bazel_dep(name = "aspect_bazel_lib", dev_dependency = True, version = "1.29.2") | ||
|
||
local_path_override( | ||
module_name = "aspect_rules_esbuild", | ||
path = "../..", | ||
) |
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,22 @@ | ||
local_repository( | ||
name = "aspect_rules_esbuild", | ||
path = "../..", | ||
) | ||
|
||
load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies") | ||
|
||
rules_esbuild_dependencies() | ||
|
||
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") | ||
|
||
nodejs_register_toolchains( | ||
name = "node", | ||
node_version = DEFAULT_NODE_VERSION, | ||
) | ||
|
||
load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_ESBUILD_VERSION", "esbuild_register_toolchains") | ||
|
||
esbuild_register_toolchains( | ||
name = "esbuild", | ||
esbuild_version = LATEST_ESBUILD_VERSION, | ||
) |
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 @@ | ||
export const ANSWER = "library: A" |
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 ANSWER = "library: B" |
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 { ANSWER } from "var-lib" | ||
|
||
console.log(ANSWER) |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"var-lib": ["./libs/a.js"] | ||
} | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"var-lib": ["./libs/b.js"] | ||
} | ||
} | ||
} |
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 @@ | ||
with invalid syntax, esbuild shouldn't use this |
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 @@ | ||
{} |
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